lpfc_init.c (16a3a20842f3df93f4ccb82b8f374be16280a337) lpfc_init.c (256ec0d05f8050339a9cc4e92bdc96cec1ce82bd)
1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2012 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com *
7 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
8 * *

--- 527 unchanged lines hidden (view full) ---

536 status &= ~(HC_R0INT_ENA);
537
538 writel(status, phba->HCregaddr);
539 readl(phba->HCregaddr); /* flush */
540 spin_unlock_irq(&phba->hbalock);
541
542 /* Set up ring-0 (ELS) timer */
543 timeout = phba->fc_ratov * 2;
1/*******************************************************************
2 * This file is part of the Emulex Linux Device Driver for *
3 * Fibre Channel Host Bus Adapters. *
4 * Copyright (C) 2004-2012 Emulex. All rights reserved. *
5 * EMULEX and SLI are trademarks of Emulex. *
6 * www.emulex.com *
7 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
8 * *

--- 527 unchanged lines hidden (view full) ---

536 status &= ~(HC_R0INT_ENA);
537
538 writel(status, phba->HCregaddr);
539 readl(phba->HCregaddr); /* flush */
540 spin_unlock_irq(&phba->hbalock);
541
542 /* Set up ring-0 (ELS) timer */
543 timeout = phba->fc_ratov * 2;
544 mod_timer(&vport->els_tmofunc, jiffies + HZ * timeout);
544 mod_timer(&vport->els_tmofunc,
545 jiffies + msecs_to_jiffies(1000 * timeout));
545 /* Set up heart beat (HB) timer */
546 /* Set up heart beat (HB) timer */
546 mod_timer(&phba->hb_tmofunc, jiffies + HZ * LPFC_HB_MBOX_INTERVAL);
547 mod_timer(&phba->hb_tmofunc,
548 jiffies + msecs_to_jiffies(1000 * LPFC_HB_MBOX_INTERVAL));
547 phba->hb_outstanding = 0;
548 phba->last_completion_time = jiffies;
549 /* Set up error attention (ERATT) polling timer */
549 phba->hb_outstanding = 0;
550 phba->last_completion_time = jiffies;
551 /* Set up error attention (ERATT) polling timer */
550 mod_timer(&phba->eratt_poll, jiffies + HZ * LPFC_ERATT_POLL_INTERVAL);
552 mod_timer(&phba->eratt_poll,
553 jiffies + msecs_to_jiffies(1000 * LPFC_ERATT_POLL_INTERVAL));
551
552 if (phba->hba_flag & LINK_DISABLED) {
553 lpfc_printf_log(phba,
554 KERN_ERR, LOG_INIT,
555 "2598 Adapter Link is disabled.\n");
556 lpfc_down_link(phba, pmb);
557 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
558 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);

--- 457 unchanged lines hidden (view full) ---

