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 24 #include <linux/config.h> 25 #include <linux/in6.h> 26 #include <linux/in.h> 27 28 struct scsi_transport_template; 29 30 struct iscsi_class_session { 31 uint8_t isid[6]; 32 uint16_t tsih; 33 int header_digest; /* 1 CRC32, 0 None */ 34 int data_digest; /* 1 CRC32, 0 None */ 35 uint16_t tpgt; 36 union { 37 struct in6_addr sin6_addr; 38 struct in_addr sin_addr; 39 } u; 40 sa_family_t addr_type; /* must be AF_INET or AF_INET6 */ 41 uint16_t port; /* must be in network byte order */ 42 int initial_r2t; /* 1 Yes, 0 No */ 43 int immediate_data; /* 1 Yes, 0 No */ 44 uint32_t max_recv_data_segment_len; 45 uint32_t max_burst_len; 46 uint32_t first_burst_len; 47 uint16_t def_time2wait; 48 uint16_t def_time2retain; 49 uint16_t max_outstanding_r2t; 50 int data_pdu_in_order; /* 1 Yes, 0 No */ 51 int data_sequence_in_order; /* 1 Yes, 0 No */ 52 int erl; 53 }; 54 55 /* 56 * accessor macros 57 */ 58 #define iscsi_isid(x) \ 59 (((struct iscsi_class_session *)&(x)->starget_data)->isid) 60 #define iscsi_tsih(x) \ 61 (((struct iscsi_class_session *)&(x)->starget_data)->tsih) 62 #define iscsi_header_digest(x) \ 63 (((struct iscsi_class_session *)&(x)->starget_data)->header_digest) 64 #define iscsi_data_digest(x) \ 65 (((struct iscsi_class_session *)&(x)->starget_data)->data_digest) 66 #define iscsi_port(x) \ 67 (((struct iscsi_class_session *)&(x)->starget_data)->port) 68 #define iscsi_addr_type(x) \ 69 (((struct iscsi_class_session *)&(x)->starget_data)->addr_type) 70 #define iscsi_sin_addr(x) \ 71 (((struct iscsi_class_session *)&(x)->starget_data)->u.sin_addr) 72 #define iscsi_sin6_addr(x) \ 73 (((struct iscsi_class_session *)&(x)->starget_data)->u.sin6_addr) 74 #define iscsi_tpgt(x) \ 75 (((struct iscsi_class_session *)&(x)->starget_data)->tpgt) 76 #define iscsi_initial_r2t(x) \ 77 (((struct iscsi_class_session *)&(x)->starget_data)->initial_r2t) 78 #define iscsi_immediate_data(x) \ 79 (((struct iscsi_class_session *)&(x)->starget_data)->immediate_data) 80 #define iscsi_max_recv_data_segment_len(x) \ 81 (((struct iscsi_class_session *)&(x)->starget_data)->max_recv_data_segment_len) 82 #define iscsi_max_burst_len(x) \ 83 (((struct iscsi_class_session *)&(x)->starget_data)->max_burst_len) 84 #define iscsi_first_burst_len(x) \ 85 (((struct iscsi_class_session *)&(x)->starget_data)->first_burst_len) 86 #define iscsi_def_time2wait(x) \ 87 (((struct iscsi_class_session *)&(x)->starget_data)->def_time2wait) 88 #define iscsi_def_time2retain(x) \ 89 (((struct iscsi_class_session *)&(x)->starget_data)->def_time2retain) 90 #define iscsi_max_outstanding_r2t(x) \ 91 (((struct iscsi_class_session *)&(x)->starget_data)->max_outstanding_r2t) 92 #define iscsi_data_pdu_in_order(x) \ 93 (((struct iscsi_class_session *)&(x)->starget_data)->data_pdu_in_order) 94 #define iscsi_data_sequence_in_order(x) \ 95 (((struct iscsi_class_session *)&(x)->starget_data)->data_sequence_in_order) 96 #define iscsi_erl(x) \ 97 (((struct iscsi_class_session *)&(x)->starget_data)->erl) 98 99 /* 100 * The functions by which the transport class and the driver communicate 101 */ 102 struct iscsi_function_template { 103 /* 104 * target attrs 105 */ 106 void (*get_isid)(struct scsi_target *); 107 void (*get_tsih)(struct scsi_target *); 108 void (*get_header_digest)(struct scsi_target *); 109 void (*get_data_digest)(struct scsi_target *); 110 void (*get_port)(struct scsi_target *); 111 void (*get_tpgt)(struct scsi_target *); 112 /* 113 * In get_ip_address the lld must set the address and 114 * the address type 115 */ 116 void (*get_ip_address)(struct scsi_target *); 117 /* 118 * The lld should snprintf the name or alias to the buffer 119 */ 120 ssize_t (*get_target_name)(struct scsi_target *, char *, ssize_t); 121 ssize_t (*get_target_alias)(struct scsi_target *, char *, ssize_t); 122 void (*get_initial_r2t)(struct scsi_target *); 123 void (*get_immediate_data)(struct scsi_target *); 124 void (*get_max_recv_data_segment_len)(struct scsi_target *); 125 void (*get_max_burst_len)(struct scsi_target *); 126 void (*get_first_burst_len)(struct scsi_target *); 127 void (*get_def_time2wait)(struct scsi_target *); 128 void (*get_def_time2retain)(struct scsi_target *); 129 void (*get_max_outstanding_r2t)(struct scsi_target *); 130 void (*get_data_pdu_in_order)(struct scsi_target *); 131 void (*get_data_sequence_in_order)(struct scsi_target *); 132 void (*get_erl)(struct scsi_target *); 133 134 /* 135 * host atts 136 */ 137 138 /* 139 * The lld should snprintf the name or alias to the buffer 140 */ 141 ssize_t (*get_initiator_alias)(struct Scsi_Host *, char *, ssize_t); 142 ssize_t (*get_initiator_name)(struct Scsi_Host *, char *, ssize_t); 143 /* 144 * The driver sets these to tell the transport class it 145 * wants the attributes displayed in sysfs. If the show_ flag 146 * is not set, the attribute will be private to the transport 147 * class. We could probably just test if a get_ fn was set 148 * since we only use the values for sysfs but this is how 149 * fc does it too. 150 */ 151 unsigned long show_isid:1; 152 unsigned long show_tsih:1; 153 unsigned long show_header_digest:1; 154 unsigned long show_data_digest:1; 155 unsigned long show_port:1; 156 unsigned long show_tpgt:1; 157 unsigned long show_ip_address:1; 158 unsigned long show_target_name:1; 159 unsigned long show_target_alias:1; 160 unsigned long show_initial_r2t:1; 161 unsigned long show_immediate_data:1; 162 unsigned long show_max_recv_data_segment_len:1; 163 unsigned long show_max_burst_len:1; 164 unsigned long show_first_burst_len:1; 165 unsigned long show_def_time2wait:1; 166 unsigned long show_def_time2retain:1; 167 unsigned long show_max_outstanding_r2t:1; 168 unsigned long show_data_pdu_in_order:1; 169 unsigned long show_data_sequence_in_order:1; 170 unsigned long show_erl:1; 171 unsigned long show_initiator_name:1; 172 unsigned long show_initiator_alias:1; 173 }; 174 175 struct scsi_transport_template *iscsi_attach_transport(struct iscsi_function_template *); 176 void iscsi_release_transport(struct scsi_transport_template *); 177 178 #endif 179