Commit f3bd0993 authored by Andrew Vasquez's avatar Andrew Vasquez Committed by James Bottomley

[PATCH] [7/18] qla2xxx: Tape command handling fixes

  Fix several tape handling issue:

  1) When the firmware receives the LOGO from the device, any
  active exchanges will be returned with a completion status
  of 0x29 -- this will cause the port to be marked as lost and
  request made to the DPC routine to begin a relogin attempt.
  The problem is, since we've never actually logged out of the
  device and cannot do so in interrupt context, we must be
  sure to perform the logout before the qla2x00_fabric_login()
  in the RELOGIN_NEEDED code.

  2) Sets the Get Port Database options to ZERO when issuing
  the call to qla2x00_get_port_database().  This consolidates
  actuall login handling in the place it should be, in the
  previous qla2x00_fabric_login() call rather than depending
  on any 'hidden' behaviour of the firmware.  If a device did
  a LOGO after the login, then any subsequent exachanges will
  be returned with an 0x29 completion status and the
  RELOGIN_NEEDED code will handle the login.

  3) Finally, if the master and slave state do not indicate a
  logged-in state from the Get Port Database call, then one
  cannot depend on the information returned from the firmware
  -- the firmware typically wipes out the PCB information for
  a given loopID when logged out.  So, return immediately with
  a failed status.
Signed-off-by: default avatarAndrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 1d9cc2e6
......@@ -2886,7 +2886,7 @@ qla2x00_fabric_dev_login(scsi_qla_host_t *ha, fc_port_t *fcport,
rval = qla2x00_fabric_login(ha, fcport, next_loopid);
if (rval == QLA_SUCCESS) {
rval = qla2x00_get_port_database(ha, fcport, BIT_1 | BIT_0);
rval = qla2x00_get_port_database(ha, fcport, 0);
if (rval != QLA_SUCCESS) {
qla2x00_fabric_logout(ha, fcport->loop_id);
} else {
......
......@@ -1431,8 +1431,16 @@ qla2x00_get_port_database(scsi_qla_host_t *ha, fc_port_t *fcport, uint8_t opt)
mcp->flags = MBX_DMA_IN;
mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2);
rval = qla2x00_mailbox_command(ha, mcp);
if (rval != QLA_SUCCESS)
goto gpd_error_out;
/* Check for logged in state. */
if (pd->master_state != PD_STATE_PORT_LOGGED_IN &&
pd->slave_state != PD_STATE_PORT_LOGGED_IN) {
rval = QLA_FUNCTION_FAILED;
goto gpd_error_out;
}
if (rval == QLA_SUCCESS) {
/* Names are little-endian. */
memcpy(fcport->node_name, pd->node_name, WWN_SIZE);
memcpy(fcport->port_name, pd->port_name, WWN_SIZE);
......@@ -1448,18 +1456,12 @@ qla2x00_get_port_database(scsi_qla_host_t *ha, fc_port_t *fcport, uint8_t opt)
(fcport->flags &= ~FCF_AUTH_REQ);
/* If not target must be initiator or unknown type. */
if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0) {
if ((pd->prli_svc_param_word_3[0] & BIT_4) == 0)
fcport->port_type = FCT_INITIATOR;
} else {
else
fcport->port_type = FCT_TARGET;
/* Check for logged in. */
if (pd->master_state != PD_STATE_PORT_LOGGED_IN &&
pd->slave_state != PD_STATE_PORT_LOGGED_IN)
rval = QLA_FUNCTION_FAILED;
}
}
gpd_error_out:
pci_free_consistent(ha->pdev, PORT_DATABASE_SIZE, pd, pd_dma);
if (rval != QLA_SUCCESS) {
......
......@@ -3428,10 +3428,15 @@ qla2x00_do_dpc(void *data)
fcport->login_retry) {
fcport->login_retry--;
if (fcport->flags & FCF_FABRIC_DEVICE)
if (fcport->flags & FCF_FABRIC_DEVICE) {
if (fcport->flags &
FCF_TAPE_PRESENT)
qla2x00_fabric_logout(
ha,
fcport->loop_id);
status = qla2x00_fabric_login(
ha, fcport, &next_loopid);
else
} else
status =
qla2x00_local_device_login(
ha, fcport->loop_id);
......
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