diff options
-rw-r--r-- | drivers/ieee1394/sbp2.c | 145 | ||||
-rw-r--r-- | drivers/ieee1394/sbp2.h | 45 |
2 files changed, 86 insertions, 104 deletions
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index becd98d411ec..f1f5de616d79 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c | |||
@@ -180,19 +180,6 @@ MODULE_PARM_DESC(workarounds, "Work around device bugs (default = 0" | |||
180 | ", or a combination)"); | 180 | ", or a combination)"); |
181 | 181 | ||
182 | /* | 182 | /* |
183 | * Export information about protocols/devices supported by this driver. | ||
184 | */ | ||
185 | static struct ieee1394_device_id sbp2_id_table[] = { | ||
186 | { | ||
187 | .match_flags = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, | ||
188 | .specifier_id = SBP2_UNIT_SPEC_ID_ENTRY & 0xffffff, | ||
189 | .version = SBP2_SW_VERSION_ENTRY & 0xffffff}, | ||
190 | {} | ||
191 | }; | ||
192 | |||
193 | MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table); | ||
194 | |||
195 | /* | ||
196 | * Debug levels, configured via kernel config, or enable here. | 183 | * Debug levels, configured via kernel config, or enable here. |
197 | */ | 184 | */ |
198 | 185 | ||
@@ -250,40 +237,66 @@ static u32 global_outstanding_dmas = 0; | |||
250 | /* | 237 | /* |
251 | * Globals | 238 | * Globals |
252 | */ | 239 | */ |
240 | static void sbp2scsi_complete_all_commands(struct scsi_id_instance_data *, u32); | ||
241 | static void sbp2scsi_complete_command(struct scsi_id_instance_data *, u32, | ||
242 | struct scsi_cmnd *, | ||
243 | void (*)(struct scsi_cmnd *)); | ||
244 | static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *); | ||
245 | static int sbp2_start_device(struct scsi_id_instance_data *); | ||
246 | static void sbp2_remove_device(struct scsi_id_instance_data *); | ||
247 | static int sbp2_login_device(struct scsi_id_instance_data *); | ||
248 | static int sbp2_reconnect_device(struct scsi_id_instance_data *); | ||
249 | static int sbp2_logout_device(struct scsi_id_instance_data *); | ||
250 | static void sbp2_host_reset(struct hpsb_host *); | ||
251 | static int sbp2_handle_status_write(struct hpsb_host *, int, int, quadlet_t *, | ||
252 | u64, size_t, u16); | ||
253 | static int sbp2_agent_reset(struct scsi_id_instance_data *, int); | ||
254 | static void sbp2_parse_unit_directory(struct scsi_id_instance_data *, | ||
255 | struct unit_directory *); | ||
256 | static int sbp2_set_busy_timeout(struct scsi_id_instance_data *); | ||
257 | static int sbp2_max_speed_and_size(struct scsi_id_instance_data *); | ||
253 | 258 | ||
254 | static void sbp2scsi_complete_all_commands(struct scsi_id_instance_data *scsi_id, | ||
255 | u32 status); | ||
256 | |||
257 | static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id, | ||
258 | u32 scsi_status, struct scsi_cmnd *SCpnt, | ||
259 | void (*done)(struct scsi_cmnd *)); | ||
260 | |||
261 | static struct scsi_host_template scsi_driver_template; | ||
262 | 259 | ||
263 | static const u8 sbp2_speedto_max_payload[] = { 0x7, 0x8, 0x9, 0xA, 0xB, 0xC }; | 260 | static const u8 sbp2_speedto_max_payload[] = { 0x7, 0x8, 0x9, 0xA, 0xB, 0xC }; |
264 | 261 | ||
265 | static void sbp2_host_reset(struct hpsb_host *host); | ||
266 | |||
267 | static int sbp2_probe(struct device *dev); | ||
268 | static int sbp2_remove(struct device *dev); | ||
269 | static int sbp2_update(struct unit_directory *ud); | ||
270 | |||
271 | static struct hpsb_highlevel sbp2_highlevel = { | 262 | static struct hpsb_highlevel sbp2_highlevel = { |
272 | .name = SBP2_DEVICE_NAME, | 263 | .name = SBP2_DEVICE_NAME, |
273 | .host_reset = sbp2_host_reset, | 264 | .host_reset = sbp2_host_reset, |
274 | }; | 265 | }; |
275 | 266 | ||
276 | static struct hpsb_address_ops sbp2_ops = { | 267 | static struct hpsb_address_ops sbp2_ops = { |
277 | .write = sbp2_handle_status_write | 268 | .write = sbp2_handle_status_write |
278 | }; | 269 | }; |
279 | 270 | ||
280 | #ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA | 271 | #ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA |
272 | static int sbp2_handle_physdma_write(struct hpsb_host *, int, int, quadlet_t *, | ||
273 | u64, size_t, u16); | ||
274 | static int sbp2_handle_physdma_read(struct hpsb_host *, int, quadlet_t *, u64, | ||
275 | size_t, u16); | ||
276 | |||
281 | static struct hpsb_address_ops sbp2_physdma_ops = { | 277 | static struct hpsb_address_ops sbp2_physdma_ops = { |
282 | .read = sbp2_handle_physdma_read, | 278 | .read = sbp2_handle_physdma_read, |
283 | .write = sbp2_handle_physdma_write, | 279 | .write = sbp2_handle_physdma_write, |
284 | }; | 280 | }; |
285 | #endif | 281 | #endif |
286 | 282 | ||
283 | |||
284 | /* | ||
285 | * Interface to driver core and IEEE 1394 core | ||
286 | */ | ||
287 | static struct ieee1394_device_id sbp2_id_table[] = { | ||
288 | { | ||
289 | .match_flags = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, | ||
290 | .specifier_id = SBP2_UNIT_SPEC_ID_ENTRY & 0xffffff, | ||
291 | .version = SBP2_SW_VERSION_ENTRY & 0xffffff}, | ||
292 | {} | ||
293 | }; | ||
294 | MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table); | ||
295 | |||
296 | static int sbp2_probe(struct device *); | ||
297 | static int sbp2_remove(struct device *); | ||
298 | static int sbp2_update(struct unit_directory *); | ||
299 | |||
287 | static struct hpsb_protocol_driver sbp2_driver = { | 300 | static struct hpsb_protocol_driver sbp2_driver = { |
288 | .name = "SBP2 Driver", | 301 | .name = "SBP2 Driver", |
289 | .id_table = sbp2_id_table, | 302 | .id_table = sbp2_id_table, |
@@ -296,6 +309,47 @@ static struct hpsb_protocol_driver sbp2_driver = { | |||
296 | }, | 309 | }, |
297 | }; | 310 | }; |
298 | 311 | ||
312 | |||
313 | /* | ||
314 | * Interface to SCSI core | ||
315 | */ | ||
316 | static int sbp2scsi_queuecommand(struct scsi_cmnd *, | ||
317 | void (*)(struct scsi_cmnd *)); | ||
318 | static int sbp2scsi_abort(struct scsi_cmnd *); | ||
319 | static int sbp2scsi_reset(struct scsi_cmnd *); | ||
320 | static int sbp2scsi_slave_alloc(struct scsi_device *); | ||
321 | static int sbp2scsi_slave_configure(struct scsi_device *); | ||
322 | static void sbp2scsi_slave_destroy(struct scsi_device *); | ||
323 | static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *, | ||
324 | struct device_attribute *, char *); | ||
325 | |||
326 | static DEVICE_ATTR(ieee1394_id, S_IRUGO, sbp2_sysfs_ieee1394_id_show, NULL); | ||
327 | |||
328 | static struct device_attribute *sbp2_sysfs_sdev_attrs[] = { | ||
329 | &dev_attr_ieee1394_id, | ||
330 | NULL | ||
331 | }; | ||
332 | |||
333 | static struct scsi_host_template scsi_driver_template = { | ||
334 | .module = THIS_MODULE, | ||
335 | .name = "SBP-2 IEEE-1394", | ||
336 | .proc_name = SBP2_DEVICE_NAME, | ||
337 | .queuecommand = sbp2scsi_queuecommand, | ||
338 | .eh_abort_handler = sbp2scsi_abort, | ||
339 | .eh_device_reset_handler = sbp2scsi_reset, | ||
340 | .slave_alloc = sbp2scsi_slave_alloc, | ||
341 | .slave_configure = sbp2scsi_slave_configure, | ||
342 | .slave_destroy = sbp2scsi_slave_destroy, | ||
343 | .this_id = -1, | ||
344 | .sg_tablesize = SG_ALL, | ||
345 | .use_clustering = ENABLE_CLUSTERING, | ||
346 | .cmd_per_lun = SBP2_MAX_CMDS, | ||
347 | .can_queue = SBP2_MAX_CMDS, | ||
348 | .emulated = 1, | ||
349 | .sdev_attrs = sbp2_sysfs_sdev_attrs, | ||
350 | }; | ||
351 | |||
352 | |||
299 | /* | 353 | /* |
300 | * List of devices with known bugs. | 354 | * List of devices with known bugs. |
301 | * | 355 | * |
@@ -715,7 +769,6 @@ static inline int sbp2util_node_is_available(struct scsi_id_instance_data *scsi_ | |||
715 | /********************************************* | 769 | /********************************************* |
716 | * IEEE-1394 core driver stack related section | 770 | * IEEE-1394 core driver stack related section |
717 | *********************************************/ | 771 | *********************************************/ |
718 | static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud); | ||
719 | 772 | ||
720 | static int sbp2_probe(struct device *dev) | 773 | static int sbp2_probe(struct device *dev) |
721 | { | 774 | { |
@@ -2630,38 +2683,12 @@ static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev, | |||
2630 | return sprintf(buf, "%016Lx:%d:%d\n", (unsigned long long)scsi_id->ne->guid, | 2683 | return sprintf(buf, "%016Lx:%d:%d\n", (unsigned long long)scsi_id->ne->guid, |
2631 | scsi_id->ud->id, lun); | 2684 | scsi_id->ud->id, lun); |
2632 | } | 2685 | } |
2633 | static DEVICE_ATTR(ieee1394_id, S_IRUGO, sbp2_sysfs_ieee1394_id_show, NULL); | ||
2634 | |||
2635 | static struct device_attribute *sbp2_sysfs_sdev_attrs[] = { | ||
2636 | &dev_attr_ieee1394_id, | ||
2637 | NULL | ||
2638 | }; | ||
2639 | 2686 | ||
2640 | MODULE_AUTHOR("Ben Collins <bcollins@debian.org>"); | 2687 | MODULE_AUTHOR("Ben Collins <bcollins@debian.org>"); |
2641 | MODULE_DESCRIPTION("IEEE-1394 SBP-2 protocol driver"); | 2688 | MODULE_DESCRIPTION("IEEE-1394 SBP-2 protocol driver"); |
2642 | MODULE_SUPPORTED_DEVICE(SBP2_DEVICE_NAME); | 2689 | MODULE_SUPPORTED_DEVICE(SBP2_DEVICE_NAME); |
2643 | MODULE_LICENSE("GPL"); | 2690 | MODULE_LICENSE("GPL"); |
2644 | 2691 | ||
2645 | /* SCSI host template */ | ||
2646 | static struct scsi_host_template scsi_driver_template = { | ||
2647 | .module = THIS_MODULE, | ||
2648 | .name = "SBP-2 IEEE-1394", | ||
2649 | .proc_name = SBP2_DEVICE_NAME, | ||
2650 | .queuecommand = sbp2scsi_queuecommand, | ||
2651 | .eh_abort_handler = sbp2scsi_abort, | ||
2652 | .eh_device_reset_handler = sbp2scsi_reset, | ||
2653 | .slave_alloc = sbp2scsi_slave_alloc, | ||
2654 | .slave_configure = sbp2scsi_slave_configure, | ||
2655 | .slave_destroy = sbp2scsi_slave_destroy, | ||
2656 | .this_id = -1, | ||
2657 | .sg_tablesize = SG_ALL, | ||
2658 | .use_clustering = ENABLE_CLUSTERING, | ||
2659 | .cmd_per_lun = SBP2_MAX_CMDS, | ||
2660 | .can_queue = SBP2_MAX_CMDS, | ||
2661 | .emulated = 1, | ||
2662 | .sdev_attrs = sbp2_sysfs_sdev_attrs, | ||
2663 | }; | ||
2664 | |||
2665 | static int sbp2_module_init(void) | 2692 | static int sbp2_module_init(void) |
2666 | { | 2693 | { |
2667 | int ret; | 2694 | int ret; |
diff --git a/drivers/ieee1394/sbp2.h b/drivers/ieee1394/sbp2.h index 1b16d6b9cf11..56917b9fa22d 100644 --- a/drivers/ieee1394/sbp2.h +++ b/drivers/ieee1394/sbp2.h | |||
@@ -364,49 +364,4 @@ struct sbp2scsi_host_info { | |||
364 | struct list_head scsi_ids; /* List of scsi ids on this host */ | 364 | struct list_head scsi_ids; /* List of scsi ids on this host */ |
365 | }; | 365 | }; |
366 | 366 | ||
367 | /* | ||
368 | * Function prototypes | ||
369 | */ | ||
370 | |||
371 | /* | ||
372 | * Various utility prototypes | ||
373 | */ | ||
374 | static int sbp2util_create_command_orb_pool(struct scsi_id_instance_data *scsi_id); | ||
375 | static void sbp2util_remove_command_orb_pool(struct scsi_id_instance_data *scsi_id); | ||
376 | static struct sbp2_command_info *sbp2util_find_command_for_orb(struct scsi_id_instance_data *scsi_id, dma_addr_t orb); | ||
377 | static struct sbp2_command_info *sbp2util_find_command_for_SCpnt(struct scsi_id_instance_data *scsi_id, void *SCpnt); | ||
378 | static struct sbp2_command_info *sbp2util_allocate_command_orb(struct scsi_id_instance_data *scsi_id, | ||
379 | struct scsi_cmnd *Current_SCpnt, | ||
380 | void (*Current_done)(struct scsi_cmnd *)); | ||
381 | static void sbp2util_mark_command_completed(struct scsi_id_instance_data *scsi_id, | ||
382 | struct sbp2_command_info *command); | ||
383 | |||
384 | |||
385 | static int sbp2_start_device(struct scsi_id_instance_data *scsi_id); | ||
386 | static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id); | ||
387 | |||
388 | #ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA | ||
389 | static int sbp2_handle_physdma_write(struct hpsb_host *host, int nodeid, int destid, quadlet_t *data, | ||
390 | u64 addr, size_t length, u16 flags); | ||
391 | static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid, quadlet_t *data, | ||
392 | u64 addr, size_t length, u16 flags); | ||
393 | #endif | ||
394 | |||
395 | /* | ||
396 | * SBP-2 protocol related prototypes | ||
397 | */ | ||
398 | static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id); | ||
399 | static int sbp2_login_device(struct scsi_id_instance_data *scsi_id); | ||
400 | static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id); | ||
401 | static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id); | ||
402 | static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int destid, | ||
403 | quadlet_t *data, u64 addr, size_t length, u16 flags); | ||
404 | static int sbp2_agent_reset(struct scsi_id_instance_data *scsi_id, int wait); | ||
405 | static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, | ||
406 | unchar *sense_data); | ||
407 | static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, | ||
408 | struct unit_directory *ud); | ||
409 | static int sbp2_set_busy_timeout(struct scsi_id_instance_data *scsi_id); | ||
410 | static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id); | ||
411 | |||
412 | #endif /* SBP2_H */ | 367 | #endif /* SBP2_H */ |