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
93c20f2609342fd05f6625f16dfcb9348e7977f2Sukumar Swaminathan#include <emlxs.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Timer period in seconds */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define EMLXS_TIMER_PERIOD 1 /* secs */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define EMLXS_PKT_PERIOD 5 /* secs */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define EMLXS_UB_PERIOD 60 /* secs */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteEMLXS_MSG_DEF(EMLXS_CLOCK_C);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void emlxs_timer_check_loopback(emlxs_hba_t *hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DHCHAP_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void emlxs_timer_check_dhchap(emlxs_port_t *port);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* DHCHAP_SUPPORT */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeldstatic void emlxs_timer_check_pools(emlxs_hba_t *hba);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanstatic void emlxs_timer(void *arg);
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathanstatic void emlxs_timer_check_fw_update(emlxs_hba_t *hba);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanstatic void emlxs_timer_check_heartbeat(emlxs_hba_t *hba);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanstatic uint32_t emlxs_timer_check_pkts(emlxs_hba_t *hba, uint8_t *flag);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanstatic void emlxs_timer_check_nodes(emlxs_port_t *port, uint8_t *flag);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanstatic void emlxs_timer_check_linkup(emlxs_hba_t *hba);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanstatic void emlxs_timer_check_discovery(emlxs_port_t *port);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeldstatic void emlxs_timer_check_clean_address(emlxs_port_t *port);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanstatic void emlxs_timer_check_ub(emlxs_port_t *port);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanstatic void emlxs_timer_check_channels(emlxs_hba_t *hba, uint8_t *flag);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanstatic uint32_t emlxs_pkt_chip_timeout(emlxs_port_t *port, emlxs_buf_t *sbp,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan Q *abortq, uint8_t *flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef TX_WATCHDOG
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanstatic void emlxs_tx_watchdog(emlxs_hba_t *hba);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* TX_WATCHDOG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern clock_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_timeout(emlxs_hba_t *hba, uint32_t timeout)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_config_t *cfg = &CFG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clock_t time;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set thread timeout */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (cfg[CFG_TIMEOUT_ENABLE].current) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) drv_getparm(LBOLT, &time);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte time += (timeout * drv_usectohz(1000000));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte time = -1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (time);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_timeout() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_timer(void *arg)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = (emlxs_hba_t *)arg;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!hba->timer_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_TIMER_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Only one timer thread is allowed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->timer_flags & EMLXS_TIMER_BUSY) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_TIMER_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if a kill request has been made */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->timer_flags & EMLXS_TIMER_KILL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->timer_id = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld hba->timer_tics = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->timer_flags |= EMLXS_TIMER_ENDED;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_TIMER_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->timer_flags |= (EMLXS_TIMER_BUSY | EMLXS_TIMER_STARTED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->timer_tics = DRV_TIME;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Check io_active count (Safety net) */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (hba->io_active & 0x80000000) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_sli_debug_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "Timer: io_active=0x%x. Reset to zero.", hba->io_active);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld hba->io_active = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_TIMER_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore EMLXS_SLI_POLL_ERRATT(hba);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* Perform standard checks */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_timer_checks(hba);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* Restart the timer */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mutex_enter(&EMLXS_TIMER_LOCK);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan hba->timer_flags &= ~EMLXS_TIMER_BUSY;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* If timer is still enabled, restart it */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if (!(hba->timer_flags & EMLXS_TIMER_KILL)) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan hba->timer_id =
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan timeout(emlxs_timer, (void *)hba,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (EMLXS_TIMER_PERIOD * drv_usectohz(1000000)));
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan } else {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan hba->timer_id = 0;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan hba->timer_flags |= EMLXS_TIMER_ENDED;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan mutex_exit(&EMLXS_TIMER_LOCK);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan return;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_timer() */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanextern void
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanemlxs_timer_checks(emlxs_hba_t *hba)
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan{
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_port_t *port = &PPORT;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint8_t flag[MAX_CHANNEL];
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan uint32_t i;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan uint32_t rc;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Exit if we are still initializing */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->state < FC_LINK_DOWN) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan bzero((void *)flag, sizeof (flag));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Check SLI level timeouts */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_SLI_TIMER(hba);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Check event queue */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_timer_check_events(hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check heartbeat timer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_timer_check_heartbeat(hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan /* Check fw update timer */
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan emlxs_timer_check_fw_update(hba);
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef IDLE_TIMER
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pm_idle_timer(hba);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* IDLE_TIMER */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for loopback timeouts */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_timer_check_loopback(hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for packet timeouts */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = emlxs_timer_check_pkts(hba, flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Link or adapter is being reset */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for linkup timeout */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_timer_check_linkup(hba);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check the ports */
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
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for node gate timeouts */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_timer_check_nodes(port, flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Check for clean address bit delay timeout */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_timer_check_clean_address(port);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for tape discovery timeout */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_timer_check_discovery(port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for UB timeouts */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_timer_check_ub(port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DHCHAP_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check for DHCHAP authentication timeouts */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_timer_check_dhchap(port);
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* DHCHAP_SUPPORT */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Check memory pools */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_timer_check_pools(hba);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Check for IO channel service timeouts */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Always do this last */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_timer_check_channels(hba, flag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_timer_checks() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_timer_start(emlxs_hba_t *hba)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->timer_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Restart the timer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_TIMER_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!hba->timer_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->timer_flags = 0;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan hba->timer_id =
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan timeout(emlxs_timer, (void *)hba, drv_usectohz(1000000));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_TIMER_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_timer_start() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_timer_stop(emlxs_hba_t *hba)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!hba->timer_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_TIMER_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->timer_flags |= EMLXS_TIMER_KILL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (hba->timer_id) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_TIMER_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte delay(drv_usectohz(500000));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_TIMER_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_TIMER_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_timer_stop() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_timer_check_pkts(emlxs_hba_t *hba, uint8_t *flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_config_t *cfg = &CFG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Q tmo;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan int32_t channelno;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan CHANNEL *cp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NODELIST *nlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *prev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCB *iocb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_buf_t *sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_packet_t *pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Q abort;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t iotag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg[CFG_TIMEOUT_ENABLE].current) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->pkt_timer > hba->timer_tics) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->pkt_timer = hba->timer_tics + EMLXS_PKT_PERIOD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan bzero((void *)&tmo, sizeof (Q));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We must hold the locks here because we never know when an iocb
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * will be removed out from under us
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
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 /* Scan the tx queues for each active node on the channel */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Get the first node */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp = (NODELIST *)cp->nodeq.q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (nlp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Scan the node's priority tx queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prev = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq = (IOCBQ *)nlp->nlp_ptx[channelno].q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (iocbq) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte next = (IOCBQ *)iocbq->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocb = &iocbq->iocb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp = (emlxs_buf_t *)iocbq->sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if iocb has timed out */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sbp && hba->timer_tics >= sbp->ticks) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iocb timed out, now deque it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (next == NULL) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_ptx[channelno].q_last =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)prev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (prev == NULL) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_ptx[channelno].
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan q_first = (uint8_t *)next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prev->next = next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->next = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_ptx[channelno].q_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* Add this iocb to our local */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* timout queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * This way we don't hold the TX_CHANNEL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lock too long
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmo.q_first) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((IOCBQ *)tmo.q_last)->next =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan tmo.q_last =
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (uint8_t *)iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmo.q_cnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan tmo.q_first =
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (uint8_t *)iocbq;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan tmo.q_last =
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (uint8_t *)iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmo.q_cnt = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prev = iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq = next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* while (iocbq) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Scan the node's tx queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prev = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq = (IOCBQ *)nlp->nlp_tx[channelno].q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (iocbq) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte next = (IOCBQ *)iocbq->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocb = &iocbq->iocb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp = (emlxs_buf_t *)iocbq->sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if iocb has timed out */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sbp && hba->timer_tics >= sbp->ticks) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* iocb timed out, now deque it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (next == NULL) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_tx[channelno].q_last =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)prev;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (prev == NULL) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_tx[channelno].q_first =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (uint8_t *)next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prev->next = next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->next = NULL;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_tx[channelno].q_cnt--;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* Add this iocb to our local */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* timout queue */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * This way we don't hold the TX_CHANNEL
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lock too long
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (tmo.q_first) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((IOCBQ *)tmo.q_last)->next =
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan tmo.q_last =
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (uint8_t *)iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmo.q_cnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan tmo.q_first =
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (uint8_t *)iocbq;
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan tmo.q_last =
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (uint8_t *)iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmo.q_cnt = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte prev = iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq = next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* while (iocbq) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (nlp == (NODELIST *)cp->nodeq.q_last) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nlp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp = nlp->nlp_next[channelno];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } /* while (nlp) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* end of for */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now cleanup the iocb's */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq = (IOCBQ *)tmo.q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (iocbq) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Free the IoTag and the bmp */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocb = &iocbq->iocb;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan channelno = ((CHANNEL *)iocbq->channel)->channelno;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = iocbq->sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sbp && (sbp != STALE_PACKET)) {
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(
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (CHANNEL *)iocbq->channel,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocb->ULPIOTAG, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->pkt_flags |= PACKET_IN_TIMEOUT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 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 complete the transmit timeouts outside the locks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq = (IOCBQ *)tmo.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) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* Warning: Some FCT sbp's don't have */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* fc_packet objects */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt = PRIV2PKT(sbp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_pkt_timeout_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "TXQ abort: sbp=%p iotag=%d tmo=%d", sbp,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->iotag, (pkt) ? pkt->pkt_timeout : 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->state >= FC_LINK_UP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pkt_complete(sbp, IOSTAT_LOCAL_REJECT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOERR_ABORT_TIMEOUT, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_pkt_complete(sbp, IOSTAT_LOCAL_REJECT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOERR_LINK_DOWN, 1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq = next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* end of while */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Now check the chip */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan bzero((void *)&abort, sizeof (Q));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Check the HBA for outstanding IOs */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = 0;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_FCTAB_LOCK);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (iotag = 1; iotag < hba->max_iotag; iotag++) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = hba->fc_table[iotag];
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (!sbp || sbp == STALE_PACKET) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore continue;
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore }
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 "timer_check_pkts: Invalid IO found. iotag=%d",
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore iotag);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore hba->fc_table[iotag] = STALE_PACKET;
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore hba->io_count--;
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore continue;
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore }
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore if ((sbp->pkt_flags & PACKET_IN_CHIPQ) &&
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (hba->timer_tics >= sbp->ticks)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan rc = emlxs_pkt_chip_timeout(sbp->iocbq.port,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp, &abort, flag);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (rc) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
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 IO channel service to send these abort iocbq */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (channelno = 0; channelno < hba->chan_count; channelno++) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (!flag[channelno]) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan continue;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp = &hba->chan[channelno];
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_SLI_ISSUE_IOCB_CMD(hba, cp, 0);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (rc == 1) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld mutex_enter(&EMLXS_PORT_LOCK);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* If a link reset or port reset is already requested, exit */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (!(hba->reset_request & (FC_LINK_RESET | FC_PORT_RESET))) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld hba->reset_request |= FC_LINK_RESET;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld mutex_exit(&EMLXS_PORT_LOCK);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Spawn a thread to reset the link */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_thread_spawn(hba, emlxs_reset_link_thread, NULL,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld NULL);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld goto exit;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (rc == 2) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld mutex_enter(&EMLXS_PORT_LOCK);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* If a port reset is already requested, exit */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (!(hba->reset_request & FC_PORT_RESET)) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld hba->reset_request |= FC_PORT_RESET;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld mutex_exit(&EMLXS_PORT_LOCK);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Spawn a thread to reset the adapter */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_thread_spawn(hba, emlxs_restart_thread, NULL,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld NULL);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld goto exit;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeldexit:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_timer_check_pkts() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathanemlxs_timer_check_channels(emlxs_hba_t *hba, uint8_t *flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_config_t *cfg = &CFG;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan int32_t channelno;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan CHANNEL *cp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint32_t logit;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg[CFG_TIMEOUT_ENABLE].current) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (channelno = 0; channelno < hba->chan_count; channelno++) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp = &hba->chan[channelno];
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan logit = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Check for channel timeout now */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_TX_CHANNEL_LOCK);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (cp->timeout && (hba->timer_tics >= cp->timeout)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Check if there is work to do on channel and */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* the link is still up */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (cp->nodeq.q_first) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan flag[channelno] = 1;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->timeout = hba->timer_tics + 10;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->state >= FC_LINK_UP) {
728bdc9be5faf84b5dca42f545967bd4910d608eSukumar Swaminathan logit = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp->timeout = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
728bdc9be5faf84b5dca42f545967bd4910d608eSukumar Swaminathan if (logit) {
728bdc9be5faf84b5dca42f545967bd4910d608eSukumar Swaminathan EMLXS_MSGF(EMLXS_CONTEXT,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan &emlxs_chan_watchdog_msg,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan "IO Channel %d cnt=%d,%d",
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan channelno,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->channel_tx_count,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan hba->io_count);
728bdc9be5faf84b5dca42f545967bd4910d608eSukumar Swaminathan }
728bdc9be5faf84b5dca42f545967bd4910d608eSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * If IO channel flag is set, request iocb servicing
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * here to send any iocb's that may still be queued
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (flag[channelno]) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_SLI_ISSUE_IOCB_CMD(hba, cp, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_timer_check_channels() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_timer_check_nodes(emlxs_port_t *port, uint8_t *flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t found;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NODELIST *nlp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan int32_t channelno;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (;;) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check node gate flag for expiration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * We need to lock, scan, and unlock because we can't hold the
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan * lock while we call node_open
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rw_enter(&port->node_rwlock, RW_READER);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < EMLXS_NUM_HASH_QUES; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nlp = port->node_table[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (nlp != NULL) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld#ifdef NODE_THROTTLE_SUPPORT
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Check io_active count (Safety net) */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (nlp->io_active & 0x80000000) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld EMLXS_MSGF(EMLXS_CONTEXT,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld &emlxs_sli_debug_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "timer_check_nodes: did=%06x "
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "io_active=0x%x. Reset to zero.",
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld nlp->nlp_DID, nlp->io_active);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld nlp->io_active = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld#endif /* NODE_THROTTLE_SUPPORT */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (channelno = 0;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan channelno < hba->chan_count;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan channelno++) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* Check if the node timer is active */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* and if timer has expired */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (nlp->nlp_tics[channelno] &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (hba->timer_tics >=
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_tics[channelno])) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* If so, set the flag and */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* break out */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = 1;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan flag[channelno] = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (nlp->nlp_force_rscn &&
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (hba->timer_tics >= nlp->nlp_force_rscn)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_force_rscn = 0;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /*
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * Generate an RSCN to
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan * wakeup ULP
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (void) emlxs_generate_rscn(port,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp->nlp_DID);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nlp = nlp->nlp_list_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rw_exit(&port->node_rwlock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_node_timeout(port, nlp, channelno);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_timer_check_nodes() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_timer_check_loopback(emlxs_hba_t *hba)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_config_t *cfg = &CFG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t reset = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg[CFG_TIMEOUT_ENABLE].current) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check the loopback timer for expiration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan if (!hba->loopback_tics || (hba->timer_tics < hba->loopback_tics)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->loopback_tics = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->flag & FC_LOOPBACK_MODE) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte reset = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (reset) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_dfc_debug_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "LOOPBACK_MODE: Expired. Resetting...");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_reset(port, FC_FCA_LINK_RESET);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_timer_check_loopback() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_timer_check_linkup(emlxs_hba_t *hba)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t linkup;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Check if all mbox commands from previous activity are processed */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (hba->model_info.sli_mask & EMLXS_SLI4_MASK) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_MBOX_LOCK);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (hba->mbox_queue.q_first) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_MBOX_LOCK);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan return;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_MBOX_LOCK);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check the linkup timer for expiration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte linkup = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->linkup_timer && (hba->timer_tics >= hba->linkup_timer)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->linkup_timer = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Make sure link is still ready */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->state >= FC_LINK_UP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte linkup = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Make the linkup callback */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (linkup) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_online(port);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_timer_check_linkup() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_timer_check_heartbeat(emlxs_hba_t *hba)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan MAILBOXQ *mbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_config_t *cfg = &CFG;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan int rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg[CFG_HEARTBEAT_ENABLE].current) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->timer_tics < hba->heartbeat_timer) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->heartbeat_timer = hba->timer_tics + 5;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Return if adapter interrupts have occurred */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->heartbeat_flag) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->heartbeat_flag = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* No adapter interrupts have occured for 5 seconds now */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Return if mailbox is busy */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* This means the mailbox timer routine is watching for problems */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->mbox_timer) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Return if heartbeat is still outstanding */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->heartbeat_active) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if ((mbq = (MAILBOXQ *)emlxs_mem_get(hba, MEM_MBOX)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_init_debug_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unable to allocate heartbeat mailbox.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_mb_heartbeat(hba, mbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->heartbeat_active = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan rc = EMLXS_SLI_ISSUE_MBOX_CMD(hba, mbq, MBX_NOWAIT, 0);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((rc != MBX_BUSY) && (rc != MBX_SUCCESS)) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_mem_put(hba, MEM_MBOX, (void *)mbq);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_timer_check_heartbeat() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathanstatic void
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathanemlxs_timer_check_fw_update(emlxs_hba_t *hba)
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan{
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan emlxs_port_t *port = &PPORT;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld char msgbuf[128];
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan if (!(hba->fw_flag & FW_UPDATE_NEEDED)) {
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan hba->fw_timer = 0;
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan return;
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan }
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan if (hba->timer_tics < hba->fw_timer) {
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan return;
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan }
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (port->mode == MODE_TARGET) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) strncpy(msgbuf,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "To trigger an update, a manual HBA or link reset "
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "using emlxadm is required.",
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (sizeof (msgbuf)-1));
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore } else {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) strncpy(msgbuf,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "To trigger an update, a manual HBA or link reset "
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "using luxadm, fcadm, or emlxadm is required.",
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (sizeof (msgbuf)-1));
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore }
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_fw_update_msg, msgbuf);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Force message to console */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld cmn_err(CE_WARN,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "^%s%d: Firmware update required.\n\t(%s)\n",
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld DRIVER_NAME, hba->ddiinst, msgbuf);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan /* Set timer for 24 hours */
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan hba->fw_timer = hba->timer_tics + (60 * 60 * 24);
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan return;
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan} /* emlxs_timer_check_fw_update() */
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan
6a573d82e26abdedeb701fcdd5b5461b2fa0da40Sukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_timer_check_discovery(emlxs_port_t *port)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_config_t *cfg = &CFG;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int32_t send_clear_la;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t found;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NODELIST *nlp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MAILBOXQ *mbox;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan int rc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!cfg[CFG_TIMEOUT_ENABLE].current) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check the discovery timer for expiration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte send_clear_la = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (hba->discovery_timer &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (hba->timer_tics >= hba->discovery_timer) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (hba->state == FC_LINK_UP)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte send_clear_la = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Perform a flush on fcp2 nodes that are still closed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rw_enter(&port->node_rwlock, RW_READER);
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_fcp_info & NLP_FCP_2_DEVICE) &&
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (nlp->nlp_flag[hba->channel_fcp] &
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan NLP_CLOSED)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte found = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nlp = nlp->nlp_list_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rw_exit(&port->node_rwlock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!found) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_node_missing_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "FCP2 device (did=%06x) missing. Flushing...",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nlp->nlp_DID);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (void) EMLXS_SLI_UNREG_NODE(port, nlp, NULL, NULL, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Try to send clear link attention, if needed */
fe199829b492e6b3aa36dd76af597360bb4af121Sukumar Swaminathan if ((hba->sli_mode < EMLXS_HBA_SLI4_MODE) && (send_clear_la == 1) &&
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (mbox = (MAILBOXQ *)emlxs_mem_get(hba, MEM_MBOX))) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If state is not FC_LINK_UP, then either the link has gone
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * down or a FC_CLEAR_LA has already been issued
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->state != FC_LINK_UP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_mem_put(hba, MEM_MBOX, (void *)mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Change state and clear discovery timer */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan EMLXS_STATE_CHANGE_LOCKED(hba, FC_CLEAR_LA);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->discovery_timer = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_PORT_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Prepare and send the CLEAR_LA command */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan emlxs_mb_clear_la(hba, mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan rc = EMLXS_SLI_ISSUE_MBOX_CMD(hba, mbox, MBX_NOWAIT, 0);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((rc != MBX_BUSY) && (rc != MBX_SUCCESS)) {
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore emlxs_mem_put(hba, MEM_MBOX, (void *)mbox);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_timer_check_discovery() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeldstatic void
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeldemlxs_timer_check_clean_address(emlxs_port_t *port)
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld{
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_hba_t *hba = HBA;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_buf_t *sbp;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (port->clean_address_timer &&
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld (hba->timer_tics < port->clean_address_timer)) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld return;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld port->clean_address_timer = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld sbp = port->clean_address_sbp;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (!sbp) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld return;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld port->clean_address_sbp = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_els_completion_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "Clean Address timeout: sid=%x prev=%x RATOV %d",
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld port->did, port->prev_did, hba->fc_ratov);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (EMLXS_SLI_REG_DID(port, FABRIC_DID, &port->fabric_sparam,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld sbp, NULL, NULL) == 0) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* Deferred completion of this pkt until */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld /* login is complete */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld return;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_pkt_complete(sbp, IOSTAT_LOCAL_REJECT,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld IOERR_NO_RESOURCES, 1);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld return;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld} /* emlxs_timer_check_clean_address() */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeldextern void
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeldemlxs_timer_cancel_clean_address(emlxs_port_t *port)
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld{
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_hba_t *hba = HBA;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_buf_t *sbp;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld port->clean_address_timer = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld sbp = port->clean_address_sbp;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (!sbp) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld return;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld port->clean_address_sbp = 0;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_els_completion_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "Clean Address cancel: sid=%x prev=%x RATOV %d",
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld port->did, port->prev_did, hba->fc_ratov);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_pkt_complete(sbp, IOSTAT_LOCAL_REJECT,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld IOERR_LINK_DOWN, 1);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld} /* emlxs_timer_cancel_clean_address() */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_timer_check_ub(emlxs_port_t *port)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_unsol_buf_t *ulistp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_unsol_buf_t *ubp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_ub_priv_t *ub_priv;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (port->ub_timer > hba->timer_tics) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte port->ub_timer = hba->timer_tics + EMLXS_UB_PERIOD;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check the unsolicited buffers */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&EMLXS_UB_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ulistp = port->ub_pool;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (ulistp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check buffers in this pool */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < ulistp->pool_nentries; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ubp = (fc_unsol_buf_t *)&ulistp->fc_ubufs[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ub_priv = ubp->ub_fca_private;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(ub_priv->flags & EMLXS_UB_IN_USE)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* If buffer has timed out, print message and */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* increase timeout */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ub_priv->time + ub_priv->timeout) <=
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hba->timer_tics) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ub_priv->flags |= EMLXS_UB_TIMEOUT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan EMLXS_MSGF(EMLXS_CONTEXT,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan &emlxs_sfs_debug_msg,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Stale UB buffer detected (%d mins): "
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan "buffer=%p (%x,%x,%x,%x)",
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (ub_priv->timeout / 60), ubp,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan ubp->ub_frame.type, ubp->ub_frame.s_id,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan ubp->ub_frame.ox_id, ubp->ub_frame.rx_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Increase timeout period */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* If timeout was 5 mins or less, */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* increase it to 10 mins */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ub_priv->timeout <= (5 * 60)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ub_priv->timeout = (10 * 60);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* If timeout was 10 mins or less, */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* increase it to 30 mins */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (ub_priv->timeout <= (10 * 60)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ub_priv->timeout = (30 * 60);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Otherwise double it. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ub_priv->timeout *= 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ulistp = ulistp->pool_next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&EMLXS_UB_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_timer_check_ub() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* EMLXS_FCTAB_LOCK must be held to call this */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic uint32_t
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathanemlxs_pkt_chip_timeout(emlxs_port_t *port, emlxs_buf_t *sbp, Q *abortq,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan uint8_t *flag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan CHANNEL *cp = (CHANNEL *)sbp->channel;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *iocbq = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_packet_t *pkt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rc = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_enter(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Warning: Some FCT sbp's don't have fc_packet objects */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt = PRIV2PKT(sbp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte switch (sbp->abort_attempts) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 0:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Create the abort IOCB */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (hba->state >= FC_LINK_UP) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_pkt_timeout_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "chipQ: 1:Aborting. sbp=%p iotag=%d tmo=%d "
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore "flags=%x",
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan sbp, sbp->iotag,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (pkt) ? pkt->pkt_timeout : 0, sbp->pkt_flags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan iocbq =
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_create_abort_xri_cn(port, sbp->node,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp->iotag, cp, sbp->class, ABORT_TYPE_ABTS);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* The adapter will make 2 attempts to send ABTS */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan /* with 2*ratov timeout each time */
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan sbp->ticks =
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan hba->timer_tics + (4 * hba->fc_ratov) + 10;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_pkt_timeout_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "chipQ: 1:Closing. sbp=%p iotag=%d tmo=%d "
a9800beb32c1006bb21c8da39e0180ea440b7badGarrett D'Amore "flags=%x",
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan sbp, sbp->iotag,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan (pkt) ? pkt->pkt_timeout : 0, sbp->pkt_flags);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan iocbq =
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_create_close_xri_cn(port, sbp->node,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp->iotag, cp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->ticks = hba->timer_tics + 30;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set the flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->pkt_flags |= (PACKET_IN_TIMEOUT | PACKET_XRI_CLOSED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan flag[cp->channelno] = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 1:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_pkt_timeout_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "chipQ: 2:Closing. sbp=%p iotag=%d", sbp, sbp->iotag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan iocbq =
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan emlxs_create_close_xri_cn(port, sbp->node, sbp->iotag,
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->ticks = hba->timer_tics + 30;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan flag[cp->channelno] = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte case 2:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_pkt_timeout_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "chipQ: 3:Resetting link. sbp=%p iotag=%d", sbp,
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan sbp->iotag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->ticks = hba->timer_tics + 60;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte default:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte EMLXS_MSGF(EMLXS_CONTEXT, &emlxs_pkt_timeout_msg,
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld "chipQ: %d:Resetting adapter. sbp=%p iotag=%d",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->abort_attempts, sbp, sbp->iotag);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->ticks = hba->timer_tics + 60;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rc = 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp->abort_attempts++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mutex_exit(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (iocbq) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (abortq->q_first) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan ((IOCBQ *)abortq->q_last)->next = iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte abortq->q_last = (uint8_t *)iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte abortq->q_cnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte abortq->q_first = (uint8_t *)iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte abortq->q_last = (uint8_t *)iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte abortq->q_cnt = 1;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (rc);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_pkt_chip_timeout() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeldstatic void
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeldemlxs_timer_check_pools(emlxs_hba_t *hba)
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld{
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld uint32_t i;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld MEMSEG *seg;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_config_t *cfg = &CFG;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (cfg[CFG_MEM_DYNAMIC].current == 0) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld return;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (hba->mem_timer > hba->timer_tics) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld return;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld hba->mem_timer = hba->timer_tics + cfg[CFG_MEM_DYNAMIC].current;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld seg = hba->memseg;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld for (i = 0; i < FC_MAX_SEG; i++, seg++) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (seg->fc_memflag & FC_MEMSEG_DYNAMIC) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_mem_pool_clean(hba, seg);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld#ifdef SFCT_SUPPORT
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld{
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld uint32_t j;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_port_t *port;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld for (i = 0; i < MAX_VPORTS; i++) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld port = &VPORT(i);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (!(port->flag & EMLXS_PORT_BOUND) ||
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld !(port->flag & EMLXS_TGT_ENABLED) ||
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld !port->fct_memseg) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld continue;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld seg = port->fct_memseg;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld for (j = 0; j < port->fct_memseg_cnt; j++, seg++) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld if (seg->fc_memflag & FC_MEMSEG_DYNAMIC) {
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld emlxs_mem_pool_clean(hba, seg);
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld }
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld}
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld#endif /* SFCT_SUPPORT */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld return;
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld} /* emlxs_timer_check_pools() */
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
8f23e9fa8abcb5857661066b954e63400d589b65Hans Rosenfeld
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef TX_WATCHDOG
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_tx_watchdog(emlxs_hba_t *hba)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_port_t *port = &PPORT;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NODELIST *nlp;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan uint32_t channelno;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan CHANNEL *cp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCBQ *iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte IOCB *iocb;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t found;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MATCHMAP *bmp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Q abort;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t iotag;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_buf_t *sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte fc_packet_t *pkt = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t cmd;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t did;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan bzero((void *)&abort, sizeof (Q));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_TX_CHANNEL_LOCK);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&EMLXS_FCTAB_LOCK);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan for (iotag = 1; iotag < hba->max_iotag; iotag++) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp = hba->fc_table[iotag];
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (sbp && (sbp != STALE_PACKET) &&
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (sbp->pkt_flags & PACKET_IN_TXQ)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan nlp = sbp->node;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq = &sbp->iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan channelno = (CHANNEL *)(sbp->channel)->channelno;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (iocbq->flag & IOCB_PRIORITY) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (IOCBQ *)nlp->nlp_ptx[channelno].
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan q_first;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan (IOCBQ *)nlp->nlp_tx[channelno].
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan q_first;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan /* Find a matching entry */
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan found = 0;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan while (iocbq) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (iocbq == &sbp->iocbq) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan found = 1;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan break;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan iocbq = (IOCBQ *)iocbq->next;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (!found) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (!(sbp->pkt_flags & PACKET_STALE)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&sbp->mtx);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp->pkt_flags |=
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan PACKET_STALE;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if (abort.q_first == 0) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_first =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan &sbp->iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ((IOCBQ *)abort.
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan q_last)->next =
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan &sbp->iocbq;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_last = &sbp->iocbq;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan abort.q_cnt++;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan } else {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan if ((sbp->pkt_flags & PACKET_STALE)) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_enter(&sbp->mtx);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan sbp->pkt_flags &=
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan ~PACKET_STALE;
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&sbp->mtx);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_FCTAB_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan iocbq = (IOCBQ *)abort.q_first;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (iocbq) {
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan next = (IOCBQ *)iocbq->next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq->next = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sbp = (emlxs_buf_t *)iocbq->sbp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte pkt = PRIV2PKT(sbp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pkt) {
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan did = LE_SWAP24_LO(pkt->pkt_cmd_fhdr.d_id);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmd = *((uint32_t *)pkt->pkt_cmd);
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan cmd = LE_SWAP32(cmd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_tx_put(iocbq, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iocbq = next;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } /* end of while */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan mutex_exit(&EMLXS_TX_CHANNEL_LOCK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_tx_watchdog() */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* TX_WATCHDOG */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#ifdef DHCHAP_SUPPORT
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteemlxs_timer_check_dhchap(emlxs_port_t *port)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_hba_t *hba = HBA;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte NODELIST *ndlp = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < EMLXS_NUM_HASH_QUES; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ndlp = port->node_table[i];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!ndlp) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check authentication response timeout */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ndlp->node_dhc.nlp_authrsp_tmo &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (hba->timer_tics >= ndlp->node_dhc.nlp_authrsp_tmo)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Trigger authresp timeout handler */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) emlxs_dhc_authrsp_timeout(port, ndlp, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check reauthentication timeout */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ndlp->node_dhc.nlp_reauth_tmo &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (hba->timer_tics >= ndlp->node_dhc.nlp_reauth_tmo)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Trigger reauth timeout handler */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte emlxs_dhc_reauth_timeout(port, NULL, ndlp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
825277341c15b6b0d2c4b8b622ae7b1d2bdc0390Sukumar Swaminathan} /* emlxs_timer_check_dhchap */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
291a2b48b9adcd7b3666c34e80ba6411929afe7fSukumar Swaminathan#endif /* DHCHAP_SUPPORT */