1 /**********************************************************************
2  * iph5526.c: Structures for the Interphase 5526 PCI Fibre Channel
3  *			  IP/SCSI driver.
4  * Copyright (C) 1999 Vineet M Abraham <vmabraham@hotmail.com>
5  **********************************************************************/
6 
7 #ifndef _TACH_STRUCT_H
8 #define _TACH_STRUCT_H
9 
10 typedef struct {
11 	u_short cmnd_code;
12 	u_short payload_length;
13 	u_short type_code;
14 	u_short est_image_pair;
15 	u_int originator_pa;
16 	u_int responder_pa;
17 	u_int service_params;
18 } PRLI;
19 
20 typedef struct {
21 	u_int flags_and_byte_offset;
22 	u_int byte_count;
23 	u_short no_of_recvd_frames;
24 	u_short no_of_expected_frames;
25 	u_int last_fctl;
26 	u_int sdb_address;
27 	u_int scratch_pad;
28 	u_int expected_ro;
29 	u_short buffer_index;
30 	u_short buffer_offset;
31 	} INB_SEST_ENTRY;
32 
33 typedef struct {
34 	u_int flags_and_did;
35 	u_short max_frame_len;
36 	u_short cntl;
37 	u_int total_seq_length;
38 	u_short link;
39 	u_short rx_id;
40 	u_int transaction_id;
41 	u_int header_address;
42 	u_char seq_id;
43 	u_char reserved;
44 	u_short header_length;
45 	u_int edb_address;
46 	} OUTB_SEST_ENTRY;
47 
48 typedef struct {
49 	u_short d_naa;
50 	u_short dest_high;
51 	u_int dest_low;
52 	u_short s_naa;
53 	u_short source_high;
54 	u_int source_low;
55 	} NW_HEADER;
56 
57 typedef struct {
58 	u_int resv;
59 	u_char sof_and_eof;
60 	u_char dest_alpa;
61 	u_short lcr_and_time_stamp;
62 	u_int r_ctl_and_d_id;
63 	u_int vc_id_and_s_id;
64 	u_int type_and_f_cntl;
65 	u_char seq_id;
66 	u_char df_cntl;
67 	u_short seq_cnt;
68 	u_short ox_id;
69 	u_short rx_id;
70 	u_int ro;
71 	NW_HEADER nw_header;
72 	} TACHYON_HEADER;
73 
74 typedef struct {
75 	u_short service_options;
76 	u_short initiator_ctl;
77 	u_short recipient_ctl;
78 	u_short recv_data_field_size;
79 	u_short concurrent_sequences;
80 	u_short n_port_end_to_end_credit;
81 	u_short open_seq_per_exchange;
82 	u_short resv;
83 	}CLASS_OF_SERVICE;
84 
85 typedef struct {
86 	u_int logo_cmnd;
87 	u_char reserved;
88 	u_char n_port_id_2;
89 	u_char n_port_id_1;
90 	u_char n_port_id_0;
91 	u_int port_name_up;
92 	u_int port_name_low;
93 	} LOGO;
94 
95 typedef struct {
96 	u_int ls_cmnd_code;
97 	u_int hard_address;
98 	u_int port_name_high;
99 	u_int port_name_low;
100 	u_int node_name_high;
101 	u_int node_name_low;
102 	u_int n_port_id;
103 	} ADISC;
104 
105 typedef struct {
106 	u_int cmnd_code;
107 	u_int reason_code;
108 	} LS_RJT;
109 
110 typedef struct {
111 	u_int cmnd_code;
112 	} ACC;
113 
114 typedef struct  {
115 	u_int seq_d_id;
116 	u_int tot_len;
117 	u_short cntl;
118 	u_short rx_id;
119 	u_short cs_enable;
120 	u_short cs_seed;
121 	u_int trans_id;
122 	u_int hdr_addr;
123 	u_short frame_len;
124 	u_short hdr_len;
125 	u_int edb_addr;
126 	}ODB;
127 
128 typedef struct {
129 	u_int cmnd_code;
130 	u_int reg_function; /* in the last byte */
131 	} SCR;
132 
133 typedef struct {
134 	u_int rev_in_id;
135 	u_char fs_type;
136 	u_char fs_subtype;
137 	u_char options;
138 	u_char resv1;
139 	u_short cmnd_resp_code;
140 	u_short max_res_size;
141 	u_char resv2;
142 	u_char reason_code;
143 	u_char expln_code;
144 	u_char vendor_unique;
145 	} CT_HDR;
146 
147 typedef struct {
148 	CT_HDR	 ct_hdr;
149 	u_int s_id;
150 	u_char bit_map[32]; /* 32 byte bit map */
151 	} RFC_4;
152 
153 typedef struct {
154 	u_int ls_cmnd_code;
155 	u_short fc_ph_version;
156 	u_short buff_to_buff_credit;
157 	u_short common_features;
158 	u_short recv_data_field_size;
159 	u_short n_port_total_conc_seq;
160 	u_short rel_off_by_info_cat;
161 	u_int ED_TOV;
162 	u_int n_port_name_high;
163 	u_int n_port_name_low;
164 	u_int node_name_high;
165 	u_int node_name_low;
166 	CLASS_OF_SERVICE c_of_s[3];
167 	u_int resv[4];
168 	u_int vendor_version_level[4];
169 	}LOGIN;
170 
171 typedef struct {
172 	CT_HDR	 ct_hdr;
173 	u_int port_type; /* in the first byte */
174 	} GP_ID4;
175 
176 typedef struct  {
177 	u_int   buf_addr;
178 	u_short ehf;
179 	u_short buf_len;
180 	}EDB;
181 
182 /* (i)chip Registers */
183 struct i_chip_regs {
184 	u_int	ptr_ichip_hw_control_reg;
185 	u_int	ptr_ichip_hw_status_reg;
186 	u_int	ptr_ichip_hw_addr_mask_reg;
187 };
188 
189 struct iph5526_novram {
190 	u_int	ptr_novram_hw_control_reg;
191 	u_int	ptr_novram_hw_status_reg;
192 	u_short data[IPH5526_NOVRAM_SIZE];
193 };
194 
195 /* Tachyon Registers */
196 struct tachyon_regs {
197 	u_int    ptr_ocq_base_reg;
198 	u_int    ptr_ocq_len_reg;
199 	u_int    ptr_ocq_prod_indx_reg;
200 	u_int    ptr_ocq_cons_indx_reg;
201 
202 	u_int    ptr_imq_base_reg;
203 	u_int    ptr_imq_len_reg;
204 	u_int    ptr_imq_cons_indx_reg;
205 	u_int    ptr_imq_prod_indx_reg;
206 
207 	u_int    ptr_mfsbq_base_reg;
208 	u_int    ptr_mfsbq_len_reg;
209 	u_int    ptr_mfsbq_prod_reg;
210 	u_int    ptr_mfsbq_cons_reg;
211 	u_int    ptr_mfsbuff_len_reg;
212 
213 	u_int    ptr_sfsbq_base_reg;
214 	u_int    ptr_sfsbq_len_reg;
215 	u_int    ptr_sfsbq_prod_reg;
216 	u_int    ptr_sfsbq_cons_reg;
217 	u_int    ptr_sfsbuff_len_reg;
218 
219 	u_int    ptr_sest_base_reg;
220 	u_int    ptr_sest_len_reg;
221 	u_int    ptr_scsibuff_len_reg;
222 
223 	u_int    ptr_tach_config_reg;
224 	u_int    ptr_tach_control_reg;
225 	u_int    ptr_tach_status_reg;
226 	u_int    ptr_tach_flush_oxid_reg;
227 
228 	u_int    ptr_fm_config_reg;
229 	u_int    ptr_fm_control_reg;
230 	u_int    ptr_fm_status_reg;
231 	u_int    ptr_fm_tov_reg;
232 	u_int    ptr_fm_wwn_hi_reg;
233 	u_int    ptr_fm_wwn_low_reg;
234 	u_int    ptr_fm_rx_al_pa_reg;
235 };
236 
237 struct globals {
238 	u_long tachyon_base;
239 	u_int *mem_base;
240 	u_short ox_id; /* OX_ID used for IP and ELS frames */
241 	u_short scsi_oxid; /* OX_ID for SEST entry */
242 	u_char seq_id;
243 	u_int my_id;
244 	u_int my_ddaa; /* my domain and area in a fabric */
245 	volatile u_char loop_up;
246 	volatile u_char ptp_up; /* we have a point-to-point link */
247 	volatile u_char link_up;
248 	volatile u_char n_port_try;
249 	volatile u_char nport_timer_set;
250 	volatile u_char lport_timer_set;
251 	/* Hmmm... We dont want to Initialize while closing */
252 	u_char dont_init;
253 	u_int my_node_name_high;
254 	u_int my_node_name_low;
255 	u_int my_port_name_high;
256 	u_int my_port_name_low;
257 	u_char fabric_present;
258 	u_char explore_fabric;
259 	u_char name_server;
260 	u_int my_mtu;
261 	u_int *els_buffer[MAX_PENDING_FRAMES]; /* temp space for ELS frames */
262 	char *arp_buffer; /* temp space for ARP frames */
263 	u_int mfs_buffer_count; /* keep track of MFS buffers used*/
264 	u_char scsi_registered;
265 	/* variables for port discovery */
266 	volatile u_char port_discovery;
267 	volatile u_char perform_adisc;
268 	u_short alpa_list_index;
269 	u_short type_of_frame; /* Could be IP/SCSI Read/SCSI Write*/
270 	u_char no_of_targets; /* used to assign target_ids */
271 	u_long sem; /* to synchronize between IP and SCSI */
272 	u_char e_i;
273 
274 	/* the frames */
275 	TACHYON_HEADER tach_header;
276 	LOGIN login;
277 	PRLI prli;
278 	LOGO logo;
279 	ADISC adisc;
280 	LS_RJT ls_rjt;
281 	ODB	odb;
282 	INB_SEST_ENTRY inb_sest_entry;
283 	OUTB_SEST_ENTRY outb_sest_entry;
284 	ACC	acc;
285 	SCR	scr;
286 	EDB	edb;
287 	RFC_4 rfc_4;
288 	GP_ID4 gp_id4;
289 };
290 
291 struct queue_variables {
292 	/* Indices maintained in host memory.
293 	 */
294 	u_int *host_ocq_cons_indx, *host_hpcq_cons_indx, *host_imq_prod_indx;
295 	u_int *ptr_host_ocq_cons_indx, *ptr_host_hpcq_cons_indx, *ptr_host_imq_prod_indx;
296 
297 	/* Variables for Outbound Command Queue (OCQ).
298 	 */
299 	u_int *ptr_ocq_base;
300 	u_int ocq_len, ocq_end;
301 	u_int ocq_prod_indx;
302 	u_int *ptr_odb[OCQ_LENGTH];
303 
304 	/* Variables for Inbound Message Queue (IMQ).
305 	 */
306 	u_int *ptr_imq_base;
307 	u_int imq_len, imq_end;
308 	u_int imq_cons_indx;
309 	u_int imq_prod_indx;
310 	u_int *ptr_imqe[IMQ_LENGTH];
311 
312 	u_int *ptr_mfsbq_base;
313 	u_int mfsbq_len, mfsbq_end;
314 	u_int mfsbq_prod_indx;
315 	u_int mfsbq_cons_indx;
316 	u_int mfsbuff_len, mfsbuff_end;
317 
318 	u_int *ptr_sfsbq_base;
319 	u_int sfsbq_len, sfsbq_end;
320 	u_int sfsbq_prod_indx;
321 	u_int sfsbq_cons_indx;
322 	u_int sfsbuff_len, sfsbuff_end;
323 	u_int *ptr_sfs_buffers[SFSBQ_LENGTH * NO_OF_ENTRIES];
324 
325 	/* Tables for SCSI Transactions */
326 	u_int *ptr_sest_base;
327 	u_int *ptr_sest[SEST_LENGTH];
328 	u_char free_scsi_oxid[SEST_LENGTH];
329 	u_int *ptr_sdb_base;
330 	u_int *ptr_sdb_slot[NO_OF_SDB_ENTRIES];
331 	u_char sdb_slot_status[NO_OF_SDB_ENTRIES];
332 	u_int sdb_indx;
333 	u_int *ptr_fcp_cmnd_base;
334 	u_int *ptr_fcp_cmnd[NO_OF_FCP_CMNDS];
335 	u_int fcp_cmnd_indx;
336 
337 	/* Table for data to be transmitted.
338 	 */
339 	u_int *ptr_edb_base;
340 	u_int *ptr_edb[EDB_LEN];
341 	u_int edb_buffer_indx;
342 	volatile u_char free_edb_list[EDB_LEN];
343 
344 	/* Table of Tachyon Headers.
345 	 */
346 	u_int *ptr_tachyon_header[NO_OF_TACH_HEADERS];
347 	u_int *ptr_tachyon_header_base;
348 	u_int tachyon_header_indx;
349 };
350 
351 /* Used to match incoming ACCs to ELS requests sent out */
352 struct ox_id_els_map {
353 	u_short ox_id;
354 	u_int els;
355 	struct ox_id_els_map *next;
356 };
357 
358 
359 /* Carries info about individual nodes... stores the info got at login
360  * time. Also maintains mapping between MAC->FC addresses
361  */
362 struct fc_node_info {
363 	/* Itz the WWN (8 bytes), the last 6 bytes is the MAC address */
364 	u_char hw_addr[PORT_NAME_LEN];
365 	u_char node_name[NODE_NAME_LEN];
366 	u_int d_id;  /*real FC address, 3 bytes */
367 	int mtu;
368 	/* login = 1 if login attempted
369 	 * login = 2 if login completed
370 	 */
371 	int login;
372 	u_char scsi; /*  = 1 if device is a SCSI Target */
373 	u_char target_id;
374 	CLASS_OF_SERVICE c_of_s[3];
375 	struct fc_node_info *next;
376 };
377 
378 struct fc_info {
379 	char name[8];
380 	u_long base_addr;
381 	int irq;
382 	struct net_device_stats fc_stats;
383 	struct fc_node_info *node_info_list;
384 	int num_nodes;
385 	struct ox_id_els_map *ox_id_list;
386 	struct i_chip_regs i_r;
387 	struct tachyon_regs t_r;
388 	struct queue_variables q;
389 	struct globals g;
390 	struct iph5526_novram n_r;
391 	u_short clone_id;
392 	struct timer_list nport_timer;
393 	struct timer_list lport_timer;
394 	struct timer_list explore_timer;
395 	struct timer_list display_cache_timer;
396 	struct net_device *dev;
397 	struct Scsi_Host *host;
398 	spinlock_t fc_lock;
399 };
400 
401 struct iph5526_hostdata {
402 	struct fc_info *fi;
403 	fcp_cmd cmnd;
404 	Scsi_Cmnd *cmnd_handler[SEST_LENGTH];
405 	u_int tag_ages[MAX_SCSI_TARGETS];
406 };
407 
408 /* List of valid AL_PAs */
409 u_char alpa_list[127] = {
410 	0x00, 0x01, 0x02, 0x04, 0x08, 0x0F, 0x10, 0x17,
411 	0x18, 0x1B, 0x1D, 0x1E, 0x1F, 0x23, 0x25, 0x26,
412 	0x27, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x31,
413 	0x32, 0x33, 0x34, 0x35, 0x36, 0x39, 0x3A, 0x3C,
414 	0x43, 0x45, 0x46, 0x47, 0x49, 0x4A, 0x4B, 0x4C,
415 	0x4D, 0x4E, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56,
416 	0x59, 0x5A, 0x5C, 0x63, 0x65, 0x66, 0x67, 0x69,
417 	0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x71, 0x72, 0x73,
418 	0x74, 0x75, 0x76, 0x79, 0x7A, 0x7C, 0x80, 0x81,
419 	0x82, 0x84, 0x88, 0x8F, 0x90, 0x97, 0x98, 0x9B,
420 	0x9D, 0x9E, 0x9F, 0xA3, 0xA5, 0xA6, 0xA7, 0xA9,
421 	0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xB1, 0xB2, 0xB3,
422 	0xB4, 0xB5, 0xB6, 0xB9, 0xBA, 0xBC, 0xC3, 0xC5,
423 	0xC6, 0xC7, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE,
424 	0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD9, 0xDA,
425 	0xDC, 0xE0, 0xE1, 0xE2, 0xE4, 0xE8, 0xEF
426 };
427 
428 #endif /* _TACH_STRUCT_H */
429