1016 spin_unlock_irqrestore(&phba->hbalock, drvr_flag);
1017
1018 /* Check and reset heart-beat timer is necessary */
1019 mempool_free(pmboxq, phba->mbox_mem_pool);
1020 if (!(phba->pport->fc_flag & FC_OFFLINE_MODE) &&
1021 !(phba->link_state == LPFC_HBA_ERROR) &&
1022 !(phba->pport->load_flag & FC_UNLOADING))
1023 mod_timer(&phba->hb_tmofunc,
554
555 if (phba->hba_flag & LINK_DISABLED) {
556 lpfc_printf_log(phba,
557 KERN_ERR, LOG_INIT,
558 "2598 Adapter Link is disabled.\n");
559 lpfc_down_link(phba, pmb);
560 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
561 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);

--- 457 unchanged lines hidden (view full) ---

1019 spin_unlock_irqrestore(&phba->hbalock, drvr_flag);
1020
1021 /* Check and reset heart-beat timer is necessary */
1022 mempool_free(pmboxq, phba->mbox_mem_pool);
1023 if (!(phba->pport->fc_flag & FC_OFFLINE_MODE) &&
1024 !(phba->link_state == LPFC_HBA_ERROR) &&
1025 !(phba->pport->load_flag & FC_UNLOADING))
1026 mod_timer(&phba->hb_tmofunc,
1024 jiffies + HZ * LPFC_HB_MBOX_INTERVAL);
1027 jiffies +
1028 msecs_to_jiffies(1000 * LPFC_HB_MBOX_INTERVAL));
1025 return;
1026}
1027
1028/**
1029 * lpfc_hb_timeout_handler - The HBA-timer timeout handler
1030 * @phba: pointer to lpfc hba data structure.
1031 *
1032 * This is the actual HBA-timer timeout handler to be invoked by the worker

--- 26 unchanged lines hidden (view full) ---

1059
1060 if ((phba->link_state == LPFC_HBA_ERROR) ||
1061 (phba->pport->load_flag & FC_UNLOADING) ||
1062 (phba->pport->fc_flag & FC_OFFLINE_MODE))
1063 return;
1064
1065 spin_lock_irq(&phba->pport->work_port_lock);
1066
1029 return;
1030}
1031
1032/**
1033 * lpfc_hb_timeout_handler - The HBA-timer timeout handler
1034 * @phba: pointer to lpfc hba data structure.
1035 *
1036 * This is the actual HBA-timer timeout handler to be invoked by the worker

--- 26 unchanged lines hidden (view full) ---

1063
1064 if ((phba->link_state == LPFC_HBA_ERROR) ||
1065 (phba->pport->load_flag & FC_UNLOADING) ||
1066 (phba->pport->fc_flag & FC_OFFLINE_MODE))
1067 return;
1068
1069 spin_lock_irq(&phba->pport->work_port_lock);
1070
1067 if (time_after(phba->last_completion_time + LPFC_HB_MBOX_INTERVAL * HZ,
1068 jiffies)) {
1071 if (time_after(phba->last_completion_time +
1072 msecs_to_jiffies(1000 * LPFC_HB_MBOX_INTERVAL),
1073 jiffies)) {
1069 spin_unlock_irq(&phba->pport->work_port_lock);
1070 if (!phba->hb_outstanding)
1071 mod_timer(&phba->hb_tmofunc,
1074 spin_unlock_irq(&phba->pport->work_port_lock);
1075 if (!phba->hb_outstanding)
1076 mod_timer(&phba->hb_tmofunc,
1072 jiffies + HZ * LPFC_HB_MBOX_INTERVAL);
1077 jiffies +
1078 msecs_to_jiffies(1000 * LPFC_HB_MBOX_INTERVAL));
1073 else
1074 mod_timer(&phba->hb_tmofunc,
1079 else
1080 mod_timer(&phba->hb_tmofunc,
1075 jiffies + HZ * LPFC_HB_MBOX_TIMEOUT);
1081 jiffies +
1082 msecs_to_jiffies(1000 * LPFC_HB_MBOX_TIMEOUT));
1076 return;
1077 }
1078 spin_unlock_irq(&phba->pport->work_port_lock);
1079
1080 if (phba->elsbuf_cnt &&
1081 (phba->elsbuf_cnt == phba->elsbuf_prev_cnt)) {
1082 spin_lock_irq(&phba->hbalock);
1083 list_splice_init(&phba->elsbuf, &completions);

--- 15 unchanged lines hidden (view full) ---

1099 if (!phba->hb_outstanding) {
1100 if ((!(psli->sli_flag & LPFC_SLI_MBOX_ACTIVE)) &&
1101 (list_empty(&psli->mboxq))) {
1102 pmboxq = mempool_alloc(phba->mbox_mem_pool,
1103 GFP_KERNEL);
1104 if (!pmboxq) {
1105 mod_timer(&phba->hb_tmofunc,
1106 jiffies +
1083 return;
1084 }
1085 spin_unlock_irq(&phba->pport->work_port_lock);
1086
1087 if (phba->elsbuf_cnt &&
1088 (phba->elsbuf_cnt == phba->elsbuf_prev_cnt)) {
1089 spin_lock_irq(&phba->hbalock);
1090 list_splice_init(&phba->elsbuf, &completions);

--- 15 unchanged lines hidden (view full) ---

1106 if (!phba->hb_outstanding) {
1107 if ((!(psli->sli_flag & LPFC_SLI_MBOX_ACTIVE)) &&
1108 (list_empty(&psli->mboxq))) {
1109 pmboxq = mempool_alloc(phba->mbox_mem_pool,
1110 GFP_KERNEL);
1111 if (!pmboxq) {
1112 mod_timer(&phba->hb_tmofunc,
1113 jiffies +
1107 HZ * LPFC_HB_MBOX_INTERVAL);
1114 msecs_to_jiffies(1000 *
1115 LPFC_HB_MBOX_INTERVAL));
1108 return;
1109 }
1110
1111 lpfc_heart_beat(phba, pmboxq);
1112 pmboxq->mbox_cmpl = lpfc_hb_mbox_cmpl;
1113 pmboxq->vport = phba->pport;
1114 retval = lpfc_sli_issue_mbox(phba, pmboxq,
1115 MBX_NOWAIT);
1116
1117 if (retval != MBX_BUSY &&
1118 retval != MBX_SUCCESS) {
1119 mempool_free(pmboxq,
1120 phba->mbox_mem_pool);
1121 mod_timer(&phba->hb_tmofunc,
1122 jiffies +
1116 return;
1117 }
1118
1119 lpfc_heart_beat(phba, pmboxq);
1120 pmboxq->mbox_cmpl = lpfc_hb_mbox_cmpl;
1121 pmboxq->vport = phba->pport;
1122 retval = lpfc_sli_issue_mbox(phba, pmboxq,
1123 MBX_NOWAIT);
1124
1125 if (retval != MBX_BUSY &&
1126 retval != MBX_SUCCESS) {
1127 mempool_free(pmboxq,
1128 phba->mbox_mem_pool);
1129 mod_timer(&phba->hb_tmofunc,
1130 jiffies +
1123 HZ * LPFC_HB_MBOX_INTERVAL);
1131 msecs_to_jiffies(1000 *
1132 LPFC_HB_MBOX_INTERVAL));
1124 return;
1125 }
1126 phba->skipped_hb = 0;
1127 phba->hb_outstanding = 1;
1128 } else if (time_before_eq(phba->last_completion_time,
1129 phba->skipped_hb)) {
1130 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
1131 "2857 Last completion time not "
1132 " updated in %d ms\n",
1133 jiffies_to_msecs(jiffies
1134 - phba->last_completion_time));
1135 } else
1136 phba->skipped_hb = jiffies;
1137
1138 mod_timer(&phba->hb_tmofunc,
1133 return;
1134 }
1135 phba->skipped_hb = 0;
1136 phba->hb_outstanding = 1;
1137 } else if (time_before_eq(phba->last_completion_time,
1138 phba->skipped_hb)) {
1139 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
1140 "2857 Last completion time not "
1141 " updated in %d ms\n",
1142 jiffies_to_msecs(jiffies
1143 - phba->last_completion_time));
1144 } else
1145 phba->skipped_hb = jiffies;
1146
1147 mod_timer(&phba->hb_tmofunc,
1139 jiffies + HZ * LPFC_HB_MBOX_TIMEOUT);
1148 jiffies +
1149 msecs_to_jiffies(1000 * LPFC_HB_MBOX_TIMEOUT));
1140 return;
1141 } else {
1142 /*
1143 * If heart beat timeout called with hb_outstanding set
1144 * we need to give the hb mailbox cmd a chance to
1145 * complete or TMO.
1146 */
1147 lpfc_printf_log(phba, KERN_WARNING, LOG_INIT,
1148 "0459 Adapter heartbeat still out"
1149 "standing:last compl time was %d ms.\n",
1150 jiffies_to_msecs(jiffies
1151 - phba->last_completion_time));
1152 mod_timer(&phba->hb_tmofunc,
1150 return;
1151 } else {
1152 /*
1153 * If heart beat timeout called with hb_outstanding set
1154 * we need to give the hb mailbox cmd a chance to
1155 * complete or TMO.
1156 */
1157 lpfc_printf_log(phba, KERN_WARNING, LOG_INIT,
1158 "0459 Adapter heartbeat still out"
1159 "standing:last compl time was %d ms.\n",
1160 jiffies_to_msecs(jiffies
1161 - phba->last_completion_time));
1162 mod_timer(&phba->hb_tmofunc,
1153 jiffies + HZ * LPFC_HB_MBOX_TIMEOUT);
1163 jiffies +
1164 msecs_to_jiffies(1000 * LPFC_HB_MBOX_TIMEOUT));
1154 }
1155 }
1156}
1157
1158/**
1159 * lpfc_offline_eratt - Bring lpfc offline on hardware error attention
1160 * @phba: pointer to lpfc hba data structure.
1161 *

--- 2040 unchanged lines hidden (view full) ---

3202 int stat = 0;
3203
3204 spin_lock_irq(shost->host_lock);
3205
3206 if (vport->load_flag & FC_UNLOADING) {
3207 stat = 1;
3208 goto finished;
3209 }
1165 }
1166 }
1167}
1168
1169/**
1170 * lpfc_offline_eratt - Bring lpfc offline on hardware error attention
1171 * @phba: pointer to lpfc hba data structure.
1172 *

--- 2040 unchanged lines hidden (view full) ---

3213 int stat = 0;
3214
3215 spin_lock_irq(shost->host_lock);
3216
3217 if (vport->load_flag & FC_UNLOADING) {
3218 stat = 1;
3219 goto finished;
3220 }
3210 if (time >= 30 * HZ) {
3221 if (time >= msecs_to_jiffies(30 * 1000)) {
3211 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
3212 "0461 Scanning longer than 30 "
3213 "seconds. Continuing initialization\n");
3214 stat = 1;
3215 goto finished;
3216 }
3222 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
3223 "0461 Scanning longer than 30 "
3224 "seconds. Continuing initialization\n");
3225 stat = 1;
3226 goto finished;
3227 }
3217 if (time >= 15 * HZ && phba->link_state <= LPFC_LINK_DOWN) {
3228 if (time >= msecs_to_jiffies(15 * 1000) &&
3229 phba->link_state <= LPFC_LINK_DOWN) {
3218 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
3219 "0465 Link down longer than 15 "
3220 "seconds. Continuing initialization\n");
3221 stat = 1;
3222 goto finished;
3223 }
3224
3225 if (vport->port_state != LPFC_VPORT_READY)
3226 goto finished;
3227 if (vport->num_disc_nodes || vport->fc_prli_sent)
3228 goto finished;
3230 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
3231 "0465 Link down longer than 15 "
3232 "seconds. Continuing initialization\n");
3233 stat = 1;
3234 goto finished;
3235 }
3236
3237 if (vport->port_state != LPFC_VPORT_READY)
3238 goto finished;
3239 if (vport->num_disc_nodes || vport->fc_prli_sent)
3240 goto finished;
3229 if (vport->fc_map_cnt == 0 && time < 2 * HZ)
3241 if (vport->fc_map_cnt == 0 && time < msecs_to_jiffies(2 * 1000))
3230 goto finished;
3231 if ((phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) != 0)
3232 goto finished;
3233
3234 stat = 1;
3235
3236finished:
3237 spin_unlock_irq(shost->host_lock);

--- 982 unchanged lines hidden (view full) ---

4220 lpfc_destroy_vport_work_array(phba, vports);
4221 }
4222
4223 if (active_vlink_present) {
4224 /*
4225 * If there are other active VLinks present,
4226 * re-instantiate the Vlink using FDISC.
4227 */
3242 goto finished;
3243 if ((phba->sli.sli_flag & LPFC_SLI_MBOX_ACTIVE) != 0)
3244 goto finished;
3245
3246 stat = 1;
3247
3248finished:
3249 spin_unlock_irq(shost->host_lock);

