File: /usr/src/linux/drivers/ieee1394/sbp2.h

1     /*
2      * sbp2.h - Defines and prototypes for sbp2.c
3      *
4      * Copyright (C) 2000 James Goodwin, Filanet Corporation (www.filanet.com)
5      * jamesg@filanet.com
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 Foundation,
19      * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20      */
21     
22     #ifndef SBP2_H
23     #define SBP2_H
24     
25     #define SBP2_DEVICE_NAME		"sbp2"
26     #define SBP2_DEVICE_NAME_SIZE		4
27     
28     /*
29      * SBP2 specific structures and defines
30      */
31     
32     #define ORB_FMT_CMD			0x0
33     #define ORB_FMT_DUMMY			0x3
34     
35     #define ORB_DIRECTION_WRITE_TO_MEDIA    0x0
36     #define ORB_DIRECTION_READ_FROM_MEDIA   0x1
37     #define ORB_DIRECTION_NO_DATA_TRANSFER  0x2
38     
39     #define SPEED_S100			0x0
40     #define SPEED_S200			0x1
41     #define SPEED_S400			0x2
42     #define SPEED_S800			0x3
43     #define SPEED_S1600			0x4
44     #define SPEED_S3200			0x5
45     
46     /* 2^(MAX_PAYLOAD+1) = Maximum data transfer length */
47     #define MAX_PAYLOAD_S100		0x7
48     #define MAX_PAYLOAD_S200		0x8
49     #define MAX_PAYLOAD_S400		0x9
50     
51     /* Max rec matches node_entry values */
52     #define MAX_REC_S100			512
53     #define MAX_REC_S200			1024
54     #define MAX_REC_S400			2048
55     
56     #define ORB_SET_NOTIFY(value)                   ((value & 0x1) << 31)
57     #define ORB_SET_RQ_FMT(value)                   ((value & 0x3) << 29)
58     #define ORB_SET_NODE_ID(value)			((value & 0xffff) << 16)
59     
60     struct sbp2_dummy_orb {
61     	volatile u32 next_ORB_hi;
62     	volatile u32 next_ORB_lo;
63     	u32 reserved1;
64             u32 reserved2;
65     	u32 notify_rq_fmt;
66     	u8 command_block[12];
67     };
68     
69     #define ORB_SET_DATA_SIZE(value)                (value & 0xffff)
70     #define ORB_SET_PAGE_SIZE(value)                ((value & 0x7) << 16)
71     #define ORB_SET_PAGE_TABLE_PRESENT(value)       ((value & 0x1) << 19)
72     #define ORB_SET_MAX_PAYLOAD(value)              ((value & 0xf) << 20)
73     #define ORB_SET_SPEED(value)                    ((value & 0x7) << 24)
74     #define ORB_SET_DIRECTION(value)                ((value & 0x1) << 27)
75     
76     struct sbp2_command_orb {
77     	volatile u32 next_ORB_hi;
78     	volatile u32 next_ORB_lo;
79     	u32 data_descriptor_hi;
80     	u32 data_descriptor_lo;
81     	u32 misc;
82     	u8 cdb[12];
83     };
84     
85     #define LOGIN_REQUEST			0x0
86     #define QUERY_LOGINS_REQUEST		0x1
87     #define RECONNECT_REQUEST		0x3
88     #define SET_PASSWORD_REQUEST		0x4
89     #define LOGOUT_REQUEST			0x7
90     #define ABORT_TASK_REQUEST		0xb
91     #define ABORT_TASK_SET			0xc
92     #define LOGICAL_UNIT_RESET		0xe
93     #define TARGET_RESET_REQUEST		0xf
94     
95     #define ORB_SET_LUN(value)                      (value & 0xffff)
96     #define ORB_SET_FUNCTION(value)                 ((value & 0xf) << 16)
97     #define ORB_SET_RECONNECT(value)                ((value & 0xf) << 20)
98     #define ORB_SET_EXCLUSIVE(value)                ((value & 0x1) << 28)
99     #define ORB_SET_LOGIN_RESP_LENGTH(value)        (value & 0xffff)
100     #define ORB_SET_PASSWD_LENGTH(value)            ((value & 0xffff) << 16)
101     
102     struct sbp2_login_orb {
103     	u32 password_hi;
104     	u32 password_lo;
105     	u32 login_response_hi;
106     	u32 login_response_lo;
107     	u32 lun_misc;
108     	u32 passwd_resp_lengths;
109     	u32 status_FIFO_hi;
110     	u32 status_FIFO_lo;
111     };
112     
113     #define RESPONSE_GET_LOGIN_ID(value)            (value & 0xffff)
114     #define RESPONSE_GET_LENGTH(value)              ((value >> 16) & 0xffff)
115     #define RESPONSE_GET_RECONNECT_HOLD(value)      (value & 0xffff)
116     
117     struct sbp2_login_response {
118     	u32 length_login_ID;
119     	u32 command_block_agent_hi;
120     	u32 command_block_agent_lo;
121     	u32 reconnect_hold;
122     };
123     
124     #define ORB_SET_LOGIN_ID(value)                 (value & 0xffff)
125     
126     struct sbp2_reconnect_orb {
127     	u32 reserved1;
128     	u32 reserved2;
129             u32 reserved3;
130             u32 reserved4;
131     	u32 login_ID_misc;
132     	u32 reserved5;
133     	u32 status_FIFO_hi;
134     	u32 status_FIFO_lo;
135     };
136     
137     struct sbp2_logout_orb {
138     	u32 reserved1;
139     	u32 reserved2;
140             u32 reserved3;
141             u32 reserved4;
142     	u32 login_ID_misc;
143     	u32 reserved5;
144     	u32 status_FIFO_hi;
145     	u32 status_FIFO_lo;
146     };
147     
148     #define PAGE_TABLE_SET_SEGMENT_BASE_HI(value)   (value & 0xffff)
149     #define PAGE_TABLE_SET_SEGMENT_LENGTH(value)    ((value & 0xffff) << 16)
150     
151     struct sbp2_unrestricted_page_table {
152     	u32 length_segment_base_hi;
153     	u32 segment_base_lo;
154     };
155     
156     #define RESP_STATUS_REQUEST_COMPLETE		0x0
157     #define RESP_STATUS_TRANSPORT_FAILURE		0x1
158     #define RESP_STATUS_ILLEGAL_REQUEST		0x2
159     #define RESP_STATUS_VENDOR_DEPENDENT		0x3
160     
161     #define SBP2_STATUS_NO_ADDITIONAL_INFO		0x0
162     #define SBP2_STATUS_REQ_TYPE_NOT_SUPPORTED	0x1
163     #define SBP2_STATUS_SPEED_NOT_SUPPORTED		0x2
164     #define SBP2_STATUS_PAGE_SIZE_NOT_SUPPORTED	0x3
165     #define SBP2_STATUS_ACCESS_DENIED		0x4
166     #define SBP2_STATUS_LU_NOT_SUPPORTED		0x5
167     #define SBP2_STATUS_MAX_PAYLOAD_TOO_SMALL	0x6
168     #define SBP2_STATUS_RESOURCES_UNAVAILABLE	0x8
169     #define SBP2_STATUS_FUNCTION_REJECTED		0x9
170     #define SBP2_STATUS_LOGIN_ID_NOT_RECOGNIZED	0xa
171     #define SBP2_STATUS_DUMMY_ORB_COMPLETED		0xb
172     #define SBP2_STATUS_REQUEST_ABORTED		0xc
173     #define SBP2_STATUS_UNSPECIFIED_ERROR		0xff
174     
175     #define SFMT_CURRENT_ERROR			0x0
176     #define SFMT_DEFERRED_ERROR			0x1
177     #define SFMT_VENDOR_DEPENDENT_STATUS		0x3
178     
179     #define SBP2_SCSI_STATUS_GOOD			0x0
180     #define SBP2_SCSI_STATUS_CHECK_CONDITION	0x2
181     #define SBP2_SCSI_STATUS_CONDITION_MET		0x4
182     #define SBP2_SCSI_STATUS_BUSY			0x8
183     #define SBP2_SCSI_STATUS_RESERVATION_CONFLICT	0x18
184     #define SBP2_SCSI_STATUS_COMMAND_TERMINATED	0x22
185     
186     #define SBP2_SCSI_STATUS_SELECTION_TIMEOUT	0xff
187     
188     #define STATUS_GET_ORB_OFFSET_HI(value)         (value & 0xffff)
189     #define STATUS_GET_SBP_STATUS(value)            ((value >> 16) & 0xff)
190     #define STATUS_GET_LENGTH(value)                ((value >> 24) & 0x7)
191     #define STATUS_GET_DEAD_BIT(value)              ((value >> 27) & 0x1)
192     #define STATUS_GET_RESP(value)                  ((value >> 28) & 0x3)
193     #define STATUS_GET_SRC(value)                   ((value >> 30) & 0x3)
194     
195     struct sbp2_status_block {
196     	u32 ORB_offset_hi_misc;
197     	u32 ORB_offset_lo;
198             u8 command_set_dependent[24];
199     };
200     
201     /*
202      * Miscellaneous SBP2 related config rom defines
203      */
204     
205     #define SBP2_STATUS_FIFO_ADDRESS				0xfffe00000000ULL     /* for write posting! */
206     #define SBP2_STATUS_FIFO_ADDRESS_HI                             0xfffe
207     #define SBP2_STATUS_FIFO_ADDRESS_LO                             0x0
208     
209     #define SBP2_UNIT_DIRECTORY_OFFSET_KEY				0xd1
210     #define SBP2_CSR_OFFSET_KEY					0x54
211     #define SBP2_UNIT_SPEC_ID_KEY					0x12
212     #define SBP2_UNIT_SW_VERSION_KEY				0x13
213     #define SBP2_COMMAND_SET_SPEC_ID_KEY				0x38
214     #define SBP2_COMMAND_SET_KEY					0x39
215     #define SBP2_UNIT_CHARACTERISTICS_KEY				0x3a
216     #define SBP2_DEVICE_TYPE_AND_LUN_KEY				0x14
217     #define SBP2_FIRMWARE_REVISION_KEY				0x3c
218     
219     #define SBP2_AGENT_STATE_OFFSET					0x00ULL
220     #define SBP2_AGENT_RESET_OFFSET					0x04ULL
221     #define SBP2_ORB_POINTER_OFFSET					0x08ULL
222     #define SBP2_DOORBELL_OFFSET					0x10ULL
223     #define SBP2_UNSOLICITED_STATUS_ENABLE_OFFSET			0x14ULL
224     #define SBP2_UNSOLICITED_STATUS_VALUE				0xf
225     
226     #define SBP2_BUSY_TIMEOUT_ADDRESS				0xfffff0000210ULL
227     #define SBP2_BUSY_TIMEOUT_VALUE					0xf
228     
229     #define SBP2_AGENT_RESET_DATA					0xf
230     
231     /*
232      * Unit spec id and sw version entry for SBP-2 devices
233      */
234     
235     #define SBP2_UNIT_SPEC_ID_ENTRY					0x1200609e
236     #define SBP2_SW_VERSION_ENTRY					0x13010483
237     
238     /*
239      * Miscellaneous general config rom related defines
240      */
241     
242     #define CONFIG_ROM_INITIAL_MEMORY_SPACE 			0xfffff0000000ULL
243     
244     #define CONFIG_ROM_BASE_ADDRESS					0xfffff0000400ULL
245     #define CONFIG_ROM_ROOT_DIR_BASE				0xfffff0000414ULL
246     #define CONFIG_ROM_SIGNATURE_ADDRESS				0xfffff0000404ULL
247     #define CONFIG_ROM_UNIT_DIRECTORY_OFFSET			0xfffff0000424ULL
248     
249     #define IEEE1394_CONFIG_ROM_SIGNATURE				0x31333934
250     
251     #define SBP2_128KB_BROKEN_FIRMWARE				0xa0b800
252     #define SBP2_BROKEN_FIRMWARE_MAX_TRANSFER			0x20000
253     
254     /*
255      * Flags for SBP-2 functions
256      */
257     #define SBP2_SEND_NO_WAIT					0x00000001
258     
259     /*
260      * SCSI specific stuff
261      */
262     
263     #define SBP2_MAX_SG_ELEMENTS		SG_ALL
264     #define SBP2_CLUSTERING			ENABLE_CLUSTERING
265     #define SBP2_MAX_SG_ELEMENT_LENGTH	0xf000
266     #define SBP2SCSI_MAX_SCSI_IDS		8
267     #define SBP2SCSI_MAX_OUTSTANDING_CMDS	8	/* Max total outstanding sbp2 commands allowed at a time! */
268     #define SBP2SCSI_MAX_CMDS_PER_LUN	4 	/* Max outstanding sbp2 commands per device - tune as needed */
269     
270     #ifndef TYPE_SDAD
271     #define TYPE_SDAD			0x0e	/* simplified direct access device */
272     #endif
273     
274     /*
275      * SCSI direction table... since the scsi stack doesn't specify direction...   =(
276      *
277      * DIN = IN data direction
278      * DOU = OUT data direction
279      * DNO = No data transfer
280      * DUN = Unknown data direction
281      */
282     #define DIN				ORB_DIRECTION_READ_FROM_MEDIA
283     #define DOU				ORB_DIRECTION_WRITE_TO_MEDIA
284     #define DNO				ORB_DIRECTION_NO_DATA_TRANSFER
285     #define DUN				DIN 
286     
287     static unchar sbp2scsi_direction_table[0x100] = {
288     	DNO,DNO,DIN,DIN,DOU,DIN,DIN,DOU,DIN,DUN,DOU,DOU,DUN,DUN,DUN,DIN,
289     	DNO,DIN,DIN,DOU,DIN,DOU,DNO,DNO,DOU,DNO,DIN,DNO,DIN,DOU,DNO,DUN,
290     	DIN,DUN,DIN,DIN,DOU,DIN,DUN,DUN,DIN,DIN,DOU,DNO,DUN,DIN,DOU,DOU,
291     	DOU,DOU,DOU,DNO,DIN,DNO,DNO,DIN,DOU,DOU,DOU,DOU,DIN,DOU,DIN,DOU,
292     	DOU,DOU,DIN,DIN,DIN,DNO,DIN,DNO,DNO,DNO,DUN,DNO,DOU,DIN,DNO,DUN,
293     	DUN,DIN,DIN,DNO,DOU,DOU,DUN,DUN,DNO,DIN,DIN,DNO,DIN,DOU,DUN,DUN,
294     	DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
295     	DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
296     	DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
297     	DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
298     	DUN,DNO,DOU,DOU,DIN,DNO,DNO,DNO,DIN,DNO,DOU,DUN,DNO,DIN,DOU,DOU,
299     	DOU,DOU,DOU,DNO,DUN,DIN,DOU,DIN,DIN,DIN,DNO,DNO,DNO,DIN,DIN,DUN,
300     	DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
301     	DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
302     	DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DOU,DUN,DUN,DUN,DUN,DUN,
303     	DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN
304     };
305     
306     
307     /*
308      * Number of request packets available for actual sbp2 I/O requests (these are used
309      * for sending command and agent reset packets).
310      */
311     #define SBP2_MAX_REQUEST_PACKETS	SBP2SCSI_MAX_OUTSTANDING_CMDS	/* Per host adapter instance */
312     #define SBP2_MAX_COMMAND_ORBS		SBP2SCSI_MAX_CMDS_PER_LUN * 2	/* Per sbp2 device instance */
313     
314     /*
315      * Request packets structure (used for sending command and agent reset packets)
316      */
317     struct sbp2_request_packet {
318     
319     	struct list_head list;
320     	struct hpsb_packet *packet;
321     	struct tq_struct tq;
322     	void *hi_context;
323     
324     };
325     
326     /* 
327      * Encapsulates all the info necessary for an outstanding command. 
328      */
329     struct sbp2_command_info {
330     
331     	struct list_head list;
332     	struct sbp2_command_orb command_orb;
333     	dma_addr_t command_orb_dma;
334     	Scsi_Cmnd *Current_SCpnt;
335     	void (*Current_done)(Scsi_Cmnd *);
336     	unsigned int linked;
337     
338     	/* Also need s/g structure for each sbp2 command */
339     	struct sbp2_unrestricted_page_table scatter_gather_element[SBP2_MAX_SG_ELEMENTS];
340     	dma_addr_t sge_dma;
341     	void *sge_buffer;
342     	dma_addr_t cmd_dma;
343     	int dma_type;
344     	unsigned long dma_size;
345     	int dma_dir;
346     
347     };
348     
349     /*
350      * Information needed on a per scsi id basis (one for each sbp2 device)
351      */
352     struct scsi_id_instance_data {
353     
354     	/*
355     	 * Various sbp2 specific structures
356     	 */
357     	struct sbp2_command_orb *last_orb;
358     	struct sbp2_login_orb *login_orb;
359     	dma_addr_t login_orb_dma;
360     	struct sbp2_login_response *login_response;
361     	dma_addr_t login_response_dma;
362     	struct sbp2_reconnect_orb *reconnect_orb;
363     	dma_addr_t reconnect_orb_dma;
364     	struct sbp2_logout_orb *logout_orb;
365     	dma_addr_t logout_orb_dma;
366     	struct sbp2_status_block status_block;
367     
368     	/*
369     	 * Stuff we need to know about the sbp2 device itself
370     	 */
371     	u64 node_unique_id;
372     	u64 sbp2_management_agent_addr;
373     	u64 sbp2_command_block_agent_addr;
374     	u32 node_id;
375     	u32 speed_code;
376     	u32 max_payload_size;
377     
378     	/*
379     	 * Values pulled from the device's unit directory
380     	 */
381     	u32 sbp2_unit_spec_id;
382     	u32 sbp2_unit_sw_version;
383     	u32 sbp2_command_set_spec_id;
384     	u32 sbp2_command_set;
385     	u32 sbp2_unit_characteristics;
386     	u32 sbp2_device_type_and_lun;
387     	u32 sbp2_firmware_revision;
388     
389     	/* 
390     	 * Wait queue used for logins, reconnects, logouts 
391     	 */
392     	wait_queue_head_t sbp2_login_wait;
393     
394     	/*
395     	 * Flag noting whether the sbp2 device is currently validated (for use during
396     	 * bus resets).
397     	 */
398     	u32 validated;
399     
400     	/* 
401     	 * Pool of command orbs, so we can have more than overlapped command per id
402     	 */
403     	spinlock_t sbp2_command_orb_lock;
404     	struct list_head sbp2_command_orb_inuse;
405     	struct list_head sbp2_command_orb_completed;
406     	u32 sbp2_total_command_orbs;
407     
408     };
409     
410     /*
411      * Sbp2 host data structure (one per sbp2 host)
412      */
413     struct sbp2scsi_host_info {
414     
415     	/*
416     	 * For use in keeping track of hosts
417     	 */
418     	struct list_head list;
419     	struct hpsb_host *host;
420     
421     	/*
422     	 * Spin locks for command processing and packet pool management
423     	 */
424     	spinlock_t sbp2_command_lock;
425     	spinlock_t sbp2_request_packet_lock;
426     
427     	/*
428     	 * Flag indicating if a bus reset (or device detection) is in progress
429     	 */
430     	u32 bus_reset_in_progress;
431     
432     	/*
433     	 * We currently use a kernel thread for dealing with bus resets and sbp2
434     	 * device detection. We use this to wake up the thread when needed.
435     	 */
436     	wait_queue_head_t sbp2_detection_wait;
437     
438     	/* 
439     	 * PID of sbp2 detection kernel thread 
440     	 */
441     	int sbp2_detection_pid;
442     
443     	/*
444     	 * Lists keeping track of inuse/free sbp2_request_packets. These structures are
445     	 * used for sending out sbp2 command and agent reset packets. We initially create
446     	 * a pool of request packets so that we don't have to do any kmallocs while in critical
447     	 * I/O paths.
448     	 */
449     	struct list_head sbp2_req_inuse;
450     	struct list_head sbp2_req_free;
451     
452     	/*
453     	 * Stuff to keep track of the initial scsi bus scan (so that we don't miss it)
454     	 */
455     	u32 initial_scsi_bus_scan_complete;
456     	Scsi_Cmnd *bus_scan_SCpnt;
457     	void (*bus_scan_done)(Scsi_Cmnd *);
458     
459     	/*
460     	 * Here is the pool of request packets. All the hpsb packets (for 1394 bus transactions)
461     	 * are allocated at init and simply re-initialized when needed.
462     	 */
463     	struct sbp2_request_packet request_packet[SBP2_MAX_REQUEST_PACKETS];
464     
465     	/*
466     	 * SCSI ID instance data (one for each sbp2 device instance possible)
467     	 */
468     	struct scsi_id_instance_data *scsi_id[SBP2SCSI_MAX_SCSI_IDS];
469     
470     };
471     
472     /*
473      * Function prototypes
474      */
475     
476     /*
477      * Various utility prototypes
478      */
479     static int sbp2util_read_quadlet(struct sbp2scsi_host_info *hi, nodeid_t node, u64 addr,
480     				 quadlet_t *buffer);
481     static int sbp2util_unit_directory(struct sbp2scsi_host_info *hi, nodeid_t node, u64 *addr);
482     static int sbp2util_create_request_packet_pool(struct sbp2scsi_host_info *hi);
483     static void sbp2util_remove_request_packet_pool(struct sbp2scsi_host_info *hi);
484     static struct sbp2_request_packet *sbp2util_allocate_write_request_packet(struct sbp2scsi_host_info *hi,
485     									  nodeid_t node, u64 addr,
486     									  size_t data_size,
487     									  quadlet_t data);
488     static void sbp2util_free_request_packet(struct sbp2_request_packet *request_packet);
489     static int sbp2util_create_command_orb_pool(struct scsi_id_instance_data *scsi_id, struct sbp2scsi_host_info *hi);
490     static void sbp2util_remove_command_orb_pool(struct scsi_id_instance_data *scsi_id, struct sbp2scsi_host_info *hi);
491     static struct sbp2_command_info *sbp2util_find_command_for_orb(struct scsi_id_instance_data *scsi_id, dma_addr_t orb);
492     static struct sbp2_command_info *sbp2util_find_command_for_SCpnt(struct scsi_id_instance_data *scsi_id, void *SCpnt);
493     static struct sbp2_command_info *sbp2util_allocate_command_orb(struct scsi_id_instance_data *scsi_id, 
494     							  Scsi_Cmnd *Current_SCpnt, 
495     							  void (*Current_done)(Scsi_Cmnd *),
496     							  struct sbp2scsi_host_info *hi);
497     static void sbp2util_mark_command_completed(struct scsi_id_instance_data *scsi_id,
498     		struct sbp2_command_info *command);
499     
500     /*
501      * IEEE-1394 core driver related prototypes
502      */
503     static void sbp2_remove_unvalidated_devices(struct sbp2scsi_host_info *hi);
504     static int sbp2_start_device(struct sbp2scsi_host_info *hi, int node_id);
505     static int sbp2_check_device(struct sbp2scsi_host_info *hi, int node_id);
506     static void sbp2_bus_reset_handler(void *context);
507     static void sbp2_add_host(struct hpsb_host *host);
508     static struct sbp2scsi_host_info *sbp2_find_host_info(struct hpsb_host *host);
509     static void sbp2_remove_host(struct hpsb_host *host);
510     static void sbp2_host_reset(struct hpsb_host *host);
511     static int sbp2_detection_thread(void *__sbp2);
512     int sbp2_init(void);
513     void sbp2_cleanup(void);
514     #if 0
515     static int sbp2_handle_physdma_write(struct hpsb_host *host, int nodeid, quadlet_t *data,
516     				     u64 addr, unsigned int length);
517     static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid, quadlet_t *data,
518     				    u64 addr, unsigned int length);
519     #endif
520     /*
521      * SBP-2 protocol related prototypes
522      */
523     static int sbp2_login_device(struct sbp2scsi_host_info *hi, struct scsi_id_instance_data *scsi_id);
524     static int sbp2_reconnect_device(struct sbp2scsi_host_info *hi, struct scsi_id_instance_data *scsi_id); 
525     static int sbp2_logout_device(struct sbp2scsi_host_info *hi, struct scsi_id_instance_data *scsi_id); 
526     static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int destid,
527     				    quadlet_t *data, u64 addr, unsigned int length);
528     static int sbp2_agent_reset(struct sbp2scsi_host_info *hi, struct scsi_id_instance_data *scsi_id, u32 flags);
529     static int sbp2_create_command_orb(struct sbp2scsi_host_info *hi, 
530     				   struct scsi_id_instance_data *scsi_id,
531     				   struct sbp2_command_info *command,
532     				   unchar *scsi_cmd,
533     				   unsigned int scsi_use_sg,
534     				   unsigned int scsi_request_bufflen,
535     				   void *scsi_request_buffer, int dma_dir);
536     static int sbp2_link_orb_command(struct sbp2scsi_host_info *hi, struct scsi_id_instance_data *scsi_id,
537     				 struct sbp2_command_info *command);
538     static int sbp2_send_command(struct sbp2scsi_host_info *hi, struct scsi_id_instance_data *scsi_id,
539     			     Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *));
540     static int sbp2_send_split_command(struct sbp2scsi_host_info *hi, struct scsi_id_instance_data *scsi_id,
541     				   Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *));
542     static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense_data);
543     static void sbp2_check_sbp2_command(unchar *cmd);
544     static void sbp2_check_sbp2_response(struct sbp2scsi_host_info *hi, struct scsi_id_instance_data *scsi_id, 
545     				     Scsi_Cmnd *SCpnt);
546     static int sbp2_parse_unit_directory(struct sbp2scsi_host_info *hi, struct scsi_id_instance_data *scsi_id);
547     static int sbp2_set_busy_timeout(struct sbp2scsi_host_info *hi, struct scsi_id_instance_data *scsi_id);
548     static int sbp2_max_speed_and_size(struct sbp2scsi_host_info *hi, struct scsi_id_instance_data *scsi_id);
549     
550     /*
551      * Scsi interface related prototypes
552      */
553     static const char *sbp2scsi_info (struct Scsi_Host *host);
554     static int sbp2scsi_detect (Scsi_Host_Template *tpnt);
555     void sbp2scsi_setup(char *str, int *ints);
556     static int sbp2scsi_biosparam (Scsi_Disk *disk, kdev_t dev, int geom[]);
557     static int sbp2scsi_abort (Scsi_Cmnd *SCpnt); 
558     static int sbp2scsi_reset (Scsi_Cmnd *SCpnt, unsigned int reset_flags); 
559     static int sbp2scsi_queuecommand (Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *));
560     static void sbp2scsi_complete_all_commands(struct sbp2scsi_host_info *hi, struct scsi_id_instance_data *scsi_id, 
561     					   u32 status);
562     static void sbp2scsi_complete_command(struct sbp2scsi_host_info *hi, struct scsi_id_instance_data *scsi_id, 
563     				      u32 scsi_status, Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *));
564     static void sbp2scsi_register_scsi_host(struct sbp2scsi_host_info *hi);
565     
566     #endif /* SBP2_H */
567