Commit e8ca5668 authored by Stefan Richter's avatar Stefan Richter

ieee1394: sbp2: remove superfluous comments

And update and reformat remaining comments.
Signed-off-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
parent d19c7764
...@@ -404,15 +404,15 @@ static int sbp2util_access_timeout(struct scsi_id_instance_data *scsi_id, ...@@ -404,15 +404,15 @@ static int sbp2util_access_timeout(struct scsi_id_instance_data *scsi_id,
return leftover <= 0; return leftover <= 0;
} }
/* Frees an allocated packet */
static void sbp2_free_packet(struct hpsb_packet *packet) static void sbp2_free_packet(struct hpsb_packet *packet)
{ {
hpsb_free_tlabel(packet); hpsb_free_tlabel(packet);
hpsb_free_packet(packet); hpsb_free_packet(packet);
} }
/* This is much like hpsb_node_write(), except it ignores the response /*
* subaction and returns immediately. Can be used from interrupts. * This is much like hpsb_node_write(), except it ignores the response
* subaction and returns immediately. Can be used from atomic context.
*/ */
static int sbp2util_node_write_no_wait(struct node_entry *ne, u64 addr, static int sbp2util_node_write_no_wait(struct node_entry *ne, u64 addr,
quadlet_t *buffer, size_t length) quadlet_t *buffer, size_t length)
...@@ -476,10 +476,6 @@ static void sbp2util_write_doorbell(struct work_struct *work) ...@@ -476,10 +476,6 @@ static void sbp2util_write_doorbell(struct work_struct *work)
sbp2util_notify_fetch_agent(container_of(work, struct scsi_id_instance_data, protocol_work), SBP2_DOORBELL_OFFSET, NULL, 4); sbp2util_notify_fetch_agent(container_of(work, struct scsi_id_instance_data, protocol_work), SBP2_DOORBELL_OFFSET, NULL, 4);
} }
/*
* This function is called to create a pool of command orbs used for
* command processing. It is called when a new sbp2 device is detected.
*/
static int sbp2util_create_command_orb_pool(struct scsi_id_instance_data *scsi_id) static int sbp2util_create_command_orb_pool(struct scsi_id_instance_data *scsi_id)
{ {
struct sbp2scsi_host_info *hi = scsi_id->hi; struct sbp2scsi_host_info *hi = scsi_id->hi;
...@@ -513,9 +509,6 @@ static int sbp2util_create_command_orb_pool(struct scsi_id_instance_data *scsi_i ...@@ -513,9 +509,6 @@ static int sbp2util_create_command_orb_pool(struct scsi_id_instance_data *scsi_i
return 0; return 0;
} }
/*
* This function is called to delete a pool of command orbs.
*/
static void sbp2util_remove_command_orb_pool(struct scsi_id_instance_data *scsi_id) static void sbp2util_remove_command_orb_pool(struct scsi_id_instance_data *scsi_id)
{ {
struct hpsb_host *host = scsi_id->hi->host; struct hpsb_host *host = scsi_id->hi->host;
...@@ -527,8 +520,6 @@ static void sbp2util_remove_command_orb_pool(struct scsi_id_instance_data *scsi_ ...@@ -527,8 +520,6 @@ static void sbp2util_remove_command_orb_pool(struct scsi_id_instance_data *scsi_
if (!list_empty(&scsi_id->sbp2_command_orb_completed)) { if (!list_empty(&scsi_id->sbp2_command_orb_completed)) {
list_for_each_safe(lh, next, &scsi_id->sbp2_command_orb_completed) { list_for_each_safe(lh, next, &scsi_id->sbp2_command_orb_completed) {
command = list_entry(lh, struct sbp2_command_info, list); command = list_entry(lh, struct sbp2_command_info, list);
/* Release our generic DMA's */
pci_unmap_single(host->pdev, command->command_orb_dma, pci_unmap_single(host->pdev, command->command_orb_dma,
sizeof(struct sbp2_command_orb), sizeof(struct sbp2_command_orb),
PCI_DMA_TODEVICE); PCI_DMA_TODEVICE);
...@@ -543,8 +534,8 @@ static void sbp2util_remove_command_orb_pool(struct scsi_id_instance_data *scsi_ ...@@ -543,8 +534,8 @@ static void sbp2util_remove_command_orb_pool(struct scsi_id_instance_data *scsi_
} }
/* /*
* This function finds the sbp2_command for a given outstanding command * Finds the sbp2_command for a given outstanding command ORB.
* orb.Only looks at the inuse list. * Only looks at the in-use list.
*/ */
static struct sbp2_command_info *sbp2util_find_command_for_orb( static struct sbp2_command_info *sbp2util_find_command_for_orb(
struct scsi_id_instance_data *scsi_id, dma_addr_t orb) struct scsi_id_instance_data *scsi_id, dma_addr_t orb)
...@@ -566,8 +557,8 @@ static struct sbp2_command_info *sbp2util_find_command_for_orb( ...@@ -566,8 +557,8 @@ static struct sbp2_command_info *sbp2util_find_command_for_orb(
} }
/* /*
* This function finds the sbp2_command for a given outstanding SCpnt. * Finds the sbp2_command for a given outstanding SCpnt.
* Only looks at the inuse list. * Only looks at the in-use list.
* Must be called with scsi_id->sbp2_command_orb_lock held. * Must be called with scsi_id->sbp2_command_orb_lock held.
*/ */
static struct sbp2_command_info *sbp2util_find_command_for_SCpnt( static struct sbp2_command_info *sbp2util_find_command_for_SCpnt(
...@@ -582,9 +573,6 @@ static struct sbp2_command_info *sbp2util_find_command_for_SCpnt( ...@@ -582,9 +573,6 @@ static struct sbp2_command_info *sbp2util_find_command_for_SCpnt(
return NULL; return NULL;
} }
/*
* This function allocates a command orb used to send a scsi command.
*/
static struct sbp2_command_info *sbp2util_allocate_command_orb( static struct sbp2_command_info *sbp2util_allocate_command_orb(
struct scsi_id_instance_data *scsi_id, struct scsi_id_instance_data *scsi_id,
struct scsi_cmnd *Current_SCpnt, struct scsi_cmnd *Current_SCpnt,
...@@ -609,7 +597,6 @@ static struct sbp2_command_info *sbp2util_allocate_command_orb( ...@@ -609,7 +597,6 @@ static struct sbp2_command_info *sbp2util_allocate_command_orb(
return command; return command;
} }
/* Free our DMA's */
static void sbp2util_free_command_dma(struct sbp2_command_info *command) static void sbp2util_free_command_dma(struct sbp2_command_info *command)
{ {
struct scsi_id_instance_data *scsi_id = struct scsi_id_instance_data *scsi_id =
...@@ -705,7 +692,7 @@ static int sbp2_remove(struct device *dev) ...@@ -705,7 +692,7 @@ static int sbp2_remove(struct device *dev)
* send them. */ * send them. */
if (!sbp2util_node_is_available(scsi_id)) if (!sbp2util_node_is_available(scsi_id))
sbp2scsi_complete_all_commands(scsi_id, DID_NO_CONNECT); sbp2scsi_complete_all_commands(scsi_id, DID_NO_CONNECT);
/* scsi_remove_device() will trigger shutdown functions of SCSI /* scsi_remove_device() may trigger shutdown functions of SCSI
* highlevel drivers which would deadlock if blocked. */ * highlevel drivers which would deadlock if blocked. */
atomic_set(&scsi_id->state, SBP2LU_STATE_IN_SHUTDOWN); atomic_set(&scsi_id->state, SBP2LU_STATE_IN_SHUTDOWN);
scsi_unblock_requests(scsi_id->scsi_host); scsi_unblock_requests(scsi_id->scsi_host);
...@@ -727,12 +714,9 @@ static int sbp2_update(struct unit_directory *ud) ...@@ -727,12 +714,9 @@ static int sbp2_update(struct unit_directory *ud)
struct scsi_id_instance_data *scsi_id = ud->device.driver_data; struct scsi_id_instance_data *scsi_id = ud->device.driver_data;
if (sbp2_reconnect_device(scsi_id)) { if (sbp2_reconnect_device(scsi_id)) {
/* Reconnect has failed. Perhaps we didn't reconnect fast
/* * enough. Try a regular login, but first log out just in
* Ok, reconnect has failed. Perhaps we didn't * case of any weirdness. */
* reconnect fast enough. Try doing a regular login, but
* first do a logout just in case of any weirdness.
*/
sbp2_logout_device(scsi_id); sbp2_logout_device(scsi_id);
if (sbp2_login_device(scsi_id)) { if (sbp2_login_device(scsi_id)) {
...@@ -743,18 +727,12 @@ static int sbp2_update(struct unit_directory *ud) ...@@ -743,18 +727,12 @@ static int sbp2_update(struct unit_directory *ud)
} }
} }
/* Set max retries to something large on the device. */
sbp2_set_busy_timeout(scsi_id); sbp2_set_busy_timeout(scsi_id);
/* Do a SBP-2 fetch agent reset. */
sbp2_agent_reset(scsi_id, 1); sbp2_agent_reset(scsi_id, 1);
/* Get the max speed and packet size that we can use. */
sbp2_max_speed_and_size(scsi_id); sbp2_max_speed_and_size(scsi_id);
/* Complete any pending commands with busy (so they get /* Complete any pending commands with busy (so they get retried)
* retried) and remove them from our queue * and remove them from our queue. */
*/
sbp2scsi_complete_all_commands(scsi_id, DID_BUS_BUSY); sbp2scsi_complete_all_commands(scsi_id, DID_BUS_BUSY);
/* Accept new commands unless there was another bus reset in the /* Accept new commands unless there was another bus reset in the
...@@ -766,8 +744,6 @@ static int sbp2_update(struct unit_directory *ud) ...@@ -766,8 +744,6 @@ static int sbp2_update(struct unit_directory *ud)
return 0; return 0;
} }
/* This functions is called by the sbp2_probe, for each new device. We now
* allocate one scsi host for each scsi_id (unit directory). */
static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud) static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud)
{ {
struct sbp2scsi_host_info *hi; struct sbp2scsi_host_info *hi;
...@@ -843,7 +819,6 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud ...@@ -843,7 +819,6 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud
goto failed_alloc; goto failed_alloc;
} }
/* Register our host with the SCSI stack. */
scsi_host = scsi_host_alloc(&scsi_driver_template, scsi_host = scsi_host_alloc(&scsi_driver_template,
sizeof(unsigned long)); sizeof(unsigned long));
if (!scsi_host) { if (!scsi_host) {
...@@ -882,16 +857,11 @@ static void sbp2_host_reset(struct hpsb_host *host) ...@@ -882,16 +857,11 @@ static void sbp2_host_reset(struct hpsb_host *host)
} }
} }
/*
* This function is where we first pull the node unique ids, and then
* allocate memory and register a SBP-2 device.
*/
static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
{ {
struct sbp2scsi_host_info *hi = scsi_id->hi; struct sbp2scsi_host_info *hi = scsi_id->hi;
int error; int error;
/* Login FIFO DMA */
scsi_id->login_response = scsi_id->login_response =
pci_alloc_consistent(hi->host->pdev, pci_alloc_consistent(hi->host->pdev,
sizeof(struct sbp2_login_response), sizeof(struct sbp2_login_response),
...@@ -899,7 +869,6 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) ...@@ -899,7 +869,6 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
if (!scsi_id->login_response) if (!scsi_id->login_response)
goto alloc_fail; goto alloc_fail;
/* Query logins ORB DMA */
scsi_id->query_logins_orb = scsi_id->query_logins_orb =
pci_alloc_consistent(hi->host->pdev, pci_alloc_consistent(hi->host->pdev,
sizeof(struct sbp2_query_logins_orb), sizeof(struct sbp2_query_logins_orb),
...@@ -907,7 +876,6 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) ...@@ -907,7 +876,6 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
if (!scsi_id->query_logins_orb) if (!scsi_id->query_logins_orb)
goto alloc_fail; goto alloc_fail;
/* Query logins response DMA */
scsi_id->query_logins_response = scsi_id->query_logins_response =
pci_alloc_consistent(hi->host->pdev, pci_alloc_consistent(hi->host->pdev,
sizeof(struct sbp2_query_logins_response), sizeof(struct sbp2_query_logins_response),
...@@ -915,7 +883,6 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) ...@@ -915,7 +883,6 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
if (!scsi_id->query_logins_response) if (!scsi_id->query_logins_response)
goto alloc_fail; goto alloc_fail;
/* Reconnect ORB DMA */
scsi_id->reconnect_orb = scsi_id->reconnect_orb =
pci_alloc_consistent(hi->host->pdev, pci_alloc_consistent(hi->host->pdev,
sizeof(struct sbp2_reconnect_orb), sizeof(struct sbp2_reconnect_orb),
...@@ -923,7 +890,6 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) ...@@ -923,7 +890,6 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
if (!scsi_id->reconnect_orb) if (!scsi_id->reconnect_orb)
goto alloc_fail; goto alloc_fail;
/* Logout ORB DMA */
scsi_id->logout_orb = scsi_id->logout_orb =
pci_alloc_consistent(hi->host->pdev, pci_alloc_consistent(hi->host->pdev,
sizeof(struct sbp2_logout_orb), sizeof(struct sbp2_logout_orb),
...@@ -931,7 +897,6 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) ...@@ -931,7 +897,6 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
if (!scsi_id->logout_orb) if (!scsi_id->logout_orb)
goto alloc_fail; goto alloc_fail;
/* Login ORB DMA */
scsi_id->login_orb = scsi_id->login_orb =
pci_alloc_consistent(hi->host->pdev, pci_alloc_consistent(hi->host->pdev,
sizeof(struct sbp2_login_orb), sizeof(struct sbp2_login_orb),
...@@ -939,51 +904,28 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) ...@@ -939,51 +904,28 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
if (!scsi_id->login_orb) if (!scsi_id->login_orb)
goto alloc_fail; goto alloc_fail;
/*
* Create our command orb pool
*/
if (sbp2util_create_command_orb_pool(scsi_id)) { if (sbp2util_create_command_orb_pool(scsi_id)) {
SBP2_ERR("sbp2util_create_command_orb_pool failed!"); SBP2_ERR("sbp2util_create_command_orb_pool failed!");
sbp2_remove_device(scsi_id); sbp2_remove_device(scsi_id);
return -ENOMEM; return -ENOMEM;
} }
/* Schedule a timeout here. The reason is that we may be so close /* Wait a second before trying to log in. Previously logged in
* to a bus reset, that the device is not available for logins. * initiators need a chance to reconnect. */
* This can happen when the bus reset is caused by the host
* connected to the sbp2 device being removed. That host would
* have a certain amount of time to relogin before the sbp2 device
* allows someone else to login instead. One second makes sense. */
if (msleep_interruptible(1000)) { if (msleep_interruptible(1000)) {
sbp2_remove_device(scsi_id); sbp2_remove_device(scsi_id);
return -EINTR; return -EINTR;
} }
/*
* Login to the sbp-2 device
*/
if (sbp2_login_device(scsi_id)) { if (sbp2_login_device(scsi_id)) {
/* Login failed, just remove the device. */
sbp2_remove_device(scsi_id); sbp2_remove_device(scsi_id);
return -EBUSY; return -EBUSY;
} }
/*
* Set max retries to something large on the device
*/
sbp2_set_busy_timeout(scsi_id); sbp2_set_busy_timeout(scsi_id);
/*
* Do a SBP-2 fetch agent reset
*/
sbp2_agent_reset(scsi_id, 1); sbp2_agent_reset(scsi_id, 1);
/*
* Get the max speed and packet size that we can use
*/
sbp2_max_speed_and_size(scsi_id); sbp2_max_speed_and_size(scsi_id);
/* Add this device to the scsi layer now */
error = scsi_add_device(scsi_id->scsi_host, 0, scsi_id->ud->id, 0); error = scsi_add_device(scsi_id->scsi_host, 0, scsi_id->ud->id, 0);
if (error) { if (error) {
SBP2_ERR("scsi_add_device failed"); SBP2_ERR("scsi_add_device failed");
...@@ -1000,9 +942,6 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) ...@@ -1000,9 +942,6 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
return -ENOMEM; return -ENOMEM;
} }
/*
* This function removes an sbp2 device from the sbp2scsi_host_info struct.
*/
static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id) static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id)
{ {
struct sbp2scsi_host_info *hi; struct sbp2scsi_host_info *hi;
...@@ -1012,7 +951,6 @@ static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id) ...@@ -1012,7 +951,6 @@ static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id)
hi = scsi_id->hi; hi = scsi_id->hi;
/* This will remove our scsi device aswell */
if (scsi_id->scsi_host) { if (scsi_id->scsi_host) {
scsi_remove_host(scsi_id->scsi_host); scsi_remove_host(scsi_id->scsi_host);
scsi_host_put(scsi_id->scsi_host); scsi_host_put(scsi_id->scsi_host);
...@@ -1067,33 +1005,25 @@ static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id) ...@@ -1067,33 +1005,25 @@ static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id)
#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA #ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA
/* /*
* This function deals with physical dma write requests (for adapters that do not support * Deal with write requests on adapters which do not support physical DMA or
* physical dma in hardware). Mostly just here for debugging... * have it switched off.
*/ */
static int sbp2_handle_physdma_write(struct hpsb_host *host, int nodeid, static int sbp2_handle_physdma_write(struct hpsb_host *host, int nodeid,
int destid, quadlet_t *data, u64 addr, int destid, quadlet_t *data, u64 addr,
size_t length, u16 flags) size_t length, u16 flags)
{ {
/*
* Manually put the data in the right place.
*/
memcpy(bus_to_virt((u32) addr), data, length); memcpy(bus_to_virt((u32) addr), data, length);
return RCODE_COMPLETE; return RCODE_COMPLETE;
} }
/* /*
* This function deals with physical dma read requests (for adapters that do not support * Deal with read requests on adapters which do not support physical DMA or
* physical dma in hardware). Mostly just here for debugging... * have it switched off.
*/ */
static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid, static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid,
quadlet_t *data, u64 addr, size_t length, quadlet_t *data, u64 addr, size_t length,
u16 flags) u16 flags)
{ {
/*
* Grab data from memory and send a read response.
*/
memcpy(data, bus_to_virt((u32) addr), length); memcpy(data, bus_to_virt((u32) addr), length);
return RCODE_COMPLETE; return RCODE_COMPLETE;
} }
...@@ -1103,10 +1033,6 @@ static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid, ...@@ -1103,10 +1033,6 @@ static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid,
* SBP-2 protocol related section * SBP-2 protocol related section
**************************************/ **************************************/
/*
* This function queries the device for the maximum concurrent logins it
* supports.
*/
static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id) static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id)
{ {
struct sbp2scsi_host_info *hi = scsi_id->hi; struct sbp2scsi_host_info *hi = scsi_id->hi;
...@@ -1172,10 +1098,6 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id) ...@@ -1172,10 +1098,6 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id)
return 0; return 0;
} }
/*
* This function is called in order to login to a particular SBP-2 device,
* after a bus reset.
*/
static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
{ {
struct sbp2scsi_host_info *hi = scsi_id->hi; struct sbp2scsi_host_info *hi = scsi_id->hi;
...@@ -1191,17 +1113,18 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) ...@@ -1191,17 +1113,18 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
} }
} }
/* Set-up login ORB, assume no password */ /* assume no password */
scsi_id->login_orb->password_hi = 0; scsi_id->login_orb->password_hi = 0;
scsi_id->login_orb->password_lo = 0; scsi_id->login_orb->password_lo = 0;
scsi_id->login_orb->login_response_lo = scsi_id->login_response_dma; scsi_id->login_orb->login_response_lo = scsi_id->login_response_dma;
scsi_id->login_orb->login_response_hi = ORB_SET_NODE_ID(hi->host->node_id); scsi_id->login_orb->login_response_hi = ORB_SET_NODE_ID(hi->host->node_id);
scsi_id->login_orb->lun_misc = ORB_SET_FUNCTION(SBP2_LOGIN_REQUEST); scsi_id->login_orb->lun_misc = ORB_SET_FUNCTION(SBP2_LOGIN_REQUEST);
scsi_id->login_orb->lun_misc |= ORB_SET_RECONNECT(0); /* One second reconnect time */
scsi_id->login_orb->lun_misc |= ORB_SET_EXCLUSIVE(exclusive_login); /* Exclusive access to device */ /* one second reconnect time */
scsi_id->login_orb->lun_misc |= ORB_SET_NOTIFY(1); /* Notify us of login complete */ scsi_id->login_orb->lun_misc |= ORB_SET_RECONNECT(0);
scsi_id->login_orb->lun_misc |= ORB_SET_EXCLUSIVE(exclusive_login);
scsi_id->login_orb->lun_misc |= ORB_SET_NOTIFY(1);
scsi_id->login_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_lun); scsi_id->login_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_lun);
scsi_id->login_orb->passwd_resp_lengths = scsi_id->login_orb->passwd_resp_lengths =
...@@ -1222,17 +1145,13 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) ...@@ -1222,17 +1145,13 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
hpsb_node_write(scsi_id->ne, scsi_id->sbp2_management_agent_addr, data, 8); hpsb_node_write(scsi_id->ne, scsi_id->sbp2_management_agent_addr, data, 8);
/* /* wait up to 20 seconds for login status */
* Wait for login status (up to 20 seconds)...
*/
if (sbp2util_access_timeout(scsi_id, 20*HZ)) { if (sbp2util_access_timeout(scsi_id, 20*HZ)) {
SBP2_ERR("Error logging into SBP-2 device - timed out"); SBP2_ERR("Error logging into SBP-2 device - timed out");
return -EIO; return -EIO;
} }
/* /* make sure that the returned status matches the login ORB */
* Sanity. Make sure status returned matches login orb.
*/
if (scsi_id->status_block.ORB_offset_lo != scsi_id->login_orb_dma) { if (scsi_id->status_block.ORB_offset_lo != scsi_id->login_orb_dma) {
SBP2_ERR("Error logging into SBP-2 device - timed out"); SBP2_ERR("Error logging into SBP-2 device - timed out");
return -EIO; return -EIO;
...@@ -1243,15 +1162,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) ...@@ -1243,15 +1162,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
return -EIO; return -EIO;
} }
/*
* Byte swap the login response, for use when reconnecting or
* logging out.
*/
sbp2util_cpu_to_be32_buffer(scsi_id->login_response, sizeof(struct sbp2_login_response)); sbp2util_cpu_to_be32_buffer(scsi_id->login_response, sizeof(struct sbp2_login_response));
/*
* Grab our command block agent address from the login response.
*/
scsi_id->sbp2_command_block_agent_addr = scsi_id->sbp2_command_block_agent_addr =
((u64)scsi_id->login_response->command_block_agent_hi) << 32; ((u64)scsi_id->login_response->command_block_agent_hi) << 32;
scsi_id->sbp2_command_block_agent_addr |= ((u64)scsi_id->login_response->command_block_agent_lo); scsi_id->sbp2_command_block_agent_addr |= ((u64)scsi_id->login_response->command_block_agent_lo);
...@@ -1261,19 +1172,12 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) ...@@ -1261,19 +1172,12 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
return 0; return 0;
} }
/*
* This function is called in order to logout from a particular SBP-2
* device, usually called during driver unload.
*/
static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id) static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id)
{ {
struct sbp2scsi_host_info *hi = scsi_id->hi; struct sbp2scsi_host_info *hi = scsi_id->hi;
quadlet_t data[2]; quadlet_t data[2];
int error; int error;
/*
* Set-up logout ORB
*/
scsi_id->logout_orb->reserved1 = 0x0; scsi_id->logout_orb->reserved1 = 0x0;
scsi_id->logout_orb->reserved2 = 0x0; scsi_id->logout_orb->reserved2 = 0x0;
scsi_id->logout_orb->reserved3 = 0x0; scsi_id->logout_orb->reserved3 = 0x0;
...@@ -1281,8 +1185,6 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id) ...@@ -1281,8 +1185,6 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id)
scsi_id->logout_orb->login_ID_misc = ORB_SET_FUNCTION(SBP2_LOGOUT_REQUEST); scsi_id->logout_orb->login_ID_misc = ORB_SET_FUNCTION(SBP2_LOGOUT_REQUEST);
scsi_id->logout_orb->login_ID_misc |= ORB_SET_LOGIN_ID(scsi_id->login_response->length_login_ID); scsi_id->logout_orb->login_ID_misc |= ORB_SET_LOGIN_ID(scsi_id->login_response->length_login_ID);
/* Notify us when complete */
scsi_id->logout_orb->login_ID_misc |= ORB_SET_NOTIFY(1); scsi_id->logout_orb->login_ID_misc |= ORB_SET_NOTIFY(1);
scsi_id->logout_orb->reserved5 = 0x0; scsi_id->logout_orb->reserved5 = 0x0;
...@@ -1291,14 +1193,8 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id) ...@@ -1291,14 +1193,8 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id)
scsi_id->logout_orb->status_fifo_lo = scsi_id->logout_orb->status_fifo_lo =
ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr); ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr);
/*
* Byte swap ORB if necessary
*/
sbp2util_cpu_to_be32_buffer(scsi_id->logout_orb, sizeof(struct sbp2_logout_orb)); sbp2util_cpu_to_be32_buffer(scsi_id->logout_orb, sizeof(struct sbp2_logout_orb));
/*
* Ok, let's write to the target's management agent register
*/
data[0] = ORB_SET_NODE_ID(hi->host->node_id); data[0] = ORB_SET_NODE_ID(hi->host->node_id);
data[1] = scsi_id->logout_orb_dma; data[1] = scsi_id->logout_orb_dma;
sbp2util_cpu_to_be32_buffer(data, 8); sbp2util_cpu_to_be32_buffer(data, 8);
...@@ -1308,7 +1204,7 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id) ...@@ -1308,7 +1204,7 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id)
if (error) if (error)
return error; return error;
/* Wait for device to logout...1 second. */ /* wait up to 1 second for the device to complete logout */
if (sbp2util_access_timeout(scsi_id, HZ)) if (sbp2util_access_timeout(scsi_id, HZ))
return -EIO; return -EIO;
...@@ -1316,19 +1212,12 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id) ...@@ -1316,19 +1212,12 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id)
return 0; return 0;
} }
/*
* This function is called in order to reconnect to a particular SBP-2
* device, after a bus reset.
*/
static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id) static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id)
{ {
struct sbp2scsi_host_info *hi = scsi_id->hi; struct sbp2scsi_host_info *hi = scsi_id->hi;
quadlet_t data[2]; quadlet_t data[2];
int error; int error;
/*
* Set-up reconnect ORB
*/
scsi_id->reconnect_orb->reserved1 = 0x0; scsi_id->reconnect_orb->reserved1 = 0x0;
scsi_id->reconnect_orb->reserved2 = 0x0; scsi_id->reconnect_orb->reserved2 = 0x0;
scsi_id->reconnect_orb->reserved3 = 0x0; scsi_id->reconnect_orb->reserved3 = 0x0;
...@@ -1337,8 +1226,6 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id) ...@@ -1337,8 +1226,6 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id)
scsi_id->reconnect_orb->login_ID_misc = ORB_SET_FUNCTION(SBP2_RECONNECT_REQUEST); scsi_id->reconnect_orb->login_ID_misc = ORB_SET_FUNCTION(SBP2_RECONNECT_REQUEST);
scsi_id->reconnect_orb->login_ID_misc |= scsi_id->reconnect_orb->login_ID_misc |=
ORB_SET_LOGIN_ID(scsi_id->login_response->length_login_ID); ORB_SET_LOGIN_ID(scsi_id->login_response->length_login_ID);
/* Notify us when complete */
scsi_id->reconnect_orb->login_ID_misc |= ORB_SET_NOTIFY(1); scsi_id->reconnect_orb->login_ID_misc |= ORB_SET_NOTIFY(1);
scsi_id->reconnect_orb->reserved5 = 0x0; scsi_id->reconnect_orb->reserved5 = 0x0;
...@@ -1347,9 +1234,6 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id) ...@@ -1347,9 +1234,6 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id)
scsi_id->reconnect_orb->status_fifo_lo = scsi_id->reconnect_orb->status_fifo_lo =
ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr); ORB_SET_STATUS_FIFO_LO(scsi_id->status_fifo_addr);
/*
* Byte swap ORB if necessary
*/
sbp2util_cpu_to_be32_buffer(scsi_id->reconnect_orb, sizeof(struct sbp2_reconnect_orb)); sbp2util_cpu_to_be32_buffer(scsi_id->reconnect_orb, sizeof(struct sbp2_reconnect_orb));
data[0] = ORB_SET_NODE_ID(hi->host->node_id); data[0] = ORB_SET_NODE_ID(hi->host->node_id);
...@@ -1361,17 +1245,13 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id) ...@@ -1361,17 +1245,13 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id)
if (error) if (error)
return error; return error;
/* /* wait up to 1 second for reconnect status */
* Wait for reconnect status (up to 1 second)...
*/
if (sbp2util_access_timeout(scsi_id, HZ)) { if (sbp2util_access_timeout(scsi_id, HZ)) {
SBP2_ERR("Error reconnecting to SBP-2 device - timed out"); SBP2_ERR("Error reconnecting to SBP-2 device - timed out");
return -EIO; return -EIO;
} }
/* /* make sure that the returned status matches the reconnect ORB */
* Sanity. Make sure status returned matches reconnect orb.
*/
if (scsi_id->status_block.ORB_offset_lo != scsi_id->reconnect_orb_dma) { if (scsi_id->status_block.ORB_offset_lo != scsi_id->reconnect_orb_dma) {
SBP2_ERR("Error reconnecting to SBP-2 device - timed out"); SBP2_ERR("Error reconnecting to SBP-2 device - timed out");
return -EIO; return -EIO;
...@@ -1387,8 +1267,8 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id) ...@@ -1387,8 +1267,8 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id)
} }
/* /*
* This function is called in order to set the busy timeout (number of * Set the target node's Single Phase Retry limit. Affects the target's retry
* retries to attempt) on the sbp2 device. * behaviour if our node is too busy to accept requests.
*/ */
static int sbp2_set_busy_timeout(struct scsi_id_instance_data *scsi_id) static int sbp2_set_busy_timeout(struct scsi_id_instance_data *scsi_id)
{ {
...@@ -1400,11 +1280,6 @@ static int sbp2_set_busy_timeout(struct scsi_id_instance_data *scsi_id) ...@@ -1400,11 +1280,6 @@ static int sbp2_set_busy_timeout(struct scsi_id_instance_data *scsi_id)
return 0; return 0;
} }
/*
* This function is called to parse sbp2 device's config rom unit
* directory. Used to determine things like sbp2 management agent offset,
* and command set used (SCSI or RBC).
*/
static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
struct unit_directory *ud) struct unit_directory *ud)
{ {
...@@ -1422,12 +1297,10 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, ...@@ -1422,12 +1297,10 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
unit_characteristics = 0x0; unit_characteristics = 0x0;
firmware_revision = 0x0; firmware_revision = 0x0;
/* Handle different fields in the unit directory, based on keys */
csr1212_for_each_dir_entry(ud->ne->csr, kv, ud->ud_kv, dentry) { csr1212_for_each_dir_entry(ud->ne->csr, kv, ud->ud_kv, dentry) {
switch (kv->key.id) { switch (kv->key.id) {
case CSR1212_KV_ID_DEPENDENT_INFO: case CSR1212_KV_ID_DEPENDENT_INFO:
if (kv->key.type == CSR1212_KV_TYPE_CSR_OFFSET) if (kv->key.type == CSR1212_KV_TYPE_CSR_OFFSET)
/* Save off the management agent address */
management_agent_addr = management_agent_addr =
CSR1212_REGISTER_SPACE_BASE + CSR1212_REGISTER_SPACE_BASE +
(kv->value.csr_offset << 2); (kv->value.csr_offset << 2);
...@@ -1438,29 +1311,27 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, ...@@ -1438,29 +1311,27 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
break; break;
case SBP2_COMMAND_SET_SPEC_ID_KEY: case SBP2_COMMAND_SET_SPEC_ID_KEY:
/* Command spec organization */
command_set_spec_id = kv->value.immediate; command_set_spec_id = kv->value.immediate;
break; break;
case SBP2_COMMAND_SET_KEY: case SBP2_COMMAND_SET_KEY:
/* Command set used by sbp2 device */
command_set = kv->value.immediate; command_set = kv->value.immediate;
break; break;
case SBP2_UNIT_CHARACTERISTICS_KEY: case SBP2_UNIT_CHARACTERISTICS_KEY:
/* /* FIXME: This is ignored so far.
* Unit characterisitcs (orb related stuff * See SBP-2 clause 7.4.8. */
* that I'm not yet paying attention to)
*/
unit_characteristics = kv->value.immediate; unit_characteristics = kv->value.immediate;
break; break;
case SBP2_FIRMWARE_REVISION_KEY: case SBP2_FIRMWARE_REVISION_KEY:
/* Firmware revision */
firmware_revision = kv->value.immediate; firmware_revision = kv->value.immediate;
break; break;
default: default:
/* FIXME: Check for SBP2_DEVICE_TYPE_AND_LUN_KEY.
* Its "ordered" bit has consequences for command ORB
* list handling. See SBP-2 clauses 4.6, 7.4.11, 10.2 */
break; break;
} }
} }
...@@ -1536,7 +1407,6 @@ static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id) ...@@ -1536,7 +1407,6 @@ static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id)
scsi_id->speed_code = scsi_id->speed_code =
hi->host->speed[NODEID_TO_NODE(scsi_id->ne->nodeid)]; hi->host->speed[NODEID_TO_NODE(scsi_id->ne->nodeid)];
/* Bump down our speed if the user requested it */
if (scsi_id->speed_code > max_speed) { if (scsi_id->speed_code > max_speed) {
scsi_id->speed_code = max_speed; scsi_id->speed_code = max_speed;
SBP2_INFO("Reducing speed to %s", hpsb_speedto_str[max_speed]); SBP2_INFO("Reducing speed to %s", hpsb_speedto_str[max_speed]);
...@@ -1563,9 +1433,6 @@ static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id) ...@@ -1563,9 +1433,6 @@ static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id)
return 0; return 0;
} }
/*
* This function is called in order to perform a SBP-2 agent reset.
*/
static int sbp2_agent_reset(struct scsi_id_instance_data *scsi_id, int wait) static int sbp2_agent_reset(struct scsi_id_instance_data *scsi_id, int wait)
{ {
quadlet_t data; quadlet_t data;
...@@ -1590,9 +1457,7 @@ static int sbp2_agent_reset(struct scsi_id_instance_data *scsi_id, int wait) ...@@ -1590,9 +1457,7 @@ static int sbp2_agent_reset(struct scsi_id_instance_data *scsi_id, int wait)
return -EIO; return -EIO;
} }
/* /* make sure that the ORB_POINTER is written on next command */
* Need to make sure orb pointer is written on next command
*/
spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags);
scsi_id->last_orb = NULL; scsi_id->last_orb = NULL;
spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
...@@ -1612,7 +1477,7 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb, ...@@ -1612,7 +1477,7 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb,
orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id); orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id);
orb->misc |= ORB_SET_DIRECTION(orb_direction); orb->misc |= ORB_SET_DIRECTION(orb_direction);
/* Special case if only one element (and less than 64KB in size) */ /* special case if only one element (and less than 64KB in size) */
if ((scsi_use_sg == 1) && if ((scsi_use_sg == 1) &&
(sgpnt[0].length <= SBP2_MAX_SG_ELEMENT_LENGTH)) { (sgpnt[0].length <= SBP2_MAX_SG_ELEMENT_LENGTH)) {
...@@ -1642,10 +1507,8 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb, ...@@ -1642,10 +1507,8 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb,
orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1); orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1);
orb->data_descriptor_lo = command->sge_dma; orb->data_descriptor_lo = command->sge_dma;
/* /* loop through and fill out our SBP-2 page tables
* Loop through and fill out our sbp-2 page tables * (and split up anything too large) */
* (and split up anything too large)
*/
for (i = 0, sg_count = 0 ; i < count; i++, sgpnt++) { for (i = 0, sg_count = 0 ; i < count; i++, sgpnt++) {
sg_len = sg_dma_len(sgpnt); sg_len = sg_dma_len(sgpnt);
sg_addr = sg_dma_address(sgpnt); sg_addr = sg_dma_address(sgpnt);
...@@ -1665,10 +1528,8 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb, ...@@ -1665,10 +1528,8 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb,
} }
} }
/* Number of page table (s/g) elements */
orb->misc |= ORB_SET_DATA_SIZE(sg_count); orb->misc |= ORB_SET_DATA_SIZE(sg_count);
/* Byte swap page tables if necessary */
sbp2util_cpu_to_be32_buffer(sg_element, sbp2util_cpu_to_be32_buffer(sg_element,
(sizeof(struct sbp2_unrestricted_page_table)) * (sizeof(struct sbp2_unrestricted_page_table)) *
sg_count); sg_count);
...@@ -1692,34 +1553,25 @@ static void sbp2_prep_command_orb_no_sg(struct sbp2_command_orb *orb, ...@@ -1692,34 +1553,25 @@ static void sbp2_prep_command_orb_no_sg(struct sbp2_command_orb *orb,
orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id); orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id);
orb->misc |= ORB_SET_DIRECTION(orb_direction); orb->misc |= ORB_SET_DIRECTION(orb_direction);
/* /* handle case where we get a command w/o s/g enabled
* Handle case where we get a command w/o s/g enabled (but * (but check for transfers larger than 64K) */
* check for transfers larger than 64K)
*/
if (scsi_request_bufflen <= SBP2_MAX_SG_ELEMENT_LENGTH) { if (scsi_request_bufflen <= SBP2_MAX_SG_ELEMENT_LENGTH) {
orb->data_descriptor_lo = command->cmd_dma; orb->data_descriptor_lo = command->cmd_dma;
orb->misc |= ORB_SET_DATA_SIZE(scsi_request_bufflen); orb->misc |= ORB_SET_DATA_SIZE(scsi_request_bufflen);
} else { } else {
/* The buffer is too large. Turn this into page tables. */
struct sbp2_unrestricted_page_table *sg_element = struct sbp2_unrestricted_page_table *sg_element =
&command->scatter_gather_element[0]; &command->scatter_gather_element[0];
u32 sg_count, sg_len; u32 sg_count, sg_len;
dma_addr_t sg_addr; dma_addr_t sg_addr;
/*
* Need to turn this into page tables, since the
* buffer is too large.
*/
orb->data_descriptor_lo = command->sge_dma; orb->data_descriptor_lo = command->sge_dma;
/* Use page tables (s/g) */
orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1); orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1);
/* /* fill out our SBP-2 page tables; split up the large buffer */
* fill out our sbp-2 page tables (and split up
* the large buffer)
*/
sg_count = 0; sg_count = 0;
sg_len = scsi_request_bufflen; sg_len = scsi_request_bufflen;
sg_addr = command->cmd_dma; sg_addr = command->cmd_dma;
...@@ -1738,20 +1590,14 @@ static void sbp2_prep_command_orb_no_sg(struct sbp2_command_orb *orb, ...@@ -1738,20 +1590,14 @@ static void sbp2_prep_command_orb_no_sg(struct sbp2_command_orb *orb,
sg_count++; sg_count++;
} }
/* Number of page table (s/g) elements */
orb->misc |= ORB_SET_DATA_SIZE(sg_count); orb->misc |= ORB_SET_DATA_SIZE(sg_count);
/* Byte swap page tables if necessary */
sbp2util_cpu_to_be32_buffer(sg_element, sbp2util_cpu_to_be32_buffer(sg_element,
(sizeof(struct sbp2_unrestricted_page_table)) * (sizeof(struct sbp2_unrestricted_page_table)) *
sg_count); sg_count);
} }
} }
/*
* This function is called to create the actual command orb and s/g list
* out of the scsi command itself.
*/
static void sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, static void sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id,
struct sbp2_command_info *command, struct sbp2_command_info *command,
unchar *scsi_cmd, unchar *scsi_cmd,
...@@ -1766,7 +1612,7 @@ static void sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, ...@@ -1766,7 +1612,7 @@ static void sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id,
u32 orb_direction; u32 orb_direction;
/* /*
* Set-up our command ORB.. * Set-up our command ORB.
* *
* NOTE: We're doing unrestricted page tables (s/g), as this is * NOTE: We're doing unrestricted page tables (s/g), as this is
* best performance (at least with the devices I have). This means * best performance (at least with the devices I have). This means
...@@ -1777,7 +1623,7 @@ static void sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, ...@@ -1777,7 +1623,7 @@ static void sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id,
command_orb->next_ORB_lo = 0x0; command_orb->next_ORB_lo = 0x0;
command_orb->misc = ORB_SET_MAX_PAYLOAD(scsi_id->max_payload_size); command_orb->misc = ORB_SET_MAX_PAYLOAD(scsi_id->max_payload_size);
command_orb->misc |= ORB_SET_SPEED(scsi_id->speed_code); command_orb->misc |= ORB_SET_SPEED(scsi_id->speed_code);
command_orb->misc |= ORB_SET_NOTIFY(1); /* Notify us when complete */ command_orb->misc |= ORB_SET_NOTIFY(1);
if (dma_dir == DMA_NONE) if (dma_dir == DMA_NONE)
orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER; orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER;
...@@ -1790,7 +1636,7 @@ static void sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, ...@@ -1790,7 +1636,7 @@ static void sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id,
orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER; orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER;
} }
/* Set-up our pagetable stuff */ /* set up our page table stuff */
if (orb_direction == ORB_DIRECTION_NO_DATA_TRANSFER) { if (orb_direction == ORB_DIRECTION_NO_DATA_TRANSFER) {
command_orb->data_descriptor_hi = 0x0; command_orb->data_descriptor_hi = 0x0;
command_orb->data_descriptor_lo = 0x0; command_orb->data_descriptor_lo = 0x0;
...@@ -1803,17 +1649,12 @@ static void sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, ...@@ -1803,17 +1649,12 @@ static void sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id,
orb_direction, scsi_request_bufflen, orb_direction, scsi_request_bufflen,
scsi_request_buffer, dma_dir); scsi_request_buffer, dma_dir);
/* Byte swap command ORB if necessary */
sbp2util_cpu_to_be32_buffer(command_orb, sizeof(struct sbp2_command_orb)); sbp2util_cpu_to_be32_buffer(command_orb, sizeof(struct sbp2_command_orb));
/* Put our scsi command in the command ORB */
memset(command_orb->cdb, 0, 12); memset(command_orb->cdb, 0, 12);
memcpy(command_orb->cdb, scsi_cmd, COMMAND_SIZE(*scsi_cmd)); memcpy(command_orb->cdb, scsi_cmd, COMMAND_SIZE(*scsi_cmd));
} }
/*
* This function is called in order to begin a regular SBP-2 command.
*/
static void sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id, static void sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
struct sbp2_command_info *command) struct sbp2_command_info *command)
{ {
...@@ -1832,9 +1673,8 @@ static void sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id, ...@@ -1832,9 +1673,8 @@ static void sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
pci_dma_sync_single_for_device(hi->host->pdev, command->sge_dma, pci_dma_sync_single_for_device(hi->host->pdev, command->sge_dma,
sizeof(command->scatter_gather_element), sizeof(command->scatter_gather_element),
PCI_DMA_BIDIRECTIONAL); PCI_DMA_BIDIRECTIONAL);
/*
* Check to see if there are any previous orbs to use /* check to see if there are any previous orbs to use */
*/
spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags);
last_orb = scsi_id->last_orb; last_orb = scsi_id->last_orb;
last_orb_dma = scsi_id->last_orb_dma; last_orb_dma = scsi_id->last_orb_dma;
...@@ -1892,9 +1732,6 @@ static void sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id, ...@@ -1892,9 +1732,6 @@ static void sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
} }
} }
/*
* This function is called in order to begin a regular SBP-2 command.
*/
static int sbp2_send_command(struct scsi_id_instance_data *scsi_id, static int sbp2_send_command(struct scsi_id_instance_data *scsi_id,
struct scsi_cmnd *SCpnt, struct scsi_cmnd *SCpnt,
void (*done)(struct scsi_cmnd *)) void (*done)(struct scsi_cmnd *))
...@@ -1903,23 +1740,13 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id, ...@@ -1903,23 +1740,13 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id,
unsigned int request_bufflen = SCpnt->request_bufflen; unsigned int request_bufflen = SCpnt->request_bufflen;
struct sbp2_command_info *command; struct sbp2_command_info *command;
/*
* Allocate a command orb and s/g structure
*/
command = sbp2util_allocate_command_orb(scsi_id, SCpnt, done); command = sbp2util_allocate_command_orb(scsi_id, SCpnt, done);
if (!command) if (!command)
return -EIO; return -EIO;
/*
* Now actually fill in the comamnd orb and sbp2 s/g list
*/
sbp2_create_command_orb(scsi_id, command, cmd, SCpnt->use_sg, sbp2_create_command_orb(scsi_id, command, cmd, SCpnt->use_sg,
request_bufflen, SCpnt->request_buffer, request_bufflen, SCpnt->request_buffer,
SCpnt->sc_data_direction); SCpnt->sc_data_direction);
/*
* Link up the orb, and ring the doorbell if needed
*/
sbp2_link_orb_command(scsi_id, command); sbp2_link_orb_command(scsi_id, command);
return 0; return 0;
...@@ -1930,9 +1757,7 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id, ...@@ -1930,9 +1757,7 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id,
*/ */
static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense_data) static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense_data)
{ {
/* /* OK, it's pretty ugly... ;-) */
* Ok, it's pretty ugly... ;-)
*/
sense_data[0] = 0x70; sense_data[0] = 0x70;
sense_data[1] = 0x0; sense_data[1] = 0x0;
sense_data[2] = sbp2_status[9]; sense_data[2] = sbp2_status[9];
...@@ -1950,12 +1775,9 @@ static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense ...@@ -1950,12 +1775,9 @@ static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense
sense_data[14] = sbp2_status[20]; sense_data[14] = sbp2_status[20];
sense_data[15] = sbp2_status[21]; sense_data[15] = sbp2_status[21];
return sbp2_status[8] & 0x3f; /* return scsi status */ return sbp2_status[8] & 0x3f;
} }
/*
* This function deals with status writes from the SBP-2 device
*/
static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid,
int destid, quadlet_t *data, u64 addr, int destid, quadlet_t *data, u64 addr,
size_t length, u16 fl) size_t length, u16 fl)
...@@ -1981,10 +1803,8 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, ...@@ -1981,10 +1803,8 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid,
SBP2_ERR("host info is NULL - this is bad!"); SBP2_ERR("host info is NULL - this is bad!");
return RCODE_ADDRESS_ERROR; return RCODE_ADDRESS_ERROR;
} }
/*
* Find our scsi_id structure by looking at the status fifo address /* Find the unit which wrote the status. */
* written to by the sbp2 device.
*/
list_for_each_entry(scsi_id_tmp, &hi->scsi_ids, scsi_list) { list_for_each_entry(scsi_id_tmp, &hi->scsi_ids, scsi_list) {
if (scsi_id_tmp->ne->nodeid == nodeid && if (scsi_id_tmp->ne->nodeid == nodeid &&
scsi_id_tmp->status_fifo_addr == addr) { scsi_id_tmp->status_fifo_addr == addr) {
...@@ -1997,20 +1817,16 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, ...@@ -1997,20 +1817,16 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid,
return RCODE_ADDRESS_ERROR; return RCODE_ADDRESS_ERROR;
} }
/* /* Put response into scsi_id status fifo buffer. The first two bytes
* Put response into scsi_id status fifo buffer. The first two bytes
* come in big endian bit order. Often the target writes only a * come in big endian bit order. Often the target writes only a
* truncated status block, minimally the first two quadlets. The rest * truncated status block, minimally the first two quadlets. The rest
* is implied to be zeros. * is implied to be zeros. */
*/
sb = &scsi_id->status_block; sb = &scsi_id->status_block;
memset(sb->command_set_dependent, 0, sizeof(sb->command_set_dependent)); memset(sb->command_set_dependent, 0, sizeof(sb->command_set_dependent));
memcpy(sb, data, length); memcpy(sb, data, length);
sbp2util_be32_to_cpu_buffer(sb, 8); sbp2util_be32_to_cpu_buffer(sb, 8);
/* /* Ignore unsolicited status. Handle command ORB status. */
* Ignore unsolicited status. Handle command ORB status.
*/
if (unlikely(STATUS_GET_SRC(sb->ORB_offset_hi_misc) == 2)) if (unlikely(STATUS_GET_SRC(sb->ORB_offset_hi_misc) == 2))
command = NULL; command = NULL;
else else
...@@ -2023,10 +1839,7 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, ...@@ -2023,10 +1839,7 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid,
pci_dma_sync_single_for_cpu(hi->host->pdev, command->sge_dma, pci_dma_sync_single_for_cpu(hi->host->pdev, command->sge_dma,
sizeof(command->scatter_gather_element), sizeof(command->scatter_gather_element),
PCI_DMA_BIDIRECTIONAL); PCI_DMA_BIDIRECTIONAL);
/* /* Grab SCSI command pointers and check status. */
* Matched status with command, now grab scsi command pointers
* and check status.
*/
/* /*
* FIXME: If the src field in the status is 1, the ORB DMA must * FIXME: If the src field in the status is 1, the ORB DMA must
* not be reused until status for a subsequent ORB is received. * not be reused until status for a subsequent ORB is received.
...@@ -2048,37 +1861,28 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, ...@@ -2048,37 +1861,28 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid,
SBP2_SCSI_STATUS_BUSY : SBP2_SCSI_STATUS_BUSY :
SBP2_SCSI_STATUS_COMMAND_TERMINATED; SBP2_SCSI_STATUS_COMMAND_TERMINATED;
} }
/*
* See if the target stored any scsi status information.
*/
if (STATUS_GET_LEN(h) > 1) if (STATUS_GET_LEN(h) > 1)
scsi_status = sbp2_status_to_sense_data( scsi_status = sbp2_status_to_sense_data(
(unchar *)sb, SCpnt->sense_buffer); (unchar *)sb, SCpnt->sense_buffer);
/*
* Check to see if the dead bit is set. If so, we'll
* have to initiate a fetch agent reset.
*/
if (STATUS_TEST_DEAD(h)) if (STATUS_TEST_DEAD(h))
sbp2_agent_reset(scsi_id, 0); sbp2_agent_reset(scsi_id, 0);
} }
/* /* Check here to see if there are no commands in-use. If there
* Check here to see if there are no commands in-use. If there
* are none, we know that the fetch agent left the active state * are none, we know that the fetch agent left the active state
* _and_ that we did not reactivate it yet. Therefore clear * _and_ that we did not reactivate it yet. Therefore clear
* last_orb so that next time we write directly to the * last_orb so that next time we write directly to the
* ORB_POINTER register. That way the fetch agent does not need * ORB_POINTER register. That way the fetch agent does not need
* to refetch the next_ORB. * to refetch the next_ORB. */
*/
spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags);
if (list_empty(&scsi_id->sbp2_command_orb_inuse)) if (list_empty(&scsi_id->sbp2_command_orb_inuse))
scsi_id->last_orb = NULL; scsi_id->last_orb = NULL;
spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
} else { } else {
/* /* It's probably status after a management request. */
* It's probably a login/logout/reconnect status.
*/
if ((sb->ORB_offset_lo == scsi_id->reconnect_orb_dma) || if ((sb->ORB_offset_lo == scsi_id->reconnect_orb_dma) ||
(sb->ORB_offset_lo == scsi_id->login_orb_dma) || (sb->ORB_offset_lo == scsi_id->login_orb_dma) ||
(sb->ORB_offset_lo == scsi_id->query_logins_orb_dma) || (sb->ORB_offset_lo == scsi_id->query_logins_orb_dma) ||
...@@ -2098,10 +1902,6 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, ...@@ -2098,10 +1902,6 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid,
* SCSI interface related section * SCSI interface related section
**************************************/ **************************************/
/*
* This routine is the main request entry routine for doing I/O. It is
* called from the scsi stack directly.
*/
static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt, static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt,
void (*done)(struct scsi_cmnd *)) void (*done)(struct scsi_cmnd *))
{ {
...@@ -2120,17 +1920,13 @@ static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt, ...@@ -2120,17 +1920,13 @@ static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt,
goto done; goto done;
} }
/* /* Multiple units are currently represented to the SCSI core as separate
* Until we handle multiple luns, just return selection time-out * targets, not as one target with multiple LUs. Therefore return
* to any IO directed at non-zero LUNs * selection time-out to any IO directed at non-zero LUNs. */
*/
if (SCpnt->device->lun) if (SCpnt->device->lun)
goto done; goto done;
/* /* handle the request sense command here (auto-request sense) */
* Check for request sense command, and handle it here
* (autorequest sense)
*/
if (SCpnt->cmnd[0] == REQUEST_SENSE) { if (SCpnt->cmnd[0] == REQUEST_SENSE) {
memcpy(SCpnt->request_buffer, SCpnt->sense_buffer, SCpnt->request_bufflen); memcpy(SCpnt->request_buffer, SCpnt->sense_buffer, SCpnt->request_bufflen);
memset(SCpnt->sense_buffer, 0, sizeof(SCpnt->sense_buffer)); memset(SCpnt->sense_buffer, 0, sizeof(SCpnt->sense_buffer));
...@@ -2138,28 +1934,20 @@ static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt, ...@@ -2138,28 +1934,20 @@ static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt,
return 0; return 0;
} }
/*
* Check to see if we are in the middle of a bus reset.
*/
if (!hpsb_node_entry_valid(scsi_id->ne)) { if (!hpsb_node_entry_valid(scsi_id->ne)) {
SBP2_ERR("Bus reset in progress - rejecting command"); SBP2_ERR("Bus reset in progress - rejecting command");
result = DID_BUS_BUSY << 16; result = DID_BUS_BUSY << 16;
goto done; goto done;
} }
/* /* Bidirectional commands are not yet implemented,
* Bidirectional commands are not yet implemented, * and unknown transfer direction not handled. */
* and unknown transfer direction not handled.
*/
if (SCpnt->sc_data_direction == DMA_BIDIRECTIONAL) { if (SCpnt->sc_data_direction == DMA_BIDIRECTIONAL) {
SBP2_ERR("Cannot handle DMA_BIDIRECTIONAL - rejecting command"); SBP2_ERR("Cannot handle DMA_BIDIRECTIONAL - rejecting command");
result = DID_ERROR << 16; result = DID_ERROR << 16;
goto done; goto done;
} }
/*
* Try and send our SCSI command
*/
if (sbp2_send_command(scsi_id, SCpnt, done)) { if (sbp2_send_command(scsi_id, SCpnt, done)) {
SBP2_ERR("Error sending SCSI command"); SBP2_ERR("Error sending SCSI command");
sbp2scsi_complete_command(scsi_id, SBP2_SCSI_STATUS_SELECTION_TIMEOUT, sbp2scsi_complete_command(scsi_id, SBP2_SCSI_STATUS_SELECTION_TIMEOUT,
...@@ -2173,10 +1961,6 @@ static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt, ...@@ -2173,10 +1961,6 @@ static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt,
return 0; return 0;
} }
/*
* This function is called in order to complete all outstanding SBP-2
* commands (in case of resets, etc.).
*/
static void sbp2scsi_complete_all_commands(struct scsi_id_instance_data *scsi_id, static void sbp2scsi_complete_all_commands(struct scsi_id_instance_data *scsi_id,
u32 status) u32 status)
{ {
...@@ -2207,25 +1991,17 @@ static void sbp2scsi_complete_all_commands(struct scsi_id_instance_data *scsi_id ...@@ -2207,25 +1991,17 @@ static void sbp2scsi_complete_all_commands(struct scsi_id_instance_data *scsi_id
} }
/* /*
* This function is called in order to complete a regular SBP-2 command. * Complete a regular SCSI command. Can be called in atomic context.
*
* This can be called in interrupt context.
*/ */
static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id, static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
u32 scsi_status, struct scsi_cmnd *SCpnt, u32 scsi_status, struct scsi_cmnd *SCpnt,
void (*done)(struct scsi_cmnd *)) void (*done)(struct scsi_cmnd *))
{ {
/*
* Sanity
*/
if (!SCpnt) { if (!SCpnt) {
SBP2_ERR("SCpnt is NULL"); SBP2_ERR("SCpnt is NULL");
return; return;
} }
/*
* Switch on scsi status
*/
switch (scsi_status) { switch (scsi_status) {
case SBP2_SCSI_STATUS_GOOD: case SBP2_SCSI_STATUS_GOOD:
SCpnt->result = DID_OK << 16; SCpnt->result = DID_OK << 16;
...@@ -2259,19 +2035,15 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id, ...@@ -2259,19 +2035,15 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
SCpnt->result = DID_ERROR << 16; SCpnt->result = DID_ERROR << 16;
} }
/* /* If a bus reset is in progress and there was an error, complete
* If a bus reset is in progress and there was an error, complete * the command as busy so that it will get retried. */
* the command as busy so that it will get retried.
*/
if (!hpsb_node_entry_valid(scsi_id->ne) if (!hpsb_node_entry_valid(scsi_id->ne)
&& (scsi_status != SBP2_SCSI_STATUS_GOOD)) { && (scsi_status != SBP2_SCSI_STATUS_GOOD)) {
SBP2_ERR("Completing command with busy (bus reset)"); SBP2_ERR("Completing command with busy (bus reset)");
SCpnt->result = DID_BUS_BUSY << 16; SCpnt->result = DID_BUS_BUSY << 16;
} }
/* /* Tell the SCSI stack that we're done with this command. */
* Tell scsi stack that we're done with this command
*/
done(SCpnt); done(SCpnt);
} }
...@@ -2311,8 +2083,8 @@ static void sbp2scsi_slave_destroy(struct scsi_device *sdev) ...@@ -2311,8 +2083,8 @@ static void sbp2scsi_slave_destroy(struct scsi_device *sdev)
} }
/* /*
* Called by scsi stack when something has really gone wrong. Usually * Called by scsi stack when something has really gone wrong.
* called when a command has timed-out for some reason. * Usually called when a command has timed-out for some reason.
*/ */
static int sbp2scsi_abort(struct scsi_cmnd *SCpnt) static int sbp2scsi_abort(struct scsi_cmnd *SCpnt)
{ {
...@@ -2401,7 +2173,6 @@ static int sbp2_module_init(void) ...@@ -2401,7 +2173,6 @@ static int sbp2_module_init(void)
{ {
int ret; int ret;
/* Module load debug option to force one command at a time (serializing I/O) */
if (serialize_io) { if (serialize_io) {
scsi_driver_template.can_queue = 1; scsi_driver_template.can_queue = 1;
scsi_driver_template.cmd_per_lun = 1; scsi_driver_template.cmd_per_lun = 1;
...@@ -2412,16 +2183,13 @@ static int sbp2_module_init(void) ...@@ -2412,16 +2183,13 @@ static int sbp2_module_init(void)
max_sectors = 128 * 1024 / 512; max_sectors = 128 * 1024 / 512;
scsi_driver_template.max_sectors = max_sectors; scsi_driver_template.max_sectors = max_sectors;
/* Register our high level driver with 1394 stack */
hpsb_register_highlevel(&sbp2_highlevel); hpsb_register_highlevel(&sbp2_highlevel);
ret = hpsb_register_protocol(&sbp2_driver); ret = hpsb_register_protocol(&sbp2_driver);
if (ret) { if (ret) {
SBP2_ERR("Failed to register protocol"); SBP2_ERR("Failed to register protocol");
hpsb_unregister_highlevel(&sbp2_highlevel); hpsb_unregister_highlevel(&sbp2_highlevel);
return ret; return ret;
} }
return 0; return 0;
} }
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#define SBP2_DEVICE_NAME "sbp2" #define SBP2_DEVICE_NAME "sbp2"
/* /*
* SBP2 specific structures and defines * SBP-2 specific definitions
*/ */
#define ORB_DIRECTION_WRITE_TO_MEDIA 0x0 #define ORB_DIRECTION_WRITE_TO_MEDIA 0x0
...@@ -185,8 +185,9 @@ struct sbp2_status_block { ...@@ -185,8 +185,9 @@ struct sbp2_status_block {
u8 command_set_dependent[24]; u8 command_set_dependent[24];
} __attribute__((packed)); } __attribute__((packed));
/* /*
* Miscellaneous SBP2 related config rom defines * SBP2 related configuration ROM definitions
*/ */
#define SBP2_UNIT_DIRECTORY_OFFSET_KEY 0xd1 #define SBP2_UNIT_DIRECTORY_OFFSET_KEY 0xd1
...@@ -207,19 +208,17 @@ struct sbp2_status_block { ...@@ -207,19 +208,17 @@ struct sbp2_status_block {
#define SBP2_UNSOLICITED_STATUS_VALUE 0xf #define SBP2_UNSOLICITED_STATUS_VALUE 0xf
#define SBP2_BUSY_TIMEOUT_ADDRESS 0xfffff0000210ULL #define SBP2_BUSY_TIMEOUT_ADDRESS 0xfffff0000210ULL
/* biggest possible value for Single Phase Retry count is 0xf */
#define SBP2_BUSY_TIMEOUT_VALUE 0xf #define SBP2_BUSY_TIMEOUT_VALUE 0xf
#define SBP2_AGENT_RESET_DATA 0xf #define SBP2_AGENT_RESET_DATA 0xf
/*
* Unit spec id and sw version entry for SBP-2 devices
*/
#define SBP2_UNIT_SPEC_ID_ENTRY 0x0000609e #define SBP2_UNIT_SPEC_ID_ENTRY 0x0000609e
#define SBP2_SW_VERSION_ENTRY 0x00010483 #define SBP2_SW_VERSION_ENTRY 0x00010483
/* /*
* SCSI specific stuff * SCSI specific definitions
*/ */
#define SBP2_MAX_SG_ELEMENT_LENGTH 0xf000 #define SBP2_MAX_SG_ELEMENT_LENGTH 0xf000
...@@ -237,18 +236,19 @@ struct sbp2_status_block { ...@@ -237,18 +236,19 @@ struct sbp2_status_block {
#define SBP2_SCSI_STATUS_COMMAND_TERMINATED 0x22 #define SBP2_SCSI_STATUS_COMMAND_TERMINATED 0x22
#define SBP2_SCSI_STATUS_SELECTION_TIMEOUT 0xff #define SBP2_SCSI_STATUS_SELECTION_TIMEOUT 0xff
/* This is the two dma types we use for cmd_dma below */
/*
* Representations of commands and devices
*/
enum cmd_dma_types { enum cmd_dma_types {
CMD_DMA_NONE, CMD_DMA_NONE,
CMD_DMA_PAGE, CMD_DMA_PAGE,
CMD_DMA_SINGLE CMD_DMA_SINGLE
}; };
/* /* Per SCSI command */
* Encapsulates all the info necessary for an outstanding command.
*/
struct sbp2_command_info { struct sbp2_command_info {
struct list_head list; struct list_head list;
struct sbp2_command_orb command_orb ____cacheline_aligned; struct sbp2_command_orb command_orb ____cacheline_aligned;
dma_addr_t command_orb_dma ____cacheline_aligned; dma_addr_t command_orb_dma ____cacheline_aligned;
...@@ -263,18 +263,17 @@ struct sbp2_command_info { ...@@ -263,18 +263,17 @@ struct sbp2_command_info {
enum cmd_dma_types dma_type; enum cmd_dma_types dma_type;
unsigned long dma_size; unsigned long dma_size;
int dma_dir; int dma_dir;
}; };
struct sbp2scsi_host_info; /* Per FireWire host */
struct sbp2scsi_host_info {
struct hpsb_host *host;
struct list_head scsi_ids;
};
/* /* Per logical unit */
* Information needed on a per scsi id basis (one for each sbp2 device)
*/
struct scsi_id_instance_data { struct scsi_id_instance_data {
/* /* Operation request blocks */
* Various sbp2 specific structures
*/
struct sbp2_command_orb *last_orb; struct sbp2_command_orb *last_orb;
dma_addr_t last_orb_dma; dma_addr_t last_orb_dma;
struct sbp2_login_orb *login_orb; struct sbp2_login_orb *login_orb;
...@@ -291,57 +290,49 @@ struct scsi_id_instance_data { ...@@ -291,57 +290,49 @@ struct scsi_id_instance_data {
dma_addr_t logout_orb_dma; dma_addr_t logout_orb_dma;
struct sbp2_status_block status_block; struct sbp2_status_block status_block;
/* /* How to talk to the unit */
* Stuff we need to know about the sbp2 device itself
*/
u64 sbp2_management_agent_addr; u64 sbp2_management_agent_addr;
u64 sbp2_command_block_agent_addr; u64 sbp2_command_block_agent_addr;
u32 speed_code; u32 speed_code;
u32 max_payload_size; u32 max_payload_size;
/* /* Pulled from the device's unit directory */
* Values pulled from the device's unit directory
*/
u32 sbp2_command_set_spec_id; u32 sbp2_command_set_spec_id;
u32 sbp2_command_set; u32 sbp2_command_set;
u32 sbp2_unit_characteristics; u32 sbp2_unit_characteristics;
u32 sbp2_lun; u32 sbp2_lun;
u32 sbp2_firmware_revision; u32 sbp2_firmware_revision;
/* /* Address for the unit to write status blocks to */
* Address for the device to write status blocks to
*/
u64 status_fifo_addr; u64 status_fifo_addr;
/* /* Waitqueue flag for logins, reconnects, logouts, query logins */
* Waitqueue flag for logins, reconnects, logouts, query logins
*/
int access_complete:1; int access_complete:1;
/* /* Pool of command ORBs for this logical unit */
* Pool of command orbs, so we can have more than overlapped command per id
*/
spinlock_t sbp2_command_orb_lock; spinlock_t sbp2_command_orb_lock;
struct list_head sbp2_command_orb_inuse; struct list_head sbp2_command_orb_inuse;
struct list_head sbp2_command_orb_completed; struct list_head sbp2_command_orb_completed;
/* Backlink to FireWire host; list of units attached to the host */
struct sbp2scsi_host_info *hi;
struct list_head scsi_list; struct list_head scsi_list;
/* Node entry, as retrieved from NodeMgr entries */ /* IEEE 1394 core's device representations */
struct node_entry *ne; struct node_entry *ne;
struct unit_directory *ud; struct unit_directory *ud;
/* A backlink to our host_info */ /* SCSI core's device representations */
struct sbp2scsi_host_info *hi;
/* SCSI related pointers */
struct scsi_device *sdev; struct scsi_device *sdev;
struct Scsi_Host *scsi_host; struct Scsi_Host *scsi_host;
/* Device specific workarounds/brokeness */ /* Device specific workarounds/brokeness */
unsigned workarounds; unsigned workarounds;
/* Connection state */
atomic_t state; atomic_t state;
/* For deferred requests to the fetch agent */
struct work_struct protocol_work; struct work_struct protocol_work;
}; };
...@@ -352,13 +343,8 @@ enum sbp2lu_state_types { ...@@ -352,13 +343,8 @@ enum sbp2lu_state_types {
SBP2LU_STATE_IN_SHUTDOWN /* when sbp2_remove was called */ SBP2LU_STATE_IN_SHUTDOWN /* when sbp2_remove was called */
}; };
/* Sbp2 host data structure (one per IEEE1394 host) */ /* For use in scsi_id_instance_data.workarounds and in the corresponding
struct sbp2scsi_host_info { * module load parameter */
struct hpsb_host *host; /* IEEE1394 host */
struct list_head scsi_ids; /* List of scsi ids on this host */
};
/* Flags for detected oddities and brokeness */
#define SBP2_WORKAROUND_128K_MAX_TRANS 0x1 #define SBP2_WORKAROUND_128K_MAX_TRANS 0x1
#define SBP2_WORKAROUND_INQUIRY_36 0x2 #define SBP2_WORKAROUND_INQUIRY_36 0x2
#define SBP2_WORKAROUND_MODE_SENSE_8 0x4 #define SBP2_WORKAROUND_MODE_SENSE_8 0x4
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment