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, ...@@ -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); rval = qla2x00_fabric_login(ha, fcport, next_loopid);
if (rval == QLA_SUCCESS) { 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) { if (rval != QLA_SUCCESS) {
qla2x00_fabric_logout(ha, fcport->loop_id); qla2x00_fabric_logout(ha, fcport->loop_id);
} else { } else {
......
...@@ -1431,35 +1431,37 @@ qla2x00_get_port_database(scsi_qla_host_t *ha, fc_port_t *fcport, uint8_t opt) ...@@ -1431,35 +1431,37 @@ qla2x00_get_port_database(scsi_qla_host_t *ha, fc_port_t *fcport, uint8_t opt)
mcp->flags = MBX_DMA_IN; mcp->flags = MBX_DMA_IN;
mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2);
rval = qla2x00_mailbox_command(ha, mcp); rval = qla2x00_mailbox_command(ha, mcp);
if (rval != QLA_SUCCESS)
goto gpd_error_out;
if (rval == QLA_SUCCESS) { /* Check for logged in state. */
/* Names are little-endian. */ if (pd->master_state != PD_STATE_PORT_LOGGED_IN &&
memcpy(fcport->node_name, pd->node_name, WWN_SIZE); pd->slave_state != PD_STATE_PORT_LOGGED_IN) {
memcpy(fcport->port_name, pd->port_name, WWN_SIZE); rval = QLA_FUNCTION_FAILED;
goto gpd_error_out;
/* Get port_id of device. */
fcport->d_id.b.al_pa = pd->port_id[2];
fcport->d_id.b.area = pd->port_id[3];
fcport->d_id.b.domain = pd->port_id[0];
fcport->d_id.b.rsvd_1 = 0;
/* Check for device require authentication. */
pd->common_features & BIT_5 ? (fcport->flags |= FCF_AUTH_REQ) :
(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) {
fcport->port_type = FCT_INITIATOR;
} 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;
}
} }
/* Names are little-endian. */
memcpy(fcport->node_name, pd->node_name, WWN_SIZE);
memcpy(fcport->port_name, pd->port_name, WWN_SIZE);
/* Get port_id of device. */
fcport->d_id.b.al_pa = pd->port_id[2];
fcport->d_id.b.area = pd->port_id[3];
fcport->d_id.b.domain = pd->port_id[0];
fcport->d_id.b.rsvd_1 = 0;
/* Check for device require authentication. */
pd->common_features & BIT_5 ? (fcport->flags |= FCF_AUTH_REQ) :
(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)
fcport->port_type = FCT_INITIATOR;
else
fcport->port_type = FCT_TARGET;
gpd_error_out:
pci_free_consistent(ha->pdev, PORT_DATABASE_SIZE, pd, pd_dma); pci_free_consistent(ha->pdev, PORT_DATABASE_SIZE, pd, pd_dma);
if (rval != QLA_SUCCESS) { if (rval != QLA_SUCCESS) {
......
...@@ -3428,10 +3428,15 @@ qla2x00_do_dpc(void *data) ...@@ -3428,10 +3428,15 @@ qla2x00_do_dpc(void *data)
fcport->login_retry) { fcport->login_retry) {
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( status = qla2x00_fabric_login(
ha, fcport, &next_loopid); ha, fcport, &next_loopid);
else } else
status = status =
qla2x00_local_device_login( qla2x00_local_device_login(
ha, fcport->loop_id); 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