fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * You can obtain a copy of the license at
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * http://www.opensource.org/licenses/cddl1.txt.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * Copyright (c) 2004-2012 Emulex. All rights reserved.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#include <emlxs.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Required for EMLXS_CONTEXT in EMLXS_MSGF calls */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteEMLXS_MSG_DEF(EMLXS_FCP_C);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define EMLXS_GET_VADDR(hba, rp, icmd) emlxs_mem_get_vaddr(hba, rp, \
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan PADDR(icmd->un.cont64[i].addrHigh, icmd->un.cont64[i].addrLow));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanstatic void emlxs_sbp_abort_add(emlxs_port_t *port, emlxs_buf_t *sbp,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan Q *abort, uint8_t *flag, emlxs_buf_t *fpkt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define SCSI3_PERSISTENT_RESERVE_IN 0x5e
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#define SCSI_INQUIRY 0x12
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#define SCSI_RX_DIAG 0x1C
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_handle_fcp_event
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description: Process an FCP Rsp Ring completion
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanemlxs_handle_fcp_event(emlxs_hba_t *hba, CHANNEL *cp, IOCBQ *iocbq)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_config_t *cfg = &CFG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCB *cmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_buf_t *sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_packet_t *pkt = NULL;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#ifdef SAN_DIAG_SUPPORT
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan NODELIST *ndlp;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t iostat;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t localstat;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fcp_rsp_t *rsp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rsp_data_resid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t check_underrun;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t asc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t ascq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t scsi_status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t sense;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t did;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t fix_it;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *scsi_cmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t scsi_opcode;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t scsi_dl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t data_rx;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld uint32_t length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd = &iocbq->iocb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Initialize the status */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iostat = cmd->ULPSTATUS;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte localstat = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_status = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte asc = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ascq = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sense = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte check_underrun = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fix_it = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.FcpEvent++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp = (emlxs_buf_t *)iocbq->sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!sbp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* completion with missing xmit command */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.FcpStray++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_stray_fcp_completion_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "cmd=%x iotag=%d", cmd->ULPCOMMAND, cmd->ULPIOTAG);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.FcpCompleted++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#ifdef SAN_DIAG_SUPPORT
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_update_sd_bucket(sbp);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* SAN_DIAG_SUPPORT */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt = PRIV2PKT(sbp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan did = LE_SWAP24_LO(pkt->pkt_cmd_fhdr.d_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_cmd = (uint8_t *)pkt->pkt_cmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_opcode = scsi_cmd[12];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte data_rx = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Sync data in data buffer only on FC_PKT_FCP_READ */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pkt->pkt_datalen && (pkt->pkt_tran_type == FC_PKT_FCP_READ)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_MPDATA_SYNC(pkt->pkt_data_dma, 0, pkt->pkt_datalen,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte DDI_DMA_SYNC_FORKERNEL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef TEST_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->underrun_counter && (iostat == IOSTAT_SUCCESS) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (pkt->pkt_datalen >= 512)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->underrun_counter--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iostat = IOSTAT_FCP_RSP_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Report 512 bytes missing by adapter */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd->un.fcpi.fcpi_parm = pkt->pkt_datalen - 512;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Corrupt 512 bytes of Data buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((uint8_t *)pkt->pkt_data, 512);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set FCP response to STATUS_GOOD */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((uint8_t *)pkt->pkt_resp, pkt->pkt_rsplen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* TEST_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Process the pkt */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for immediate return */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((iostat == IOSTAT_SUCCESS) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (pkt->pkt_comp) &&
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan !(sbp->pkt_flags &
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (PACKET_ULP_OWNED | PACKET_COMPLETED |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PACKET_IN_COMPLETION | PACKET_IN_TXQ | PACKET_IN_CHIPQ |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PACKET_IN_DONEQ | PACKET_IN_TIMEOUT | PACKET_IN_FLUSH |
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte PACKET_IN_ABORT | PACKET_POLLED))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.FcpGood++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan sbp->pkt_flags |=
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (PACKET_STATE_VALID | PACKET_IN_COMPLETION |
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan PACKET_COMPLETED | PACKET_ULP_OWNED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#if (EMLXS_MODREVX == EMLXS_MODREV2X)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_unswap_pkt(sbp);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* EMLXS_MODREV2X */
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan#ifdef FMA_SUPPORT
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan emlxs_check_dma(hba, sbp);
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan#endif /* FMA_SUPPORT */
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->ulpCmplCmd++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*pkt->pkt_comp) (pkt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan#ifdef FMA_SUPPORT
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan if (hba->flag & FC_DMA_CHECK_ERROR) {
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan emlxs_thread_spawn(hba, emlxs_restart_thread,
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan NULL, NULL);
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan }
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan#endif /* FMA_SUPPORT */
b3660a963b4e1d5319365d4d7c34beb66fb5abc7Sukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * A response is only placed in the resp buffer if IOSTAT_FCP_RSP_ERROR
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * is reported.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Check if a response buffer was not provided */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if ((iostat != IOSTAT_FCP_RSP_ERROR) || (pkt->pkt_rsplen == 0)) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld goto done;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld EMLXS_MPDATA_SYNC(pkt->pkt_resp_dma, 0, pkt->pkt_rsplen,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld DDI_DMA_SYNC_FORKERNEL);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Get the response buffer pointer */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rsp = (fcp_rsp_t *)pkt->pkt_resp;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Validate the response payload */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (!rsp->fcp_u.fcp_status.resid_under &&
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld !rsp->fcp_u.fcp_status.resid_over) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rsp->fcp_resid = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (!rsp->fcp_u.fcp_status.rsp_len_set) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rsp->fcp_response_len = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (!rsp->fcp_u.fcp_status.sense_len_set) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rsp->fcp_sense_len = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld length = sizeof (fcp_rsp_t) + LE_SWAP32(rsp->fcp_response_len) +
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld LE_SWAP32(rsp->fcp_sense_len);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (length > pkt->pkt_rsplen) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld iostat = IOSTAT_RSP_INVALID;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld pkt->pkt_data_resid = pkt->pkt_datalen;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld goto done;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Set the valid response flag */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld sbp->pkt_flags |= PACKET_FCP_RSP_VALID;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld scsi_status = rsp->fcp_u.fcp_status.scsi_status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#ifdef SAN_DIAG_SUPPORT
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld ndlp = (NODELIST *)iocbq->node;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (scsi_status == SCSI_STAT_QUE_FULL) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_log_sd_scsi_event(port, SD_SCSI_SUBCATEGORY_QFULL,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (HBA_WWN *)&ndlp->nlp_portname, sbp->lun);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld } else if (scsi_status == SCSI_STAT_BUSY) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_log_sd_scsi_event(port,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld SD_SCSI_SUBCATEGORY_DEVBSY,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (HBA_WWN *)&ndlp->nlp_portname, sbp->lun);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * Convert a task abort to a check condition with no data
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * transferred. We saw a data corruption when Solaris received
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * a Task Abort from a tape.
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld */
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (scsi_status == SCSI_STAT_TASK_ABORT) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld EMLXS_MSGF(EMLXS_CONTEXT,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld &emlxs_fcp_completion_error_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "Task Abort. "
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "Fixed. did=0x%06x sbp=%p cmd=%02x dl=%d",
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld did, sbp, scsi_opcode, pkt->pkt_datalen);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rsp->fcp_u.fcp_status.scsi_status =
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld SCSI_STAT_CHECK_COND;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rsp->fcp_u.fcp_status.rsp_len_set = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rsp->fcp_u.fcp_status.sense_len_set = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rsp->fcp_u.fcp_status.resid_over = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (pkt->pkt_datalen) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rsp->fcp_u.fcp_status.resid_under = 1;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rsp->fcp_resid =
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld LE_SWAP32(pkt->pkt_datalen);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld } else {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rsp->fcp_u.fcp_status.resid_under = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rsp->fcp_resid = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld scsi_status = SCSI_STAT_CHECK_COND;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * We only need to check underrun if data could
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * have been sent
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Always check underrun if status is good */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (scsi_status == SCSI_STAT_GOOD) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld check_underrun = 1;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Check the sense codes if this is a check condition */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld else if (scsi_status == SCSI_STAT_CHECK_COND) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld check_underrun = 1;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Check if sense data was provided */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (LE_SWAP32(rsp->fcp_sense_len) >= 14) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld sense = *((uint8_t *)rsp + 32 + 2);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld asc = *((uint8_t *)rsp + 32 + 12);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld ascq = *((uint8_t *)rsp + 32 + 13);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld#ifdef SAN_DIAG_SUPPORT
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_log_sd_scsi_check_event(port,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (HBA_WWN *)&ndlp->nlp_portname, sbp->lun,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld scsi_opcode, sense, asc, ascq);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld#endif
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Status is not good and this is not a check condition */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* No data should have been sent */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld else {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld check_underrun = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Initialize the resids */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld pkt->pkt_resp_resid = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld pkt->pkt_data_resid = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Check if no data was to be transferred */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (pkt->pkt_datalen == 0) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld goto done;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Get the residual underrun count reported by the SCSI reply */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rsp_data_resid = (rsp->fcp_u.fcp_status.resid_under) ?
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld LE_SWAP32(rsp->fcp_resid) : 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Set the pkt_data_resid to what the scsi response resid */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld pkt->pkt_data_resid = rsp_data_resid;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Adjust the pkt_data_resid field if needed */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (pkt->pkt_tran_type == FC_PKT_FCP_READ) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * Get the residual underrun count reported by
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * our adapter
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld pkt->pkt_data_resid = cmd->un.fcpi.fcpi_parm;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#ifdef SAN_DIAG_SUPPORT
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if ((rsp_data_resid == 0) && (pkt->pkt_data_resid)) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_log_sd_fc_rdchk_event(port,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (HBA_WWN *)&ndlp->nlp_portname, sbp->lun,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld scsi_opcode, pkt->pkt_data_resid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld#endif
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Get the actual amount of data transferred */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld data_rx = pkt->pkt_datalen - pkt->pkt_data_resid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * If the residual being reported by the adapter is
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * greater than the residual being reported in the
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * reply, then we have a true underrun.
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (check_underrun && (pkt->pkt_data_resid > rsp_data_resid)) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld switch (scsi_opcode) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld case SCSI_INQUIRY:
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld scsi_dl = scsi_cmd[16];
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld break;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld case SCSI_RX_DIAG:
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld scsi_dl =
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (scsi_cmd[15] * 0x100) +
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld scsi_cmd[16];
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld default:
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld scsi_dl = pkt->pkt_datalen;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld#ifdef FCP_UNDERRUN_PATCH1
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeldif (cfg[CFG_ENABLE_PATCH].current & FCP_UNDERRUN_PATCH1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * If status is not good and no data was
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * actually transferred, then we must fix
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * the issue
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if ((scsi_status != SCSI_STAT_GOOD) && (data_rx == 0)) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld fix_it = 1;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld EMLXS_MSGF(EMLXS_CONTEXT,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld &emlxs_fcp_completion_error_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "Underrun(1). Fixed. "
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "did=0x%06x sbp=%p cmd=%02x "
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "dl=%d,%d rx=%d rsp=%d",
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld did, sbp, scsi_opcode,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld pkt->pkt_datalen, scsi_dl,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (pkt->pkt_datalen -
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld pkt->pkt_data_resid),
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rsp_data_resid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld}
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld#endif /* FCP_UNDERRUN_PATCH1 */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld#ifdef FCP_UNDERRUN_PATCH2
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeldif (cfg[CFG_ENABLE_PATCH].current & FCP_UNDERRUN_PATCH2) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (scsi_status == SCSI_STAT_GOOD) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_msg_t *msg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld msg = &emlxs_fcp_completion_error_msg;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * If status is good and this is an
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * inquiry request and the amount of
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * data
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * requested <= data received, then we
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * must fix the issue.
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if ((scsi_opcode == SCSI_INQUIRY) &&
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (pkt->pkt_datalen >= data_rx) &&
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (scsi_dl <= data_rx)) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld fix_it = 1;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld EMLXS_MSGF(EMLXS_CONTEXT, msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "Underrun(2). Fixed. "
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "did=0x%06x sbp=%p "
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "cmd=%02x dl=%d,%d "
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "rx=%d rsp=%d",
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld did, sbp, scsi_opcode,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld pkt->pkt_datalen, scsi_dl,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld data_rx, rsp_data_resid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * If status is good and this is an
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * inquiry request and the amount of
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * data requested >= 128 bytes, but
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * only 128 bytes were received,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * then we must fix the issue.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld else if ((scsi_opcode == SCSI_INQUIRY) &&
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (pkt->pkt_datalen >= 128) &&
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (scsi_dl >= 128) && (data_rx == 128)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fix_it = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld EMLXS_MSGF(EMLXS_CONTEXT, msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "Underrun(3). Fixed. "
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "did=0x%06x sbp=%p "
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "cmd=%02x dl=%d,%d "
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "rx=%d rsp=%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte did, sbp, scsi_opcode,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt->pkt_datalen, scsi_dl,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld data_rx, rsp_data_resid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan}
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld#endif /* FCP_UNDERRUN_PATCH2 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * Check if SCSI response payload should be
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * fixed or if a DATA_UNDERRUN should be
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * reported
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (fix_it) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * Fix the SCSI response payload itself
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rsp->fcp_u.fcp_status.resid_under = 1;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rsp->fcp_resid =
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld LE_SWAP32(pkt->pkt_data_resid);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld } else {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * Change the status from
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * IOSTAT_FCP_RSP_ERROR to
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * IOSTAT_DATA_UNDERRUN
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld iostat = IOSTAT_DATA_UNDERRUN;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld pkt->pkt_data_resid =
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld pkt->pkt_datalen;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * If the residual being reported by the adapter is
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * less than the residual being reported in the reply,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * then we have a true overrun. Since we don't know
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * where the extra data came from or went to then we
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * cannot trust anything we received
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld else if (rsp_data_resid > pkt->pkt_data_resid) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * Change the status from
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * IOSTAT_FCP_RSP_ERROR to
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * IOSTAT_DATA_OVERRUN
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld iostat = IOSTAT_DATA_OVERRUN;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld pkt->pkt_data_resid = pkt->pkt_datalen;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld } else if ((hba->sli_mode == EMLXS_HBA_SLI4_MODE) &&
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (pkt->pkt_tran_type == FC_PKT_FCP_WRITE)) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * Get the residual underrun count reported by
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * our adapter
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld pkt->pkt_data_resid = cmd->un.fcpi.fcpi_parm;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld#ifdef SAN_DIAG_SUPPORT
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if ((rsp_data_resid == 0) && (pkt->pkt_data_resid)) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_log_sd_fc_rdchk_event(port,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (HBA_WWN *)&ndlp->nlp_portname, sbp->lun,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld scsi_opcode, pkt->pkt_data_resid);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld#endif /* SAN_DIAG_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Get the actual amount of data transferred */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld data_rx = pkt->pkt_datalen - pkt->pkt_data_resid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * If the residual being reported by the adapter is
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * greater than the residual being reported in the
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * reply, then we have a true underrun.
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (check_underrun && (pkt->pkt_data_resid > rsp_data_resid)) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld scsi_dl = pkt->pkt_datalen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld#ifdef FCP_UNDERRUN_PATCH1
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeldif (cfg[CFG_ENABLE_PATCH].current & FCP_UNDERRUN_PATCH1) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * If status is not good and no data was
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * actually transferred, then we must fix
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * the issue
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if ((scsi_status != SCSI_STAT_GOOD) && (data_rx == 0)) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld fix_it = 1;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld EMLXS_MSGF(EMLXS_CONTEXT,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld &emlxs_fcp_completion_error_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "Underrun(1). Fixed. "
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "did=0x%06x sbp=%p cmd=%02x "
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "dl=%d,%d rx=%d rsp=%d",
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld did, sbp, scsi_opcode,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld pkt->pkt_datalen, scsi_dl,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (pkt->pkt_datalen -
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld pkt->pkt_data_resid),
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rsp_data_resid);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld}
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld#endif /* FCP_UNDERRUN_PATCH1 */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * Check if SCSI response payload should be
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * fixed or if a DATA_UNDERRUN should be
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * reported
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (fix_it) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * Fix the SCSI response payload itself
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rsp->fcp_u.fcp_status.resid_under = 1;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rsp->fcp_resid =
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld LE_SWAP32(pkt->pkt_data_resid);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Change the status from
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * IOSTAT_FCP_RSP_ERROR to
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * IOSTAT_DATA_UNDERRUN
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld iostat = IOSTAT_DATA_UNDERRUN;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld pkt->pkt_data_resid =
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld pkt->pkt_datalen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * If the residual being reported by the adapter is
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * less than the residual being reported in the reply,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * then we have a true overrun. Since we don't know
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * where the extra data came from or went to then we
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * cannot trust anything we received
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld else if (rsp_data_resid > pkt->pkt_data_resid) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * Change the status from
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * IOSTAT_FCP_RSP_ERROR to
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * IOSTAT_DATA_OVERRUN
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld iostat = IOSTAT_DATA_OVERRUN;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld pkt->pkt_data_resid = pkt->pkt_datalen;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfelddone:
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Print completion message */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (iostat) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IOSTAT_SUCCESS:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Build SCSI GOOD status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pkt->pkt_rsplen) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((uint8_t *)pkt->pkt_resp, pkt->pkt_rsplen);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IOSTAT_FCP_RSP_ERROR:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IOSTAT_REMOTE_STOP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fcp_completion_error_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "Remote Stop. did=0x%06x sbp=%p cmd=%02x", did, sbp,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan scsi_opcode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IOSTAT_LOCAL_REJECT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte localstat = cmd->un.grsp.perr.statLocalError;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (localstat) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IOERR_SEQUENCE_TIMEOUT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &emlxs_fcp_completion_error_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "Local reject. "
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "%s did=0x%06x sbp=%p cmd=%02x tmo=%d ",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_error_xlate(localstat), did, sbp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scsi_opcode, pkt->pkt_timeout);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &emlxs_fcp_completion_error_msg,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore "Local reject. %s 0x%06x %p %02x (%x)(%x)",
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_error_xlate(localstat), did, sbp,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore scsi_opcode, (uint16_t)cmd->ULPIOTAG,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore (uint16_t)cmd->ULPCONTEXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IOSTAT_NPORT_RJT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fcp_completion_error_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "Nport reject. did=0x%06x sbp=%p cmd=%02x", did, sbp,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan scsi_opcode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IOSTAT_FABRIC_RJT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fcp_completion_error_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "Fabric reject. did=0x%06x sbp=%p cmd=%02x", did, sbp,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan scsi_opcode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IOSTAT_NPORT_BSY:
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#ifdef SAN_DIAG_SUPPORT
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan ndlp = (NODELIST *)iocbq->node;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_log_sd_fc_bsy_event(port, (HBA_WWN *)&ndlp->nlp_portname);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fcp_completion_error_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "Nport busy. did=0x%06x sbp=%p cmd=%02x", did, sbp,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan scsi_opcode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IOSTAT_FABRIC_BSY:
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#ifdef SAN_DIAG_SUPPORT
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan ndlp = (NODELIST *)iocbq->node;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_log_sd_fc_bsy_event(port, NULL);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fcp_completion_error_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "Fabric busy. did=0x%06x sbp=%p cmd=%02x", did, sbp,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan scsi_opcode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IOSTAT_INTERMED_RSP:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fcp_completion_error_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "Intermediate response. did=0x%06x sbp=%p cmd=%02x", did,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan sbp, scsi_opcode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IOSTAT_LS_RJT:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fcp_completion_error_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "LS Reject. did=0x%06x sbp=%p cmd=%02x", did, sbp,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan scsi_opcode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IOSTAT_DATA_UNDERRUN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fcp_completion_error_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "Underrun. did=0x%06x sbp=%p cmd=%02x "
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "dl=%d,%d rx=%d rsp=%d (%02x,%02x,%02x,%02x)",
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan did, sbp, scsi_opcode, pkt->pkt_datalen, scsi_dl, data_rx,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan rsp_data_resid, scsi_status, sense, asc, ascq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case IOSTAT_DATA_OVERRUN:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fcp_completion_error_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "Overrun. did=0x%06x sbp=%p cmd=%02x "
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "dl=%d,%d rx=%d rsp=%d (%02x,%02x,%02x,%02x)",
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan did, sbp, scsi_opcode, pkt->pkt_datalen, scsi_dl, data_rx,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan rsp_data_resid, scsi_status, sense, asc, ascq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld case IOSTAT_RSP_INVALID:
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fcp_completion_error_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "Rsp Invalid. did=0x%06x sbp=%p cmd=%02x dl=%d rl=%d"
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "(%d, %d, %d)",
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld did, sbp, scsi_opcode, pkt->pkt_datalen, pkt->pkt_rsplen,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld LE_SWAP32(rsp->fcp_resid),
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld LE_SWAP32(rsp->fcp_sense_len),
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld LE_SWAP32(rsp->fcp_response_len));
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld break;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fcp_completion_error_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unknown status=%x reason=%x did=0x%06x sbp=%p cmd=%02x",
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan iostat, cmd->un.grsp.perr.statLocalError, did, sbp,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan scsi_opcode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iostat == IOSTAT_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.FcpGood++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.FcpError++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pkt_complete(sbp, iostat, localstat, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_handle_fcp_event() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_post_buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This routine will post count buffers to the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ring with the QUE_RING_BUF_CN command. This
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allows 2 buffers / command to be posted.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns the number of buffers NOT posted.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan/* SLI3 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_post_buffer(emlxs_hba_t *hba, RING *rp, int16_t cnt)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCB *icmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MATCHMAP *mp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t tag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t maxqbuf;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t seg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t size;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte maxqbuf = 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tag = (uint16_t)cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt += rp->fc_missbufcnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (rp->ringno == hba->channel_els) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seg = MEM_BUF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = MEM_ELSBUF_SIZE;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else if (rp->ringno == hba->channel_ip) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seg = MEM_IPBUF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = MEM_IPBUF_SIZE;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else if (rp->ringno == hba->channel_ct) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seg = MEM_CTBUF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = MEM_CTBUF_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef SFCT_SUPPORT
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan else if (rp->ringno == hba->CHANNEL_FCT) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte seg = MEM_FCTBUF;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte size = MEM_FCTBUF_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* SFCT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * While there are buffers to post
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (cnt) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if ((iocbq = (IOCBQ *)emlxs_mem_get(hba, MEM_IOCB)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rp->fc_missbufcnt = cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq->channel = (void *)&hba->chan[rp->ringno];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->port = (void *)port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->flag |= (IOCB_PRIORITY | IOCB_SPECIAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte icmd = &iocbq->iocb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Max buffers can be posted per command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < maxqbuf; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cnt <= 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* fill in BDEs for command */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if ((mp = (MATCHMAP *)emlxs_mem_get(hba, seg))
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan == 0) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPBDECOUNT = i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0; j < i; j++) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mp = EMLXS_GET_VADDR(hba, rp, icmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mp) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_mem_put(hba, seg,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore (void *)mp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rp->fc_missbufcnt = cnt + i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_mem_put(hba, MEM_IOCB, (void *)iocbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (cnt + i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * map that page and save the address pair for lookup
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * later
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_mem_map_vaddr(hba,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan rp,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t *)&icmd->un.cont64[i].addrHigh,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint32_t *)&icmd->un.cont64[i].addrLow);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte icmd->un.cont64[i].tus.f.bdeSize = size;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPCOMMAND = CMD_QUE_RING_BUF64_CN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_sli_detail_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * "UB Post: ring=%d addr=%08x%08x size=%d",
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * rp->ringno, icmd->un.cont64[i].addrHigh,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * icmd->un.cont64[i].addrLow, size);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPIOTAG = tag;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPBDECOUNT = i;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPLE = 1;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPOWNER = OWN_CHIP;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* used for delimiter between commands */
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore iocbq->bp = (void *)mp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_SLI_ISSUE_IOCB_CMD(hba, &hba->chan[rp->ringno], iocbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rp->fc_missbufcnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_post_buffer() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeldstatic void
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeldemlxs_fcp_tag_nodes(emlxs_port_t *port)
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld{
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld NODELIST *nlp;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld int i;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* We will process all nodes with this tag later */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rw_enter(&port->node_rwlock, RW_READER);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld for (i = 0; i < EMLXS_NUM_HASH_QUES; i++) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld nlp = port->node_table[i];
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld while (nlp != NULL) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld nlp->nlp_tag = 1;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld nlp = nlp->nlp_list_next;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rw_exit(&port->node_rwlock);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld}
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeldstatic NODELIST *
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeldemlxs_find_tagged_node(emlxs_port_t *port)
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld{
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld NODELIST *nlp;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld NODELIST *tagged;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld int i;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Find first node */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rw_enter(&port->node_rwlock, RW_READER);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld tagged = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld for (i = 0; i < EMLXS_NUM_HASH_QUES; i++) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld nlp = port->node_table[i];
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld while (nlp != NULL) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (!nlp->nlp_tag) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld nlp = nlp->nlp_list_next;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld continue;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld nlp->nlp_tag = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (nlp->nlp_Rpi == FABRIC_RPI) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld nlp = nlp->nlp_list_next;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld continue;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld tagged = nlp;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld break;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (tagged) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld break;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rw_exit(&port->node_rwlock);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld return (tagged);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld}
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_port_offline(emlxs_port_t *port, uint32_t scope)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_config_t *cfg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NODELIST *nlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_affected_id_t *aid;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t mask;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t aff_d_id;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t linkdown;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t vlinkdown;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t action;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t unreg_vpi;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t update;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t adisc_support;
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore uint32_t clear_all;
3be114ed300cd3c74d686e19db5d0638cec49ad4Sukumar Swaminathan uint8_t format;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Target mode only uses this routine for linkdowns */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if ((port->mode == MODE_TARGET) && (scope != 0xffffffff) &&
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (scope != 0xfeffffff) && (scope != 0xfdffffff)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg = &CFG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte aid = (fc_affected_id_t *)&scope;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte linkdown = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vlinkdown = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unreg_vpi = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte update = 0;
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore clear_all = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(port->flag & EMLXS_PORT_BOUND)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
3be114ed300cd3c74d686e19db5d0638cec49ad4Sukumar Swaminathan format = aid->aff_format;
3be114ed300cd3c74d686e19db5d0638cec49ad4Sukumar Swaminathan
3be114ed300cd3c74d686e19db5d0638cec49ad4Sukumar Swaminathan switch (format) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 0: /* Port */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mask = 0x00ffffff;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 1: /* Area */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mask = 0x00ffff00;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 2: /* Domain */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mask = 0x00ff0000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 3: /* Network */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mask = 0x00000000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DHCHAP_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 0xfe: /* Virtual link down */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mask = 0x00000000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vlinkdown = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* DHCHAP_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 0xff: /* link is down */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mask = 0x00000000;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte linkdown = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld case 0xfd: /* New fabric */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld default:
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld mask = 0x00000000;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld linkdown = 1;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld clear_all = 1;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte aff_d_id = aid->aff_d_id & mask;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * If link is down then this is a hard shutdown and flush
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * If link not down then this is a soft shutdown and flush
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * (e.g. RSCN)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (linkdown) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->flag &= EMLXS_PORT_LINKDOWN_MASK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (port->ulp_statec != FC_STATE_OFFLINE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->ulp_statec = FC_STATE_OFFLINE;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore port->prev_did = port->did;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld port->did = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld port->rdid = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore bcopy(&port->fabric_sparam, &port->prev_fabric_sparam,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore sizeof (SERV_PARM));
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld bzero(&port->fabric_sparam, sizeof (SERV_PARM));
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte update = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_timer_cancel_clean_address(port);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Tell ULP about it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (update) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (port->flag & EMLXS_PORT_BOUND) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (port->vpi == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan &emlxs_link_down_msg, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (port->mode == MODE_INITIATOR) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_fca_link_down(port);
3be114ed300cd3c74d686e19db5d0638cec49ad4Sukumar Swaminathan }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#ifdef SFCT_SUPPORT
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld else if (port->mode == MODE_TARGET) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_fct_link_down(port);
3be114ed300cd3c74d686e19db5d0638cec49ad4Sukumar Swaminathan }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* SFCT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (port->vpi == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan &emlxs_link_down_msg, "*");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unreg_vpi = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DHCHAP_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Stop authentication with all nodes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_dhc_auth_stop(port, NULL);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* DHCHAP_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Flush the base node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_tx_node_flush(port, &port->node_base, 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_chipq_node_flush(port, 0, &port->node_base, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Flush any pending ub buffers */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_ub_flush(port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DHCHAP_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* virtual link down */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (vlinkdown) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (port->ulp_statec != FC_STATE_OFFLINE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->ulp_statec = FC_STATE_OFFLINE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte update = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_timer_cancel_clean_address(port);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Tell ULP about it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (update) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (port->flag & EMLXS_PORT_BOUND) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (port->vpi == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &emlxs_link_down_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Switch authentication failed.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (port->mode == MODE_INITIATOR) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_fca_link_down(port);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef SFCT_SUPPORT
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld else if (port->mode == MODE_TARGET) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_fct_link_down(port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld#endif /* SFCT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (port->vpi == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &emlxs_link_down_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Switch authentication failed. *");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Flush the base node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_tx_node_flush(port, &port->node_base, 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_chipq_node_flush(port, 0, &port->node_base, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* DHCHAP_SUPPORT */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld else {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_timer_cancel_clean_address(port);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (port->mode == MODE_TARGET) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (hba->sli_mode == EMLXS_HBA_SLI4_MODE) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Set the node tags */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_fcp_tag_nodes(port);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld unreg_vpi = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld while ((nlp = emlxs_find_tagged_node(port))) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) emlxs_rpi_pause_notify(port,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld nlp->rpip);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /*
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * In port_online we need to resume
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * these RPIs before we can use them.
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto done;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set the node tags */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_fcp_tag_nodes(port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore if (!clear_all && (hba->flag & FC_ONLINE_MODE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adisc_support = cfg[CFG_ADISC_SUPPORT].current;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adisc_support = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check ADISC support level */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (adisc_support) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 0: /* No support - Flush all IO to all matching nodes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan for (;;) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We need to hold the locks this way because
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * EMLXS_SLI_UNREG_NODE and the flush routines enter the
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * same locks. Also, when we release the lock the list
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * can change out from under us.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Find first node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rw_enter(&port->node_rwlock, RW_READER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte action = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < EMLXS_NUM_HASH_QUES; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nlp = port->node_table[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (nlp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!nlp->nlp_tag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nlp = nlp->nlp_list_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nlp->nlp_tag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check for any device that matches
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * our mask
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((nlp->nlp_DID & mask) == aff_d_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (linkdown) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte action = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan } else { /* Must be an RCSN */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte action = 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nlp = nlp->nlp_list_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (action) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rw_exit(&port->node_rwlock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if nothing was found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (action == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (action == 1) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) EMLXS_SLI_UNREG_NODE(port, nlp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, NULL, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (action == 2) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld EMLXS_SET_DFC_STATE(nlp, NODE_LIMBO);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DHCHAP_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_dhc_auth_stop(port, nlp);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* DHCHAP_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * Close the node for any further normal IO
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * A PLOGI with reopen the node
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_node_close(port, nlp,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->channel_fcp, 60);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_node_close(port, nlp,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->channel_ip, 60);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Flush tx queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_tx_node_flush(port, nlp, 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Flush chip queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_chipq_node_flush(port, 0, nlp, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan case 1: /* Partial support - Flush IO for non-FCP2 matching nodes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (;;) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We need to hold the locks this way because
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * EMLXS_SLI_UNREG_NODE and the flush routines enter the
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * same locks. Also, when we release the lock the list
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * can change out from under us.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rw_enter(&port->node_rwlock, RW_READER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte action = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < EMLXS_NUM_HASH_QUES; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nlp = port->node_table[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (nlp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!nlp->nlp_tag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nlp = nlp->nlp_list_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nlp->nlp_tag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * Check for special FCP2 target device
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * that matches our mask
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((nlp->nlp_fcp_info &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NLP_FCP_TGT_DEVICE) &&
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (nlp-> nlp_fcp_info &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NLP_FCP_2_DEVICE) &&
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (nlp->nlp_DID & mask) ==
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan aff_d_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte action = 3;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check for any other device that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * matches our mask
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if ((nlp->nlp_DID & mask) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte aff_d_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (linkdown) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte action = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan } else { /* Must be an RSCN */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte action = 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nlp = nlp->nlp_list_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (action) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rw_exit(&port->node_rwlock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if nothing was found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (action == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (action == 1) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) EMLXS_SLI_UNREG_NODE(port, nlp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, NULL, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (action == 2) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld EMLXS_SET_DFC_STATE(nlp, NODE_LIMBO);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DHCHAP_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_dhc_auth_stop(port, nlp);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* DHCHAP_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * Close the node for any further normal IO
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * A PLOGI with reopen the node
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_node_close(port, nlp,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->channel_fcp, 60);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_node_close(port, nlp,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->channel_ip, 60);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Flush tx queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_tx_node_flush(port, nlp, 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Flush chip queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_chipq_node_flush(port, 0, nlp, 0);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (action == 3) { /* FCP2 devices */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld EMLXS_SET_DFC_STATE(nlp, NODE_LIMBO);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unreg_vpi = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore if (hba->sli_mode == EMLXS_HBA_SLI4_MODE) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore (void) emlxs_rpi_pause_notify(port,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore nlp->rpip);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore }
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DHCHAP_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_dhc_auth_stop(port, nlp);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* DHCHAP_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * Close the node for any further normal IO
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * An ADISC or a PLOGI with reopen the node
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_node_close(port, nlp,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->channel_fcp, -1);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_node_close(port, nlp, hba->channel_ip,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((linkdown) ? 0 : 60));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Flush tx queues except for FCP ring */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_tx_node_flush(port, nlp,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan &hba->chan[hba->channel_ct], 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_tx_node_flush(port, nlp,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan &hba->chan[hba->channel_els], 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_tx_node_flush(port, nlp,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan &hba->chan[hba->channel_ip], 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Flush chip queues except for FCP ring */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_chipq_node_flush(port,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan &hba->chan[hba->channel_ct], nlp, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_chipq_node_flush(port,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan &hba->chan[hba->channel_els], nlp, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_chipq_node_flush(port,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan &hba->chan[hba->channel_ip], nlp, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 2: /* Full support - Hold FCP IO to FCP target matching nodes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!linkdown && !vlinkdown) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (;;) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We need to hold the locks this way because
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * EMLXS_SLI_UNREG_NODE and the flush routines enter the
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * same locks. Also, when we release the lock the list
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * can change out from under us.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rw_enter(&port->node_rwlock, RW_READER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte action = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < EMLXS_NUM_HASH_QUES; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nlp = port->node_table[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (nlp != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!nlp->nlp_tag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nlp = nlp->nlp_list_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nlp->nlp_tag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check for FCP target device that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * matches our mask
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if ((nlp-> nlp_fcp_info &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NLP_FCP_TGT_DEVICE) &&
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (nlp->nlp_DID & mask) ==
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan aff_d_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte action = 3;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check for any other device that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * matches our mask
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if ((nlp->nlp_DID & mask) ==
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte aff_d_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (linkdown) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte action = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else { /* Must be an RSCN */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte action = 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nlp = nlp->nlp_list_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (action) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rw_exit(&port->node_rwlock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if nothing was found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (action == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (action == 1) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) EMLXS_SLI_UNREG_NODE(port, nlp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NULL, NULL, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (action == 2) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld EMLXS_SET_DFC_STATE(nlp, NODE_LIMBO);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * Close the node for any further normal IO
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * A PLOGI with reopen the node
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_node_close(port, nlp,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->channel_fcp, 60);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_node_close(port, nlp,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->channel_ip, 60);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Flush tx queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_tx_node_flush(port, nlp, 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Flush chip queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_chipq_node_flush(port, 0, nlp, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (action == 3) { /* FCP2 devices */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld EMLXS_SET_DFC_STATE(nlp, NODE_LIMBO);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unreg_vpi = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore if (hba->sli_mode == EMLXS_HBA_SLI4_MODE) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore (void) emlxs_rpi_pause_notify(port,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore nlp->rpip);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore }
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * Close the node for any further normal IO
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * An ADISC or a PLOGI with reopen the node
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_node_close(port, nlp,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->channel_fcp, -1);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_node_close(port, nlp, hba->channel_ip,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((linkdown) ? 0 : 60));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Flush tx queues except for FCP ring */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_tx_node_flush(port, nlp,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan &hba->chan[hba->channel_ct], 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_tx_node_flush(port, nlp,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan &hba->chan[hba->channel_els], 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_tx_node_flush(port, nlp,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan &hba->chan[hba->channel_ip], 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Flush chip queues except for FCP ring */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_chipq_node_flush(port,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan &hba->chan[hba->channel_ct], nlp, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_chipq_node_flush(port,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan &hba->chan[hba->channel_els], nlp, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_chipq_node_flush(port,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan &hba->chan[hba->channel_ip], nlp, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* switch() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore if (unreg_vpi) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore (void) emlxs_mb_unreg_vpi(port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_port_offline() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_port_online(emlxs_port_t *vport)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = vport->hba;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld NODELIST *nlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t state;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t update;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t npiv_linkup;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char topology[32];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char linkspeed[32];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char mode[32];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_link_up_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * "linkup_callback. vpi=%d fc_flag=%x", vport->vpi, hba->flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((vport->vpi > 0) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (!(hba->flag & FC_NPIV_ENABLED) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !(hba->flag & FC_NPIV_SUPPORTED))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(vport->flag & EMLXS_PORT_BOUND) ||
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld !(vport->flag & EMLXS_PORT_ENABLED)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for mode */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (port->mode == MODE_TARGET) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) strlcpy(mode, ", target", sizeof (mode));
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (hba->sli_mode == EMLXS_HBA_SLI4_MODE) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Set the node tags */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_fcp_tag_nodes(vport);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld while ((nlp = emlxs_find_tagged_node(vport))) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* The RPI was paused in port_offline */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) emlxs_rpi_resume_notify(vport,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld nlp->rpip, 0);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld } else if (port->mode == MODE_INITIATOR) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) strlcpy(mode, ", initiator", sizeof (mode));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) strlcpy(mode, "unknown", sizeof (mode));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for loop topology */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->topology == TOPOLOGY_LOOP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte state = FC_STATE_LOOP;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) strlcpy(topology, ", loop", sizeof (topology));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte state = FC_STATE_ONLINE;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) strlcpy(topology, ", fabric", sizeof (topology));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set the link speed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (hba->linkspeed) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 0:
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) strlcpy(linkspeed, "Gb", sizeof (linkspeed));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte state |= FC_STATE_1GBIT_SPEED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case LA_1GHZ_LINK:
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) strlcpy(linkspeed, "1Gb", sizeof (linkspeed));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte state |= FC_STATE_1GBIT_SPEED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case LA_2GHZ_LINK:
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) strlcpy(linkspeed, "2Gb", sizeof (linkspeed));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte state |= FC_STATE_2GBIT_SPEED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case LA_4GHZ_LINK:
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) strlcpy(linkspeed, "4Gb", sizeof (linkspeed));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte state |= FC_STATE_4GBIT_SPEED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case LA_8GHZ_LINK:
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) strlcpy(linkspeed, "8Gb", sizeof (linkspeed));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte state |= FC_STATE_8GBIT_SPEED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case LA_10GHZ_LINK:
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) strlcpy(linkspeed, "10Gb", sizeof (linkspeed));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte state |= FC_STATE_10GBIT_SPEED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld case LA_16GHZ_LINK:
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) strlcpy(linkspeed, "16Gb", sizeof (linkspeed));
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld state |= FC_STATE_16GBIT_SPEED;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) snprintf(linkspeed, sizeof (linkspeed), "unknown(0x%x)",
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld hba->linkspeed);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte npiv_linkup = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte update = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((hba->state >= FC_LINK_UP) &&
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan !(hba->flag & FC_LOOPBACK_MODE) && (vport->ulp_statec != state)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte update = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte vport->ulp_statec = state;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((vport->vpi > 0) && !(hba->flag & FC_NPIV_LINKUP)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->flag |= FC_NPIV_LINKUP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte npiv_linkup = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (update) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vport->flag & EMLXS_PORT_BOUND) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vport->vpi == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_link_up_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "%s%s%s", linkspeed, topology, mode);
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (npiv_linkup) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan &emlxs_npiv_link_up_msg, "%s%s%s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte linkspeed, topology, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (vport->mode == MODE_INITIATOR) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_fca_link_up(vport);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
3be114ed300cd3c74d686e19db5d0638cec49ad4Sukumar Swaminathan#ifdef SFCT_SUPPORT
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld else if (vport->mode == MODE_TARGET) {
3be114ed300cd3c74d686e19db5d0638cec49ad4Sukumar Swaminathan emlxs_fct_link_up(vport);
3be114ed300cd3c74d686e19db5d0638cec49ad4Sukumar Swaminathan }
3be114ed300cd3c74d686e19db5d0638cec49ad4Sukumar Swaminathan#endif /* SFCT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vport->vpi == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_link_up_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "%s%s%s *", linkspeed, topology, mode);
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (npiv_linkup) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan &emlxs_npiv_link_up_msg, "%s%s%s *",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte linkspeed, topology, mode);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for waiting threads */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (vport->vpi == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_LINKUP_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->linkup_wait_flag == TRUE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->linkup_wait_flag = FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cv_broadcast(&EMLXS_LINKUP_CV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_LINKUP_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Flush any pending ub buffers */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_ub_flush(vport);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_port_online() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore/* SLI3 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_linkdown(emlxs_hba_t *hba)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore uint32_t scope;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (hba->state > FC_LINK_DOWN) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan HBASTATS.LinkDown++;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_STATE_CHANGE_LOCKED(hba, FC_LINK_DOWN);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore /* Set scope */
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore scope = (hba->flag & FC_NEW_FABRIC)? 0xFDFFFFFF:0xFFFFFFFF;
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Filter hba flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->flag &= FC_LINKDOWN_MASK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->discovery_timer = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->linkup_timer = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < MAX_VPORTS; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port = &VPORT(i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(port->flag & EMLXS_PORT_BOUND)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore (void) emlxs_port_offline(port, scope);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_log_link_event(port);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_linkdown() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore/* SLI3 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_linkup(emlxs_hba_t *hba)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_config_t *cfg = &CFG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Check for any mode changes */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_mode_set(hba);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBASTATS.LinkUp++;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_STATE_CHANGE_LOCKED(hba, FC_LINK_UP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef MENLO_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & FC_MENLO_MODE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Trigger linkup CV and don't start linkup & discovery
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * timers
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_LINKUP_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cv_broadcast(&EMLXS_LINKUP_CV);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_LINKUP_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_log_link_event(port);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* MENLO_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set the linkup & discovery timers */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->linkup_timer = hba->timer_tics + cfg[CFG_LINKUP_TIMEOUT].current;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan hba->discovery_timer =
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan hba->timer_tics + cfg[CFG_LINKUP_TIMEOUT].current +
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan cfg[CFG_DISC_TIMEOUT].current;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_log_link_event(port);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_linkup() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * emlxs_reset_link
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Called to reset the link with an init_link
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanemlxs_reset_link(emlxs_hba_t *hba, uint32_t linkup, uint32_t wait)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_config_t *cfg;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan MAILBOXQ *mbq = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan MAILBOX *mb = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan int rval = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld int tmo;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan int rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get a buffer to use for the mailbox command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if ((mbq = (MAILBOXQ *)emlxs_mem_get(hba, MEM_MBOX))
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_link_reset_failed_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unable to allocate mailbox buffer.");
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan rval = 1;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan goto reset_link_fail;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore if (linkup) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_link_reset_msg,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore "Resetting link...");
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore } else {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_link_reset_msg,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore "Disabling link...");
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore }
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mb = (MAILBOX *)mbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Bring link down first */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_mb_down_link(hba, mbq);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan#define MBXERR_LINK_DOWN 0x33
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (wait) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wait = MBX_WAIT;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wait = MBX_NOWAIT;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan rc = EMLXS_SLI_ISSUE_MBOX_CMD(hba, mbq, wait, 0);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((rc != MBX_BUSY) && (rc != MBX_SUCCESS) &&
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (rc != MBXERR_LINK_DOWN)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan rval = 1;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan goto reset_link_fail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld tmo = 120;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld do {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld delay(drv_usectohz(500000));
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld tmo--;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (!tmo) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld rval = 1;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_link_reset_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "Linkdown timeout.");
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld goto reset_link_fail;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld } while ((hba->state >= FC_LINK_UP) && (hba->state != FC_ERROR));
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (linkup) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Setup and issue mailbox INITIALIZE LINK command
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (wait == MBX_NOWAIT) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if ((mbq = (MAILBOXQ *)emlxs_mem_get(hba, MEM_MBOX))
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan == NULL) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_MSGF(EMLXS_CONTEXT,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan &emlxs_link_reset_failed_msg,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan "Unable to allocate mailbox buffer.");
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan rval = 1;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan goto reset_link_fail;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mb = (MAILBOX *)mbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Reuse mbq from previous mbox */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mb = (MAILBOX *)mbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cfg = &CFG;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_mb_init_link(hba, mbq,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cfg[CFG_TOPOLOGY].current, cfg[CFG_LINK_SPEED].current);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mb->un.varInitLnk.lipsr_AL_PA = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Clear the loopback mode */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->flag &= ~FC_LOOPBACK_MODE;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan hba->loopback_tics = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan rc = EMLXS_SLI_ISSUE_MBOX_CMD(hba, mbq, wait, 0);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((rc != MBX_BUSY) && (rc != MBX_SUCCESS)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan rval = 1;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan goto reset_link_fail;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_link_reset_msg, NULL);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanreset_link_fail:
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((wait == MBX_WAIT) && mbq) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_mem_put(hba, MEM_MBOX, (void *)mbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan return (rval);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_reset_link() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_online(emlxs_hba_t *hba)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t rval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Make sure adapter is offline or exit trying (30 seconds) */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan while (i++ < 30) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if adapter is already going online */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & (FC_ONLINE_MODE | FC_ONLINING_MODE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check again */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & (FC_ONLINE_MODE | FC_ONLINING_MODE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if adapter is offline */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & FC_OFFLINE_MODE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Mark it going online */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->flag &= ~FC_OFFLINE_MODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->flag |= FC_ONLINING_MODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Currently !FC_ONLINE_MODE and !FC_OFFLINE_MODE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld BUSYWAIT_MS(1000);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_adapter_trans_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Going online...");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (rval = EMLXS_SLI_ONLINE(hba)) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_init_failed_msg, "status=%x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_offline_msg, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set FC_OFFLINE_MODE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->flag |= FC_OFFLINE_MODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->flag &= ~FC_ONLINING_MODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Start the timer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_timer_start(hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set FC_ONLINE_MODE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->flag |= FC_ONLINE_MODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->flag &= ~FC_ONLINING_MODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_online_msg, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef SFCT_SUPPORT
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (port->flag & EMLXS_TGT_ENABLED) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) emlxs_fct_port_initialize(port);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* SFCT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_online() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeldemlxs_offline(emlxs_hba_t *hba, uint32_t reset_requested)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t i = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int rval = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Make sure adapter is online or exit trying (30 seconds) */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan while (i++ < 30) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if adapter is already going offline */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & (FC_OFFLINE_MODE | FC_OFFLINING_MODE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check again */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & (FC_OFFLINE_MODE | FC_OFFLINING_MODE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if adapter is online */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & FC_ONLINE_MODE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Mark it going offline */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->flag &= ~FC_ONLINE_MODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->flag |= FC_OFFLINING_MODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Currently !FC_ONLINE_MODE and !FC_OFFLINE_MODE */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld BUSYWAIT_MS(1000);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_adapter_trans_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "Going offline...");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Declare link down */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (hba->sli_mode == EMLXS_HBA_SLI4_MODE) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) emlxs_fcf_shutdown_notify(port, 1);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld } else {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_linkdown(hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef SFCT_SUPPORT
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (port->flag & EMLXS_TGT_ENABLED) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_fct_port_shutdown(port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* SFCT_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if adapter was shutdown */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & FC_HARDWARE_ERROR) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * Force mailbox cleanup
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * This will wake any sleeping or polling threads
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_mb_fini(hba, NULL, MBX_HARDWARE_ERROR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Pause here for the IO to settle */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte delay(drv_usectohz(1000000)); /* 1 sec */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Unregister all nodes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_ffcleanup(hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->bus_type == SBUS_FC) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan WRITE_SBUS_CSR_REG(hba, FC_SHS_REG(hba), 0x9A);
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan#ifdef FMA_SUPPORT
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Access handle validation */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_CHK_ACC_HANDLE(hba, hba->sli.sli3.sbus_csr_handle);
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan#endif /* FMA_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Stop the timer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_timer_stop(hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* For safety flush every iotag list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (emlxs_iotag_flush(hba)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Pause here for the IO to flush */
728bdc9be5faf84b5dca42f545967bd4910d608eSukumar Swaminathan delay(drv_usectohz(1000));
728bdc9be5faf84b5dca42f545967bd4910d608eSukumar Swaminathan }
728bdc9be5faf84b5dca42f545967bd4910d608eSukumar Swaminathan
728bdc9be5faf84b5dca42f545967bd4910d608eSukumar Swaminathan /* Wait for poll command request to settle */
728bdc9be5faf84b5dca42f545967bd4910d608eSukumar Swaminathan while (hba->io_poll_count > 0) {
728bdc9be5faf84b5dca42f545967bd4910d608eSukumar Swaminathan delay(drv_usectohz(2000000)); /* 2 sec */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
728bdc9be5faf84b5dca42f545967bd4910d608eSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Shutdown the adapter interface */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld EMLXS_SLI_OFFLINE(hba, reset_requested);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->flag |= FC_OFFLINE_MODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->flag &= ~FC_OFFLINING_MODE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_offline_msg, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortedone:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_offline() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_power_down(emlxs_hba_t *hba)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan#ifdef FMA_SUPPORT
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan emlxs_port_t *port = &PPORT;
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan#endif /* FMA_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t rval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if ((rval = emlxs_offline(hba, 0))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_SLI_HBA_RESET(hba, 1, 1, 0);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan#ifdef FMA_SUPPORT
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan if (emlxs_fm_check_acc_handle(hba, hba->pci_acc_handle)
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan != DDI_FM_OK) {
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan EMLXS_MSGF(EMLXS_CONTEXT,
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan &emlxs_invalid_access_handle_msg, NULL);
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan return (1);
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan }
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan#endif /* FMA_SUPPORT */
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* End emlxs_power_down */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_power_up(emlxs_hba_t *hba)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan#ifdef FMA_SUPPORT
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan emlxs_port_t *port = &PPORT;
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan#endif /* FMA_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t rval = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan#ifdef FMA_SUPPORT
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan if (emlxs_fm_check_acc_handle(hba, hba->pci_acc_handle)
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan != DDI_FM_OK) {
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan EMLXS_MSGF(EMLXS_CONTEXT,
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan &emlxs_invalid_access_handle_msg, NULL);
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan return (1);
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan }
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan#endif /* FMA_SUPPORT */
4baa2c25868c5c0ae97aa381b8b1c571c85dc5efSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Bring adapter online */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((rval = emlxs_online(hba))) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore if (hba->pci_cap_offset[PCI_CAP_ID_PM]) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore /* Put chip in D3 state */
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore (void) ddi_put8(hba->pci_acc_handle,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore (uint8_t *)(hba->pci_addr +
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore hba->pci_cap_offset[PCI_CAP_ID_PM] +
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore PCI_PMCSR),
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore (uint8_t)PCI_PMCSR_D3HOT);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rval);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld} /* emlxs_power_up() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NAME: emlxs_ffcleanup
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * FUNCTION: Cleanup all the Firefly resources used by configuring the adapter
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * EXECUTION ENVIRONMENT: process only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CALLED FROM: CFG_TERM
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * INPUT: hba - pointer to the dev_ctl area.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RETURNS: none
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_ffcleanup(emlxs_hba_t *hba)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan uint32_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Disable all but the mailbox interrupt */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_SLI_DISABLE_INTR(hba, HC_MBINT_ENA);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Make sure all port nodes are destroyed */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan for (i = 0; i < MAX_VPORTS; i++) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan port = &VPORT(i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (port->node_count) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) EMLXS_SLI_UNREG_NODE(port, 0, 0, 0, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Clear all interrupt enable conditions */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_SLI_DISABLE_INTR(hba, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_ffcleanup() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint16_t
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanemlxs_register_pkt(CHANNEL *cp, emlxs_buf_t *sbp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t iotag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba = cp->hba;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_FCTAB_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sbp->iotag != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_sli_detail_msg,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan "Pkt already registered! channel=%d iotag=%d sbp=%p",
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp->channel, sbp->iotag, sbp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iotag = 0;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (i = 0; i < hba->max_iotag; i++) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (!hba->fc_iotag || hba->fc_iotag >= hba->max_iotag) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->fc_iotag = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iotag = hba->fc_iotag++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (hba->fc_table[iotag] == 0 ||
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->fc_table[iotag] == STALE_PACKET) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->io_count++;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->fc_table[iotag] = sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->iotag = iotag;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp->channel = cp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iotag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_FCTAB_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_sli_detail_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld * "register_pkt: channel=%d iotag=%d sbp=%p",
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * cp->channelno, iotag, sbp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iotag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_register_pkt() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern emlxs_buf_t *
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanemlxs_unregister_pkt(CHANNEL *cp, uint16_t iotag, uint32_t forced)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_buf_t *sbp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba = cp->hba;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check the iotag range */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((iotag == 0) || (iotag >= hba->max_iotag)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Remove the sbp from the table */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_FCTAB_LOCK);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = hba->fc_table[iotag];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!sbp || (sbp == STALE_PACKET)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_FCTAB_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (sbp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->fc_table[iotag] = ((forced) ? STALE_PACKET : NULL);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->io_count--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->iotag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_FCTAB_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Clean up the sbp */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sbp->pkt_flags & PACKET_IN_TXQ) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->pkt_flags &= ~PACKET_IN_TXQ;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->channel_tx_count--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sbp->pkt_flags & PACKET_IN_CHIPQ) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->pkt_flags &= ~PACKET_IN_CHIPQ;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sbp->bmp) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_mem_put(hba, MEM_BPL, (void *)sbp->bmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->bmp = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mutex_exit(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (sbp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_unregister_pkt() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan/* Flush all IO's to all nodes for a given IO Channel */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanemlxs_tx_channel_flush(emlxs_hba_t *hba, CHANNEL *cp, emlxs_buf_t *fpkt)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_buf_t *sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCB *iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint32_t channelno;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Q abort;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NODELIST *ndlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCB *icmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MATCHMAP *mp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t i;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint8_t flag[MAX_CHANNEL];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan channelno = cp->channelno;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *)&abort, sizeof (Q));
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan bzero((void *)flag, MAX_CHANNEL * sizeof (uint8_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* While a node needs servicing */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan while (cp->nodeq.q_first) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp = (NODELIST *) cp->nodeq.q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if priority queue is not empty */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (ndlp->nlp_ptx[channelno].q_first) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Transfer all iocb's to local queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (abort.q_first == 0) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_first =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_ptx[channelno].q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((IOCBQ *)abort.q_last)->next =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (IOCBQ *)ndlp->nlp_ptx[channelno].q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan flag[channelno] = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_last = ndlp->nlp_ptx[channelno].q_last;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_cnt += ndlp->nlp_ptx[channelno].q_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if tx queue is not empty */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (ndlp->nlp_tx[channelno].q_first) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Transfer all iocb's to local queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (abort.q_first == 0) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_first = ndlp->nlp_tx[channelno].q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((IOCBQ *)abort.q_last)->next =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (IOCBQ *)ndlp->nlp_tx[channelno].q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_last = ndlp->nlp_tx[channelno].q_last;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_cnt += ndlp->nlp_tx[channelno].q_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Clear the queue pointers */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_ptx[channelno].q_first = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_ptx[channelno].q_last = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_ptx[channelno].q_cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_tx[channelno].q_first = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_tx[channelno].q_last = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_tx[channelno].q_cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Remove node from service queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If this is the last node on list */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (cp->nodeq.q_last == (void *)ndlp) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_last = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_first = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Remove node from head */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_first = ndlp->nlp_next[channelno];
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ((NODELIST *)cp->nodeq.q_last)->nlp_next[channelno] =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_first;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Clear node */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_next[channelno] = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* First cleanup the iocb's while still holding the lock */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan iocbq = (IOCBQ *) abort.q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (iocbq) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Free the IoTag and the bmp */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocb = &iocbq->iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (hba->sli_mode == EMLXS_HBA_SLI4_MODE) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = iocbq->sbp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (sbp) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_sli4_free_xri(port, sbp, sbp->xrip, 1);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = emlxs_unregister_pkt((CHANNEL *)iocbq->channel,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPIOTAG, 0);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sbp && (sbp != STALE_PACKET)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->pkt_flags |= PACKET_IN_FLUSH;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the fpkt is already set, then we will leave it
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * alone. This ensures that this pkt is only accounted
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * for on one fpkt->flush_count
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!sbp->fpkt && fpkt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&fpkt->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->fpkt = fpkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fpkt->flush_count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&fpkt->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq = (IOCBQ *)iocbq->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* end of while */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now abort the iocb's */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq = (IOCBQ *)abort.q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (iocbq) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Save the next iocbq for now */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte next = (IOCBQ *)iocbq->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Unlink this iocbq */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the pkt */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp = (emlxs_buf_t *)iocbq->sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sbp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_pkt_flush_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "tx: sbp=%p node=%p", sbp, sbp->node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->state >= FC_LINK_UP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pkt_complete(sbp, IOSTAT_LOCAL_REJECT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOERR_ABORT_REQUESTED, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pkt_complete(sbp, IOSTAT_LOCAL_REJECT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOERR_LINK_DOWN, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Free the iocb and its associated buffers */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte icmd = &iocbq->iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* SLI3 */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (icmd->ULPCOMMAND == CMD_QUE_RING_BUF64_CN ||
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPCOMMAND == CMD_QUE_RING_BUF_CN ||
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPCOMMAND == CMD_QUE_RING_LIST64_CN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((hba->flag &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (FC_ONLINE_MODE | FC_ONLINING_MODE)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* HBA is detaching or offlining */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (icmd->ULPCOMMAND !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CMD_QUE_RING_LIST64_CN) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore void *tmp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan RING *rp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan rp = &hba->sli.sli3.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ring[channelno];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan i < icmd->ULPBDECOUNT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp = EMLXS_GET_VADDR(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba, rp, icmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore tmp = (void *)mp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mp) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_mem_put(
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan hba, MEM_BUF, tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_mem_put(hba, MEM_IOCB,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore (void *)iocbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* repost the unsolicited buffer */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_SLI_ISSUE_IOCB_CMD(hba, cp,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan iocbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else if (icmd->ULPCOMMAND == CMD_CLOSE_XRI_CN ||
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPCOMMAND == CMD_CLOSE_XRI_CX) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_tx_put(iocbq, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq = next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* end of while */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Now trigger channel service */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (channelno = 0; channelno < hba->chan_count; channelno++) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (!flag[channelno]) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan continue;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_SLI_ISSUE_IOCB_CMD(hba, &hba->chan[channelno], 0);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (abort.q_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_tx_channel_flush() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Flush all IO's on all or a given ring for a given node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanemlxs_tx_node_flush(emlxs_port_t *port, NODELIST *ndlp, CHANNEL *chan,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t shutdown, emlxs_buf_t *fpkt)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_buf_t *sbp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint32_t channelno;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan CHANNEL *cp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCB *icmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NODELIST *prev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCB *iocb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Q abort;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MATCHMAP *mp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint8_t flag[MAX_CHANNEL];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *)&abort, sizeof (Q));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Flush all I/O's on tx queue to this target */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!ndlp->nlp_base && shutdown) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp->nlp_active = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (channelno = 0; channelno < hba->chan_count; channelno++) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp = &hba->chan[channelno];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (chan && cp != chan) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!ndlp->nlp_base || shutdown) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if priority queue is not empty */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (ndlp->nlp_ptx[channelno].q_first) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Transfer all iocb's to local queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (abort.q_first == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte abort.q_first =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_ptx[channelno].q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ((IOCBQ *)(abort.q_last))->next =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (IOCBQ *)ndlp->nlp_ptx[channelno].
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan flag[channelno] = 1;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_last = ndlp->nlp_ptx[channelno].q_last;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_cnt += ndlp->nlp_ptx[channelno].q_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if tx queue is not empty */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (ndlp->nlp_tx[channelno].q_first) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Transfer all iocb's to local queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (abort.q_first == 0) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_first = ndlp->nlp_tx[channelno].q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((IOCBQ *)abort.q_last)->next =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (IOCBQ *)ndlp->nlp_tx[channelno].q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_last = ndlp->nlp_tx[channelno].q_last;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_cnt += ndlp->nlp_tx[channelno].q_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Clear the queue pointers */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_ptx[channelno].q_first = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_ptx[channelno].q_last = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_ptx[channelno].q_cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_tx[channelno].q_first = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_tx[channelno].q_last = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_tx[channelno].q_cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* If this node was on the channel queue, remove it */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (ndlp->nlp_next[channelno]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If this is the only node on list */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (cp->nodeq.q_first == (void *)ndlp &&
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_last == (void *)ndlp) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_last = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_first = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_cnt = 0;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else if (cp->nodeq.q_first == (void *)ndlp) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_first = ndlp->nlp_next[channelno];
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ((NODELIST *) cp->nodeq.q_last)->
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp_next[channelno] = cp->nodeq.q_first;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_cnt--;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * This is a little more difficult find the
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * previous node in the circular channel queue
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prev = ndlp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan while (prev->nlp_next[channelno] != ndlp) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan prev = prev->nlp_next[channelno];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan prev->nlp_next[channelno] =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_next[channelno];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (cp->nodeq.q_last == (void *)ndlp) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_last = (void *)prev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Clear node */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_next[channelno] = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* First cleanup the iocb's while still holding the lock */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan iocbq = (IOCBQ *) abort.q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (iocbq) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Free the IoTag and the bmp */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocb = &iocbq->iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (hba->sli_mode == EMLXS_HBA_SLI4_MODE) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = iocbq->sbp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (sbp) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_sli4_free_xri(port, sbp, sbp->xrip, 1);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = emlxs_unregister_pkt((CHANNEL *)iocbq->channel,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPIOTAG, 0);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sbp && (sbp != STALE_PACKET)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->pkt_flags |= PACKET_IN_FLUSH;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the fpkt is already set, then we will leave it
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * alone. This ensures that this pkt is only accounted
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * for on one fpkt->flush_count
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!sbp->fpkt && fpkt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&fpkt->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->fpkt = fpkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fpkt->flush_count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&fpkt->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan iocbq = (IOCBQ *) iocbq->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* end of while */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now abort the iocb's outside the locks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq = (IOCBQ *)abort.q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (iocbq) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Save the next iocbq for now */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte next = (IOCBQ *)iocbq->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Unlink this iocbq */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the pkt */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp = (emlxs_buf_t *)iocbq->sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sbp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_pkt_flush_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "tx: sbp=%p node=%p", sbp, sbp->node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->state >= FC_LINK_UP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pkt_complete(sbp, IOSTAT_LOCAL_REJECT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOERR_ABORT_REQUESTED, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pkt_complete(sbp, IOSTAT_LOCAL_REJECT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOERR_LINK_DOWN, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Free the iocb and its associated buffers */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* CMD_CLOSE_XRI_CN should also free the memory */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte icmd = &iocbq->iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* SLI3 */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (icmd->ULPCOMMAND == CMD_QUE_RING_BUF64_CN ||
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPCOMMAND == CMD_QUE_RING_BUF_CN ||
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPCOMMAND == CMD_QUE_RING_LIST64_CN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((hba->flag &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (FC_ONLINE_MODE | FC_ONLINING_MODE)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* HBA is detaching or offlining */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (icmd->ULPCOMMAND !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CMD_QUE_RING_LIST64_CN) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore void *tmp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan RING *rp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan int ch;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ch = ((CHANNEL *)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq->channel)->channelno;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan rp = &hba->sli.sli3.ring[ch];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan i < icmd->ULPBDECOUNT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp = EMLXS_GET_VADDR(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba, rp, icmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore tmp = (void *)mp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mp) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_mem_put(
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan hba, MEM_BUF, tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_mem_put(hba, MEM_IOCB,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore (void *)iocbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* repost the unsolicited buffer */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_SLI_ISSUE_IOCB_CMD(hba,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (CHANNEL *)iocbq->channel, iocbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else if (icmd->ULPCOMMAND == CMD_CLOSE_XRI_CN ||
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPCOMMAND == CMD_CLOSE_XRI_CX) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /*
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Resend the abort iocbq if any
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_tx_put(iocbq, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq = next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* end of while */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Now trigger channel service */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (channelno = 0; channelno < hba->chan_count; channelno++) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (!flag[channelno]) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan continue;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_SLI_ISSUE_IOCB_CMD(hba, &hba->chan[channelno], 0);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (abort.q_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_tx_node_flush() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Check for IO's on all or a given ring for a given node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanemlxs_tx_node_check(emlxs_port_t *port, NODELIST *ndlp, CHANNEL *chan)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint32_t channelno;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan CHANNEL *cp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Flush all I/O's on tx queue to this target */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (channelno = 0; channelno < hba->chan_count; channelno++) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp = &hba->chan[channelno];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (chan && cp != chan) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if priority queue is not empty */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (ndlp->nlp_ptx[channelno].q_first) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan count += ndlp->nlp_ptx[channelno].q_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if tx queue is not empty */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (ndlp->nlp_tx[channelno].q_first) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan count += ndlp->nlp_tx[channelno].q_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_tx_node_check() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan/* Flush all IO's on the any ring for a given node's lun */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanemlxs_tx_lun_flush(emlxs_port_t *port, NODELIST *ndlp, uint32_t lun,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_buf_t *fpkt)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_buf_t *sbp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint32_t channelno;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *prev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCB *iocb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCB *icmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Q abort;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MATCHMAP *mp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint8_t flag[MAX_CHANNEL];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore if (lun == EMLXS_LUN_NONE) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore return (0);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore }
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *)&abort, sizeof (Q));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Flush I/O's on txQ to this target's lun */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (channelno = 0; channelno < hba->chan_count; channelno++) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Scan the priority queue first */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan prev = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq = (IOCBQ *) ndlp->nlp_ptx[channelno].q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan while (iocbq) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan next = (IOCBQ *)iocbq->next;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb = &iocbq->iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = (emlxs_buf_t *)iocbq->sbp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Check if this IO is for our lun */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (sbp && (sbp->lun == lun)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Remove iocb from the node's ptx queue */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (next == 0) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_ptx[channelno].q_last =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (uint8_t *)prev;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (prev == 0) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_ptx[channelno].q_first =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (uint8_t *)next;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan prev->next = next;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq->next = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_ptx[channelno].q_cnt--;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /*
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Add this iocb to our local abort Q
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (abort.q_first) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ((IOCBQ *)abort.q_last)->next = iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_last = (uint8_t *)iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_cnt++;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_first = (uint8_t *)iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_last = (uint8_t *)iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_cnt = 1;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq->next = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan flag[channelno] = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan prev = iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq = next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } /* while (iocbq) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Scan the regular queue */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan prev = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq = (IOCBQ *)ndlp->nlp_tx[channelno].q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan while (iocbq) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan next = (IOCBQ *)iocbq->next;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb = &iocbq->iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = (emlxs_buf_t *)iocbq->sbp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Check if this IO is for our lun */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (sbp && (sbp->lun == lun)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Remove iocb from the node's tx queue */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (next == 0) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_tx[channelno].q_last =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (uint8_t *)prev;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (prev == 0) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_tx[channelno].q_first =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (uint8_t *)next;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan prev->next = next;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq->next = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ndlp->nlp_tx[channelno].q_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /*
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Add this iocb to our local abort Q
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (abort.q_first) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ((IOCBQ *) abort.q_last)->next = iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_last = (uint8_t *)iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_cnt++;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_first = (uint8_t *)iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_last = (uint8_t *)iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_cnt = 1;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan prev = iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq = next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } /* while (iocbq) */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } /* for loop */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* First cleanup the iocb's while still holding the lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq = (IOCBQ *)abort.q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (iocbq) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Free the IoTag and the bmp */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocb = &iocbq->iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (hba->sli_mode == EMLXS_HBA_SLI4_MODE) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = iocbq->sbp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (sbp) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_sli4_free_xri(port, sbp, sbp->xrip, 1);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = emlxs_unregister_pkt((CHANNEL *)iocbq->channel,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPIOTAG, 0);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sbp && (sbp != STALE_PACKET)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->pkt_flags |= PACKET_IN_FLUSH;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If the fpkt is already set, then we will leave it
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * alone. This ensures that this pkt is only accounted
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * for on one fpkt->flush_count
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!sbp->fpkt && fpkt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&fpkt->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->fpkt = fpkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fpkt->flush_count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&fpkt->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan iocbq = (IOCBQ *) iocbq->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* end of while */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now abort the iocb's outside the locks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq = (IOCBQ *)abort.q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (iocbq) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Save the next iocbq for now */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte next = (IOCBQ *)iocbq->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Unlink this iocbq */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the pkt */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp = (emlxs_buf_t *)iocbq->sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sbp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_pkt_flush_msg,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "tx: sbp=%p node=%p", sbp, sbp->node);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->state >= FC_LINK_UP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pkt_complete(sbp, IOSTAT_LOCAL_REJECT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOERR_ABORT_REQUESTED, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pkt_complete(sbp, IOSTAT_LOCAL_REJECT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOERR_LINK_DOWN, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Free the iocb and its associated buffers */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Should never happen! */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte icmd = &iocbq->iocb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* SLI3 */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (icmd->ULPCOMMAND == CMD_QUE_RING_BUF64_CN ||
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPCOMMAND == CMD_QUE_RING_BUF_CN ||
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPCOMMAND == CMD_QUE_RING_LIST64_CN) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((hba->flag &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (FC_ONLINE_MODE | FC_ONLINING_MODE)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* HBA is detaching or offlining */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (icmd->ULPCOMMAND !=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte CMD_QUE_RING_LIST64_CN) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore void *tmp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan RING *rp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan int ch;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ch = ((CHANNEL *)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq->channel)->channelno;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan rp = &hba->sli.sli3.ring[ch];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan i < icmd->ULPBDECOUNT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mp = EMLXS_GET_VADDR(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba, rp, icmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore tmp = (void *)mp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mp) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_mem_put(
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan hba, MEM_BUF, tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_mem_put(hba, MEM_IOCB,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore (void *)iocbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* repost the unsolicited buffer */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_SLI_ISSUE_IOCB_CMD(hba,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (CHANNEL *)iocbq->channel, iocbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else if (icmd->ULPCOMMAND == CMD_CLOSE_XRI_CN ||
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPCOMMAND == CMD_CLOSE_XRI_CX) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /*
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Resend the abort iocbq if any
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_tx_put(iocbq, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq = next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* end of while */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Now trigger channel service */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (channelno = 0; channelno < hba->chan_count; channelno++) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (!flag[channelno]) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan continue;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_SLI_ISSUE_IOCB_CMD(hba, &hba->chan[channelno], 0);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (abort.q_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_tx_lun_flush() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_tx_put(IOCBQ *iocbq, uint32_t lock)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint32_t channelno;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NODELIST *nlp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan CHANNEL *cp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_buf_t *sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port = (emlxs_port_t *)iocbq->port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba = HBA;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp = (CHANNEL *)iocbq->channel;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nlp = (NODELIST *)iocbq->node;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan channelno = cp->channelno;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp = (emlxs_buf_t *)iocbq->sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nlp == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set node to base node by default */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nlp = &port->node_base;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->node = (void *)nlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sbp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->node = (void *)nlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lock) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!nlp->nlp_active || (sbp && (sbp->pkt_flags & PACKET_IN_ABORT))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sbp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->pkt_flags |= PACKET_IN_FLUSH;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (hba->sli_mode == EMLXS_HBA_SLI4_MODE) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_sli4_free_xri(port, sbp, sbp->xrip, 1);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (void) emlxs_unregister_pkt(cp, sbp->iotag, 0);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lock) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->state >= FC_LINK_UP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pkt_complete(sbp, IOSTAT_LOCAL_REJECT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOERR_ABORT_REQUESTED, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pkt_complete(sbp, IOSTAT_LOCAL_REJECT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOERR_LINK_DOWN, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lock) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_mem_put(hba, MEM_IOCB, (void *)iocbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sbp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if (sbp->pkt_flags &
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (PACKET_IN_COMPLETION | PACKET_IN_CHIPQ | PACKET_IN_TXQ)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lock) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->pkt_flags |= PACKET_IN_TXQ;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->channel_tx_count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check iocbq priority */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Some IOCB has the high priority like reset/close xri etc */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iocbq->flag & IOCB_PRIORITY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Add the iocb to the bottom of the node's ptx queue */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (nlp->nlp_ptx[channelno].q_first) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ((IOCBQ *)nlp->nlp_ptx[channelno].q_last)->next = iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_ptx[channelno].q_last = (uint8_t *)iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_ptx[channelno].q_cnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_ptx[channelno].q_first = (uint8_t *)iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_ptx[channelno].q_last = (uint8_t *)iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_ptx[channelno].q_cnt = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else { /* Normal priority */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Add the iocb to the bottom of the node's tx queue */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (nlp->nlp_tx[channelno].q_first) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ((IOCBQ *)nlp->nlp_tx[channelno].q_last)->next = iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_tx[channelno].q_last = (uint8_t *)iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_tx[channelno].q_cnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_tx[channelno].q_first = (uint8_t *)iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_tx[channelno].q_last = (uint8_t *)iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_tx[channelno].q_cnt = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Check if the node is not already on channel queue and
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * (is not closed or is a priority request)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (!nlp->nlp_next[channelno] &&
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (!(nlp->nlp_flag[channelno] & NLP_CLOSED) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (iocbq->flag & IOCB_PRIORITY))) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* If so, then add it to the channel queue */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (cp->nodeq.q_first) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ((NODELIST *)cp->nodeq.q_last)->nlp_next[channelno] =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)nlp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_next[channelno] = cp->nodeq.q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * If this is not the base node then add it
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * to the tail
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!nlp->nlp_base) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_last = (uint8_t *)nlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else { /* Otherwise, add it to the head */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* The command node always gets priority */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_first = (uint8_t *)nlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_cnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_first = (uint8_t *)nlp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_last = (uint8_t *)nlp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_next[channelno] = nlp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_cnt = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan HBASTATS.IocbTxPut[channelno]++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Adjust the channel timeout timer */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->timeout = hba->timer_tics + 5;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lock) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_tx_put() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern IOCBQ *
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanemlxs_tx_get(CHANNEL *cp, uint32_t lock)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint32_t channelno;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NODELIST *nlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_buf_t *sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba = cp->hba;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan channelno = cp->channelno;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lock) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortebegin:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if a node needs servicing */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (cp->nodeq.q_first) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp = (NODELIST *)cp->nodeq.q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get next iocb from node's priority queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (nlp->nlp_ptx[channelno].q_first) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq = (IOCBQ *)nlp->nlp_ptx[channelno].q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if this is last entry */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (nlp->nlp_ptx[channelno].q_last == (void *)iocbq) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_ptx[channelno].q_first = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_ptx[channelno].q_last = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_ptx[channelno].q_cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Remove iocb from head */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_ptx[channelno].q_first =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)iocbq->next;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_ptx[channelno].q_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get next iocb from node tx queue if node not closed */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan else if (nlp->nlp_tx[channelno].q_first &&
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan !(nlp->nlp_flag[channelno] & NLP_CLOSED)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq = (IOCBQ *)nlp->nlp_tx[channelno].q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if this is last entry */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (nlp->nlp_tx[channelno].q_last == (void *)iocbq) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_tx[channelno].q_first = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_tx[channelno].q_last = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_tx[channelno].q_cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Remove iocb from head */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_tx[channelno].q_first =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void *)iocbq->next;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_tx[channelno].q_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now deal with node itself */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if node still needs servicing */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((nlp->nlp_ptx[channelno].q_first) ||
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (nlp->nlp_tx[channelno].q_first &&
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan !(nlp->nlp_flag[channelno] & NLP_CLOSED))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If this is the base node, then don't shift the
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * pointers. We want to drain the base node before
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * moving on
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!nlp->nlp_base) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Just shift channel queue pointers to next
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * node
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_last = (void *)nlp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_first = nlp->nlp_next[channelno];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Remove node from channel queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* If this is the last node on list */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (cp->nodeq.q_last == (void *)nlp) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_last = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_first = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_cnt = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Remove node from head */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_first = nlp->nlp_next[channelno];
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ((NODELIST *)cp->nodeq.q_last)->
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp_next[channelno] = cp->nodeq.q_first;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->nodeq.q_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Clear node */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_next[channelno] = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * If no iocbq was found on this node, then it will have
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * been removed. So try again.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!iocbq) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto begin;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp = (emlxs_buf_t *)iocbq->sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sbp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * Check flags before we enter mutex in case this
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * has been flushed and destroyed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((sbp->pkt_flags &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (PACKET_IN_COMPLETION | PACKET_IN_CHIPQ)) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !(sbp->pkt_flags & PACKET_IN_TXQ)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto begin;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((sbp->pkt_flags &
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (PACKET_IN_COMPLETION | PACKET_IN_CHIPQ)) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !(sbp->pkt_flags & PACKET_IN_TXQ)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte goto begin;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->pkt_flags &= ~PACKET_IN_TXQ;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->channel_tx_count--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iocbq) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan HBASTATS.IocbTxGet[channelno]++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Adjust the ring timeout timer */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->timeout = (cp->nodeq.q_first) ? (hba->timer_tics + 5) : 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (lock) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iocbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_tx_get() */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan/*
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Remove all cmd from from_rp's txq to to_rp's txq for ndlp.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * The old IoTag has to be released, the new one has to be
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * allocated. Others no change
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * TX_CHANNEL lock is held
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanextern void
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanemlxs_tx_move(NODELIST *ndlp, CHANNEL *from_chan, CHANNEL *to_chan,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint32_t cmd, emlxs_buf_t *fpkt, uint32_t lock)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan{
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_hba_t *hba;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_port_t *port;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint32_t fchanno, tchanno, i;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan IOCBQ *iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan IOCBQ *prev;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan IOCBQ *next;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan IOCB *iocb, *icmd;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan Q tbm; /* To Be Moved Q */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan MATCHMAP *mp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan NODELIST *nlp = ndlp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_buf_t *sbp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan NODELIST *n_prev = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan NODELIST *n_next = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint16_t count = 0;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba = from_chan->hba;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan port = &PPORT;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cmd = cmd; /* To pass lint */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan fchanno = from_chan->channelno;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan tchanno = to_chan->channelno;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (lock) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_TX_CHANNEL_LOCK);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan bzero((void *)&tbm, sizeof (Q));
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Scan the ndlp's fchanno txq to get the iocb of fcp cmd */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan prev = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq = (IOCBQ *)nlp->nlp_tx[fchanno].q_first;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan while (iocbq) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan next = (IOCBQ *)iocbq->next;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Check if this iocb is fcp cmd */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb = &iocbq->iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan switch (iocb->ULPCOMMAND) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* FCP commands */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan case CMD_FCP_ICMND_CR:
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan case CMD_FCP_ICMND_CX:
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan case CMD_FCP_IREAD_CR:
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan case CMD_FCP_IREAD_CX:
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan case CMD_FCP_IWRITE_CR:
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan case CMD_FCP_IWRITE_CX:
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan case CMD_FCP_ICMND64_CR:
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan case CMD_FCP_ICMND64_CX:
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan case CMD_FCP_IREAD64_CR:
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan case CMD_FCP_IREAD64_CX:
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan case CMD_FCP_IWRITE64_CR:
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan case CMD_FCP_IWRITE64_CX:
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* We found a fcp cmd */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan break;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan default:
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* this is not fcp cmd continue */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan prev = iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq = next;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan continue;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* found a fcp cmd iocb in fchanno txq, now deque it */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (next == NULL) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* This is the last iocbq */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_tx[fchanno].q_last =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (uint8_t *)prev;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (prev == NULL) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* This is the first one then remove it from head */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_tx[fchanno].q_first =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (uint8_t *)next;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan prev->next = next;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq->next = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_tx[fchanno].q_cnt--;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Add this iocb to our local toberemovedq */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* This way we donot hold the TX_CHANNEL lock too long */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (tbm.q_first) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ((IOCBQ *)tbm.q_last)->next = iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan tbm.q_last = (uint8_t *)iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan tbm.q_cnt++;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan tbm.q_first = (uint8_t *)iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan tbm.q_last = (uint8_t *)iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan tbm.q_cnt = 1;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq = next;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } /* While (iocbq) */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((tchanno == hba->channel_fcp) && (tbm.q_cnt != 0)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* from_chan->nodeq.q_first must be non NULL */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (from_chan->nodeq.q_first) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* nodeq is not empty, now deal with the node itself */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((nlp->nlp_tx[fchanno].q_first)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (!nlp->nlp_base) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan from_chan->nodeq.q_last =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (void *)nlp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan from_chan->nodeq.q_first =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_next[fchanno];
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan n_prev = (NODELIST *)from_chan->nodeq.q_first;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan count = from_chan->nodeq.q_cnt;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (n_prev == nlp) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* If this is the only node on list */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (from_chan->nodeq.q_last ==
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (void *)nlp) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan from_chan->nodeq.q_last =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan from_chan->nodeq.q_first =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan from_chan->nodeq.q_cnt = 0;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan from_chan->nodeq.q_first =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_next[fchanno];
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ((NODELIST *)from_chan->
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nodeq.q_last)->
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp_next[fchanno] =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan from_chan->nodeq.q_first;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan from_chan->nodeq.q_cnt--;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Clear node */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_next[fchanno] = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan count--;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan do {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan n_next =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan n_prev->nlp_next[fchanno];
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (n_next == nlp) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan break;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan n_prev = n_next;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } while (count--);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (count != 0) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (n_next ==
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (NODELIST *)from_chan->
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nodeq.q_last) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan n_prev->
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp_next[fchanno]
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ((NODELIST *)
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan from_chan->
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nodeq.q_last)->
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp_next
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan [fchanno];
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan from_chan->nodeq.q_last
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan = (uint8_t *)n_prev;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan n_prev->
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp_next[fchanno]
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan n_next-> nlp_next
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan [fchanno];
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan from_chan->nodeq.q_cnt--;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Clear node */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_next[fchanno] =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Now cleanup the iocb's */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan prev = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq = (IOCBQ *)tbm.q_first;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan while (iocbq) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan next = (IOCBQ *)iocbq->next;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Free the IoTag and the bmp */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb = &iocbq->iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (hba->sli_mode == EMLXS_HBA_SLI4_MODE) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = iocbq->sbp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (sbp) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_sli4_free_xri(port, sbp, sbp->xrip, 1);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = emlxs_unregister_pkt((CHANNEL *)iocbq->channel,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPIOTAG, 0);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (sbp && (sbp != STALE_PACKET)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&sbp->mtx);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp->pkt_flags |= PACKET_IN_FLUSH;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /*
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If the fpkt is already set, then we will leave it
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * alone. This ensures that this pkt is only accounted
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * for on one fpkt->flush_count
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (!sbp->fpkt && fpkt) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&fpkt->mtx);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp->fpkt = fpkt;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan fpkt->flush_count++;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&fpkt->mtx);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&sbp->mtx);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq = next;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } /* end of while */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq = (IOCBQ *)tbm.q_first;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan while (iocbq) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Save the next iocbq for now */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan next = (IOCBQ *)iocbq->next;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Unlink this iocbq */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq->next = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Get the pkt */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = (emlxs_buf_t *)iocbq->sbp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (sbp) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_pkt_flush_msg,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan "tx: sbp=%p node=%p", sbp, sbp->node);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (hba->state >= FC_LINK_UP) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_pkt_complete(sbp, IOSTAT_LOCAL_REJECT,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan IOERR_ABORT_REQUESTED, 1);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_pkt_complete(sbp, IOSTAT_LOCAL_REJECT,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan IOERR_LINK_DOWN, 1);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Free the iocb and its associated buffers */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd = &iocbq->iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* SLI3 */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (icmd->ULPCOMMAND == CMD_QUE_RING_BUF64_CN ||
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPCOMMAND == CMD_QUE_RING_BUF_CN ||
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan icmd->ULPCOMMAND == CMD_QUE_RING_LIST64_CN) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((hba->flag &
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (FC_ONLINE_MODE | FC_ONLINING_MODE)) == 0) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* HBA is detaching or offlining */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (icmd->ULPCOMMAND !=
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan CMD_QUE_RING_LIST64_CN) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore void *tmp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan RING *rp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan int ch;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ch = from_chan->channelno;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan rp = &hba->sli.sli3.ring[ch];
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (i = 0;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan i < icmd->ULPBDECOUNT;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan i++) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mp = EMLXS_GET_VADDR(
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba, rp, icmd);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore tmp = (void *)mp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (mp) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_mem_put(
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan MEM_BUF,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan tmp);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_mem_put(hba, MEM_IOCB,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore (void *)iocbq);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* repost the unsolicited buffer */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_SLI_ISSUE_IOCB_CMD(hba,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan from_chan, iocbq);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq = next;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } /* end of while */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Now flush the chipq if any */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (!(nlp->nlp_flag[fchanno] & NLP_CLOSED)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_TX_CHANNEL_LOCK);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (void) emlxs_chipq_node_flush(port, from_chan, nlp, 0);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_TX_CHANNEL_LOCK);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (lock) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_TX_CHANNEL_LOCK);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan return;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_tx_move */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanemlxs_chipq_node_flush(emlxs_port_t *port, CHANNEL *chan, NODELIST *ndlp,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_buf_t *fpkt)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_buf_t *sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Q abort;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan CHANNEL *cp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint32_t channelno;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint8_t flag[MAX_CHANNEL];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t iotag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *)&abort, sizeof (Q));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *)flag, sizeof (flag));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (channelno = 0; channelno < hba->chan_count; channelno++) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp = &hba->chan[channelno];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (chan && cp != chan) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_FCTAB_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (iotag = 1; iotag < hba->max_iotag; iotag++) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = hba->fc_table[iotag];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sbp && (sbp != STALE_PACKET) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (sbp->pkt_flags & PACKET_IN_CHIPQ) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (sbp->node == ndlp) &&
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (sbp->channel == cp) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !(sbp->pkt_flags & PACKET_XRI_CLOSED)) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_sbp_abort_add(port, sbp, &abort, flag,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan fpkt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_FCTAB_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* for */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now put the iocb's on the tx queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq = (IOCBQ *)abort.q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (iocbq) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Save the next iocbq for now */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte next = (IOCBQ *)iocbq->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Unlink this iocbq */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Send this iocbq */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_tx_put(iocbq, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq = next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Now trigger channel service */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (channelno = 0; channelno < hba->chan_count; channelno++) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (!flag[channelno]) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_SLI_ISSUE_IOCB_CMD(hba, &hba->chan[channelno], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (abort.q_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_chipq_node_flush() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Flush all IO's left on all iotag lists */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanextern uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_iotag_flush(emlxs_hba_t *hba)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_buf_t *sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCB *iocb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Q abort;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan CHANNEL *cp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint32_t channelno;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t iotag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count = 0;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (channelno = 0; channelno < hba->chan_count; channelno++) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp = &hba->chan[channelno];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *)&abort, sizeof (Q));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_FCTAB_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (iotag = 1; iotag < hba->max_iotag; iotag++) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = hba->fc_table[iotag];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Check if the slot is empty */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!sbp || (sbp == STALE_PACKET)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* We are building an abort list per channel */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (sbp->channel != cp) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan continue;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore hba->fc_table[iotag] = STALE_PACKET;
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore hba->io_count--;
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore /* Check if IO is valid */
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore if (!(sbp->pkt_flags & PACKET_VALID) ||
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore (sbp->pkt_flags & (PACKET_ULP_OWNED|
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore PACKET_COMPLETED|PACKET_IN_COMPLETION))) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_sli_debug_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "iotag_flush: Invalid IO found. iotag=%d",
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore iotag);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore continue;
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore }
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore sbp->iotag = 0;
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set IOCB status */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq = &sbp->iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocb = &iocbq->iocb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPSTATUS = IOSTAT_LOCAL_REJECT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocb->un.grsp.perr.statLocalError = IOERR_LINK_DOWN;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPLE = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (hba->sli_mode == EMLXS_HBA_SLI4_MODE) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore if (sbp->xrip) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore EMLXS_MSGF(EMLXS_CONTEXT,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore &emlxs_sli_debug_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "iotag_flush: iotag=%d sbp=%p "
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore "xrip=%p state=%x flag=%x",
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore iotag, sbp, sbp->xrip,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore sbp->xrip->state, sbp->xrip->flag);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore } else {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore EMLXS_MSGF(EMLXS_CONTEXT,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore &emlxs_sli_debug_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "iotag_flush: iotag=%d sbp=%p "
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "xrip=NULL", iotag, sbp);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_sli4_free_xri(port, sbp, sbp->xrip, 0);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Clean up the sbp */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&sbp->mtx);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (sbp->pkt_flags & PACKET_IN_TXQ) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp->pkt_flags &= ~PACKET_IN_TXQ;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->channel_tx_count --;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (sbp->pkt_flags & PACKET_IN_CHIPQ) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp->pkt_flags &= ~PACKET_IN_CHIPQ;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (sbp->bmp) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_mem_put(hba, MEM_BPL,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore (void *)sbp->bmp);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp->bmp = 0;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* At this point all nodes are assumed destroyed */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->node = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Add this iocb to our local abort Q */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (abort.q_first) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan ((IOCBQ *)abort.q_last)->next = iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte abort.q_last = (uint8_t *)iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte abort.q_cnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte abort.q_first = (uint8_t *)iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte abort.q_last = (uint8_t *)iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte abort.q_cnt = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_FCTAB_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Trigger deferred completion */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (abort.q_first) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&cp->rsp_lock);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (cp->rsp_head == NULL) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->rsp_head = (IOCBQ *)abort.q_first;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->rsp_tail = (IOCBQ *)abort.q_last;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->rsp_tail->next = (IOCBQ *)abort.q_first;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->rsp_tail = (IOCBQ *)abort.q_last;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&cp->rsp_lock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_thread_trigger2(&cp->intr_thread,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_proc_channel, cp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_sli_debug_msg,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore "iotag_flush: channel=%d count=%d",
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan channelno, abort.q_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count += abort.q_cnt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_iotag_flush() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan/* Checks for IO's on all or a given channel for a given node */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanemlxs_chipq_node_check(emlxs_port_t *port, CHANNEL *chan, NODELIST *ndlp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_buf_t *sbp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan CHANNEL *cp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint32_t channelno;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t count;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t iotag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (channelno = 0; channelno < hba->chan_count; channelno++) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp = &hba->chan[channelno];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (chan && cp != chan) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_FCTAB_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (iotag = 1; iotag < hba->max_iotag; iotag++) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = hba->fc_table[iotag];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sbp && (sbp != STALE_PACKET) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (sbp->pkt_flags & PACKET_IN_CHIPQ) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (sbp->node == ndlp) &&
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (sbp->channel == cp) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !(sbp->pkt_flags & PACKET_XRI_CLOSED)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_FCTAB_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* for */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (count);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_chipq_node_check() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan/* Flush all IO's for a given node's lun (on any channel) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern uint32_t
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanemlxs_chipq_lun_flush(emlxs_port_t *port, NODELIST *ndlp,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint32_t lun, emlxs_buf_t *fpkt)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_buf_t *sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Q abort;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t iotag;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint8_t flag[MAX_CHANNEL];
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint32_t channelno;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore if (lun == EMLXS_LUN_NONE) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore return (0);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore }
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *)flag, sizeof (flag));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero((void *)&abort, sizeof (Q));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_FCTAB_LOCK);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (iotag = 1; iotag < hba->max_iotag; iotag++) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = hba->fc_table[iotag];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sbp && (sbp != STALE_PACKET) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->pkt_flags & PACKET_IN_CHIPQ &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->node == ndlp &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->lun == lun &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte !(sbp->pkt_flags & PACKET_XRI_CLOSED)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_sbp_abort_add(port, sbp,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan &abort, flag, fpkt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_FCTAB_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now put the iocb's on the tx queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq = (IOCBQ *)abort.q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (iocbq) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Save the next iocbq for now */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte next = (IOCBQ *)iocbq->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Unlink this iocbq */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Send this iocbq */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_tx_put(iocbq, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq = next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Now trigger channel service */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (channelno = 0; channelno < hba->chan_count; channelno++) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (!flag[channelno]) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan continue;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_SLI_ISSUE_IOCB_CMD(hba, &hba->chan[channelno], 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (abort.q_cnt);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_chipq_lun_flush() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Issue an ABORT_XRI_CN iocb command to abort an FCP command already issued.
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan * This must be called while holding the EMLXS_FCTAB_LOCK
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern IOCBQ *
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanemlxs_create_abort_xri_cn(emlxs_port_t *port, NODELIST *ndlp,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint16_t iotag, CHANNEL *cp, uint8_t class, int32_t flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCB *iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_wqe_t *wqe;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_buf_t *sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t abort_iotag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if ((iocbq = (IOCBQ *)emlxs_mem_get(hba, MEM_IOCB)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq->channel = (void *)cp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->port = (void *)port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->node = (void *)ndlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->flag |= (IOCB_PRIORITY | IOCB_SPECIAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * set up an iotag using special Abort iotags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((hba->fc_oor_iotag >= EMLXS_MAX_ABORT_TAG)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->fc_oor_iotag = hba->max_iotag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort_iotag = hba->fc_oor_iotag++;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (hba->sli_mode == EMLXS_HBA_SLI4_MODE) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe = &iocbq->wqe;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = hba->fc_table[iotag];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Try to issue abort by XRI if possible */
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore if (sbp == NULL || sbp == STALE_PACKET || sbp->xrip == NULL) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->un.Abort.Criteria = ABORT_REQ_TAG;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->AbortTag = iotag;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->un.Abort.Criteria = ABORT_XRI_TAG;
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore wqe->AbortTag = sbp->xrip->XRI;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->un.Abort.IA = 0;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->RequestTag = abort_iotag;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->Command = CMD_ABORT_XRI_CX;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->Class = CLASS3;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld wqe->CQId = (uint16_t)0xffff; /* default CQ for response */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->CmdType = WQE_TYPE_ABORT;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb = &iocbq->iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPIOTAG = abort_iotag;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->un.acxri.abortType = flag;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->un.acxri.abortContextTag = ndlp->nlp_Rpi;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->un.acxri.abortIoTag = iotag;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPLE = 1;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPCLASS = class;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPCOMMAND = CMD_ABORT_XRI_CN;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPOWNER = OWN_CHIP;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iocbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_create_abort_xri_cn() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan/* This must be called while holding the EMLXS_FCTAB_LOCK */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern IOCBQ *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_create_abort_xri_cx(emlxs_port_t *port, NODELIST *ndlp, uint16_t xid,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan CHANNEL *cp, uint8_t class, int32_t flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCB *iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_wqe_t *wqe;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t abort_iotag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if ((iocbq = (IOCBQ *)emlxs_mem_get(hba, MEM_IOCB)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq->channel = (void *)cp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->port = (void *)port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->node = (void *)ndlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->flag |= (IOCB_PRIORITY | IOCB_SPECIAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * set up an iotag using special Abort iotags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((hba->fc_oor_iotag >= EMLXS_MAX_ABORT_TAG)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->fc_oor_iotag = hba->max_iotag;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort_iotag = hba->fc_oor_iotag++;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (hba->sli_mode == EMLXS_HBA_SLI4_MODE) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe = &iocbq->wqe;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->un.Abort.Criteria = ABORT_XRI_TAG;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->un.Abort.IA = 0;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->RequestTag = abort_iotag;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->AbortTag = xid;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->Command = CMD_ABORT_XRI_CX;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->Class = CLASS3;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld wqe->CQId = (uint16_t)0xffff; /* default CQ for response */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->CmdType = WQE_TYPE_ABORT;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb = &iocbq->iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPCONTEXT = xid;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPIOTAG = abort_iotag;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->un.acxri.abortType = flag;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPLE = 1;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPCLASS = class;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPCOMMAND = CMD_ABORT_XRI_CX;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPOWNER = OWN_CHIP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iocbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_create_abort_xri_cx() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan/* This must be called while holding the EMLXS_FCTAB_LOCK */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern IOCBQ *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_create_close_xri_cn(emlxs_port_t *port, NODELIST *ndlp,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint16_t iotag, CHANNEL *cp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCB *iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_wqe_t *wqe;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_buf_t *sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t abort_iotag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if ((iocbq = (IOCBQ *)emlxs_mem_get(hba, MEM_IOCB)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq->channel = (void *)cp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->port = (void *)port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->node = (void *)ndlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->flag |= (IOCB_PRIORITY | IOCB_SPECIAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * set up an iotag using special Abort iotags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((hba->fc_oor_iotag >= EMLXS_MAX_ABORT_TAG)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->fc_oor_iotag = hba->max_iotag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort_iotag = hba->fc_oor_iotag++;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (hba->sli_mode == EMLXS_HBA_SLI4_MODE) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe = &iocbq->wqe;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = hba->fc_table[iotag];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Try to issue close by XRI if possible */
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore if (sbp == NULL || sbp == STALE_PACKET || sbp->xrip == NULL) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->un.Abort.Criteria = ABORT_REQ_TAG;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->AbortTag = iotag;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->un.Abort.Criteria = ABORT_XRI_TAG;
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore wqe->AbortTag = sbp->xrip->XRI;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->un.Abort.IA = 1;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->RequestTag = abort_iotag;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->Command = CMD_ABORT_XRI_CX;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->Class = CLASS3;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld wqe->CQId = (uint16_t)0xffff; /* default CQ for response */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->CmdType = WQE_TYPE_ABORT;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb = &iocbq->iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPIOTAG = abort_iotag;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->un.acxri.abortType = 0;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->un.acxri.abortContextTag = ndlp->nlp_Rpi;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->un.acxri.abortIoTag = iotag;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPLE = 1;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPCLASS = 0;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPCOMMAND = CMD_CLOSE_XRI_CN;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPOWNER = OWN_CHIP;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iocbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_create_close_xri_cn() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan/* This must be called while holding the EMLXS_FCTAB_LOCK */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern IOCBQ *
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanemlxs_create_close_xri_cx(emlxs_port_t *port, NODELIST *ndlp, uint16_t xid,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan CHANNEL *cp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCB *iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_wqe_t *wqe;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint16_t abort_iotag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if ((iocbq = (IOCBQ *)emlxs_mem_get(hba, MEM_IOCB)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq->channel = (void *)cp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->port = (void *)port;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->node = (void *)ndlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->flag |= (IOCB_PRIORITY | IOCB_SPECIAL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * set up an iotag using special Abort iotags
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((hba->fc_oor_iotag >= EMLXS_MAX_ABORT_TAG)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->fc_oor_iotag = hba->max_iotag;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort_iotag = hba->fc_oor_iotag++;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (hba->sli_mode == EMLXS_HBA_SLI4_MODE) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe = &iocbq->wqe;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->un.Abort.Criteria = ABORT_XRI_TAG;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->un.Abort.IA = 1;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->RequestTag = abort_iotag;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->AbortTag = xid;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->Command = CMD_ABORT_XRI_CX;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->Class = CLASS3;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld wqe->CQId = (uint16_t)0xffff; /* default CQ for response */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan wqe->CmdType = WQE_TYPE_ABORT;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb = &iocbq->iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPCONTEXT = xid;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPIOTAG = abort_iotag;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPLE = 1;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPCLASS = 0;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPCOMMAND = CMD_CLOSE_XRI_CX;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPOWNER = OWN_CHIP;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iocbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_create_close_xri_cx() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amorevoid
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amoreemlxs_close_els_exchange(emlxs_hba_t *hba, emlxs_port_t *port, uint32_t rxid)
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore{
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore CHANNEL *cp;
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore IOCBQ *iocbq;
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore IOCB *iocb;
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore if (rxid == 0 || rxid == 0xFFFF) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore return;
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore }
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore if (hba->sli_mode == EMLXS_HBA_SLI4_MODE) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_unsol_els_msg,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore "Closing ELS exchange: xid=%x", rxid);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (emlxs_sli4_unreserve_xri(port, rxid, 1) == 0) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore return;
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore }
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore }
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore cp = &hba->chan[hba->channel_els];
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore mutex_enter(&EMLXS_FCTAB_LOCK);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore /* Create the abort IOCB */
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore iocbq = emlxs_create_close_xri_cx(port, NULL, rxid, cp);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore mutex_exit(&EMLXS_FCTAB_LOCK);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore if (iocbq) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore iocb = &iocbq->iocb;
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_unsol_els_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "Closing ELS exchange: xid=%x iotag=%d", rxid,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore iocb->ULPIOTAG);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore EMLXS_SLI_ISSUE_IOCB_CMD(hba, cp, iocbq);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore }
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore} /* emlxs_close_els_exchange() */
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathanvoid
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathanemlxs_abort_els_exchange(emlxs_hba_t *hba, emlxs_port_t *port, uint32_t rxid)
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan{
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan CHANNEL *cp;
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan IOCBQ *iocbq;
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan IOCB *iocb;
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan if (rxid == 0 || rxid == 0xFFFF) {
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan return;
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan }
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan if (hba->sli_mode == EMLXS_HBA_SLI4_MODE) {
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_unsol_els_msg,
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan "Aborting ELS exchange: xid=%x", rxid);
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (emlxs_sli4_unreserve_xri(port, rxid, 1) == 0) {
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan /* We have no way to abort unsolicited exchanges */
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan /* that we have not responded to at this time */
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan /* So we will return for now */
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan return;
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan }
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan }
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan cp = &hba->chan[hba->channel_els];
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan mutex_enter(&EMLXS_FCTAB_LOCK);
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan /* Create the abort IOCB */
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan if (hba->state >= FC_LINK_UP) {
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan iocbq = emlxs_create_abort_xri_cx(port, NULL, rxid, cp,
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan CLASS3, ABORT_TYPE_ABTS);
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan } else {
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan iocbq = emlxs_create_close_xri_cx(port, NULL, rxid, cp);
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan }
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan mutex_exit(&EMLXS_FCTAB_LOCK);
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan if (iocbq) {
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan iocb = &iocbq->iocb;
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_unsol_els_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "Aborting ELS exchange: xid=%x iotag=%d", rxid,
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan iocb->ULPIOTAG);
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan EMLXS_SLI_ISSUE_IOCB_CMD(hba, cp, iocbq);
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan }
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan} /* emlxs_abort_els_exchange() */
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan
728bdc9be5faf84b5dca42f545967bd4910d608eSukumar Swaminathanvoid
bb63f56ebeb244bd34f5e8d50900e3420f01b394Sukumar Swaminathanemlxs_abort_ct_exchange(emlxs_hba_t *hba, emlxs_port_t *port, uint32_t rxid)
728bdc9be5faf84b5dca42f545967bd4910d608eSukumar Swaminathan{
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan CHANNEL *cp;
728bdc9be5faf84b5dca42f545967bd4910d608eSukumar Swaminathan IOCBQ *iocbq;
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan IOCB *iocb;
728bdc9be5faf84b5dca42f545967bd4910d608eSukumar Swaminathan
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan if (rxid == 0 || rxid == 0xFFFF) {
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan return;
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (hba->sli_mode == EMLXS_HBA_SLI4_MODE) {
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_unsol_ct_msg,
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan "Aborting CT exchange: xid=%x", rxid);
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (emlxs_sli4_unreserve_xri(port, rxid, 1) == 0) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* We have no way to abort unsolicited exchanges */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* that we have not responded to at this time */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* So we will return for now */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan return;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp = &hba->chan[hba->channel_ct];
728bdc9be5faf84b5dca42f545967bd4910d608eSukumar Swaminathan
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan mutex_enter(&EMLXS_FCTAB_LOCK);
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan
728bdc9be5faf84b5dca42f545967bd4910d608eSukumar Swaminathan /* Create the abort IOCB */
728bdc9be5faf84b5dca42f545967bd4910d608eSukumar Swaminathan if (hba->state >= FC_LINK_UP) {
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan iocbq = emlxs_create_abort_xri_cx(port, NULL, rxid, cp,
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan CLASS3, ABORT_TYPE_ABTS);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq = emlxs_create_close_xri_cx(port, NULL, rxid, cp);
728bdc9be5faf84b5dca42f545967bd4910d608eSukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan mutex_exit(&EMLXS_FCTAB_LOCK);
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan
bb63f56ebeb244bd34f5e8d50900e3420f01b394Sukumar Swaminathan if (iocbq) {
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan iocb = &iocbq->iocb;
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_unsol_els_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "Aborting CT exchange: xid=%x iotag=%d", rxid,
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan iocb->ULPIOTAG);
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_SLI_ISSUE_IOCB_CMD(hba, cp, iocbq);
bb63f56ebeb244bd34f5e8d50900e3420f01b394Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_abort_ct_exchange() */
728bdc9be5faf84b5dca42f545967bd4910d608eSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan/* This must be called while holding the EMLXS_FCTAB_LOCK */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_sbp_abort_add(emlxs_port_t *port, emlxs_buf_t *sbp, Q *abort,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t *flag, emlxs_buf_t *fpkt)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan CHANNEL *cp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NODELIST *ndlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp = (CHANNEL *)sbp->channel;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp = sbp->node;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Create the close XRI IOCB */
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore if (hba->state >= FC_LINK_UP) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore iocbq = emlxs_create_abort_xri_cn(port, ndlp, sbp->iotag, cp,
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore CLASS3, ABORT_TYPE_ABTS);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore } else {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore iocbq = emlxs_create_close_xri_cn(port, ndlp, sbp->iotag, cp);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * Add this iocb to our local abort Q
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * This way we don't hold the CHIPQ lock too long
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iocbq) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (abort->q_first) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan ((IOCBQ *)abort->q_last)->next = iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte abort->q_last = (uint8_t *)iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte abort->q_cnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte abort->q_first = (uint8_t *)iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte abort->q_last = (uint8_t *)iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte abort->q_cnt = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set the flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->pkt_flags |= (PACKET_IN_FLUSH | PACKET_XRI_CLOSED);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->ticks = hba->timer_tics + 10;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->abort_attempts++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan flag[cp->channelno] = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * If the fpkt is already set, then we will leave it alone
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This ensures that this pkt is only accounted for on one
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fpkt->flush_count
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!sbp->fpkt && fpkt) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&fpkt->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->fpkt = fpkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fpkt->flush_count++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&fpkt->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_sbp_abort_add() */