--- 982 unchanged lines hidden (view full) ---

4232 lpfc_destroy_vport_work_array(phba, vports);
4233 }
4234
4235 if (active_vlink_present) {
4236 /*
4237 * If there are other active VLinks present,
4238 * re-instantiate the Vlink using FDISC.
4239 */
4228 mod_timer(&ndlp->nlp_delayfunc, jiffies + HZ);
4240 mod_timer(&ndlp->nlp_delayfunc,
4241 jiffies + msecs_to_jiffies(1000));
4229 shost = lpfc_shost_from_vport(vport);
4230 spin_lock_irq(shost->host_lock);
4231 ndlp->nlp_flag |= NLP_DELAY_TMO;
4232 spin_unlock_irq(shost->host_lock);
4233 ndlp->nlp_last_elscmd = ELS_CMD_FDISC;
4234 vport->port_state = LPFC_FDISC;
4235 } else {
4236 /*

--- 6414 unchanged lines hidden ---
4242 shost = lpfc_shost_from_vport(vport);
4243 spin_lock_irq(shost->host_lock);
4244 ndlp->nlp_flag |= NLP_DELAY_TMO;
4245 spin_unlock_irq(shost->host_lock);
4246 ndlp->nlp_last_elscmd = ELS_CMD_FDISC;
4247 vport->port_state = LPFC_FDISC;
4248 } else {
4249 /*

--- 6414 unchanged lines hidden ---