50 static void emlxs_timer_check_discovery(emlxs_port_t *port);
51 static void emlxs_timer_check_clean_address(emlxs_port_t *port);
52 static void emlxs_timer_check_ub(emlxs_port_t *port);
53 static void emlxs_timer_check_channels(emlxs_hba_t *hba, uint8_t *flag);
54 static uint32_t emlxs_pkt_chip_timeout(emlxs_port_t *port, emlxs_buf_t *sbp,
55 Q *abortq, uint8_t *flag);
56
57 #ifdef TX_WATCHDOG
58 static void emlxs_tx_watchdog(emlxs_hba_t *hba);
59 #endif /* TX_WATCHDOG */
60
61 extern clock_t
62 emlxs_timeout(emlxs_hba_t *hba, uint32_t timeout)
63 {
64 emlxs_config_t *cfg = &CFG;
65 clock_t time;
66
67 /* Set thread timeout */
68 if (cfg[CFG_TIMEOUT_ENABLE].current) {
69 (void) drv_getparm(LBOLT, &time);
70 time += (timeout * drv_usectohz(1000000));
71 } else {
72 time = -1;
73 }
74
75 return (time);
76
77 } /* emlxs_timeout() */
78
79
80 static void
81 emlxs_timer(void *arg)
82 {
83 emlxs_hba_t *hba = (emlxs_hba_t *)arg;
84 emlxs_port_t *port = &PPORT;
85
86 if (!hba->timer_id) {
87 return;
88 }
89
90 mutex_enter(&EMLXS_TIMER_LOCK);
114 "Timer: io_active=0x%x. Reset to zero.", hba->io_active);
115 hba->io_active = 0;
116 }
117
118 mutex_exit(&EMLXS_TIMER_LOCK);
119
120 EMLXS_SLI_POLL_ERRATT(hba);
121
122 /* Perform standard checks */
123 emlxs_timer_checks(hba);
124
125 /* Restart the timer */
126 mutex_enter(&EMLXS_TIMER_LOCK);
127
128 hba->timer_flags &= ~EMLXS_TIMER_BUSY;
129
130 /* If timer is still enabled, restart it */
131 if (!(hba->timer_flags & EMLXS_TIMER_KILL)) {
132 hba->timer_id =
133 timeout(emlxs_timer, (void *)hba,
134 (EMLXS_TIMER_PERIOD * drv_usectohz(1000000)));
135 } else {
136 hba->timer_id = 0;
137 hba->timer_flags |= EMLXS_TIMER_ENDED;
138 }
139
140 mutex_exit(&EMLXS_TIMER_LOCK);
141
142 return;
143
144 } /* emlxs_timer() */
145
146
147 extern void
148 emlxs_timer_checks(emlxs_hba_t *hba)
149 {
150 emlxs_port_t *port = &PPORT;
151 uint8_t flag[MAX_CHANNEL];
152 uint32_t i;
153 uint32_t rc;
154
223 /* Always do this last */
224 emlxs_timer_check_channels(hba, flag);
225
226 return;
227
228 } /* emlxs_timer_checks() */
229
230
231 extern void
232 emlxs_timer_start(emlxs_hba_t *hba)
233 {
234 if (hba->timer_id) {
235 return;
236 }
237
238 /* Restart the timer */
239 mutex_enter(&EMLXS_TIMER_LOCK);
240 if (!hba->timer_id) {
241 hba->timer_flags = 0;
242 hba->timer_id =
243 timeout(emlxs_timer, (void *)hba, drv_usectohz(1000000));
244 }
245 mutex_exit(&EMLXS_TIMER_LOCK);
246
247 } /* emlxs_timer_start() */
248
249
250 extern void
251 emlxs_timer_stop(emlxs_hba_t *hba)
252 {
253 if (!hba->timer_id) {
254 return;
255 }
256
257 mutex_enter(&EMLXS_TIMER_LOCK);
258 hba->timer_flags |= EMLXS_TIMER_KILL;
259
260 while (hba->timer_id) {
261 mutex_exit(&EMLXS_TIMER_LOCK);
262 delay(drv_usectohz(500000));
263 mutex_enter(&EMLXS_TIMER_LOCK);
|
50 static void emlxs_timer_check_discovery(emlxs_port_t *port);
51 static void emlxs_timer_check_clean_address(emlxs_port_t *port);
52 static void emlxs_timer_check_ub(emlxs_port_t *port);
53 static void emlxs_timer_check_channels(emlxs_hba_t *hba, uint8_t *flag);
54 static uint32_t emlxs_pkt_chip_timeout(emlxs_port_t *port, emlxs_buf_t *sbp,
55 Q *abortq, uint8_t *flag);
56
57 #ifdef TX_WATCHDOG
58 static void emlxs_tx_watchdog(emlxs_hba_t *hba);
59 #endif /* TX_WATCHDOG */
60
61 extern clock_t
62 emlxs_timeout(emlxs_hba_t *hba, uint32_t timeout)
63 {
64 emlxs_config_t *cfg = &CFG;
65 clock_t time;
66
67 /* Set thread timeout */
68 if (cfg[CFG_TIMEOUT_ENABLE].current) {
69 (void) drv_getparm(LBOLT, &time);
70 time += drv_sectohz(timeout);
71 } else {
72 time = -1;
73 }
74
75 return (time);
76
77 } /* emlxs_timeout() */
78
79
80 static void
81 emlxs_timer(void *arg)
82 {
83 emlxs_hba_t *hba = (emlxs_hba_t *)arg;
84 emlxs_port_t *port = &PPORT;
85
86 if (!hba->timer_id) {
87 return;
88 }
89
90 mutex_enter(&EMLXS_TIMER_LOCK);
114 "Timer: io_active=0x%x. Reset to zero.", hba->io_active);
115 hba->io_active = 0;
116 }
117
118 mutex_exit(&EMLXS_TIMER_LOCK);
119
120 EMLXS_SLI_POLL_ERRATT(hba);
121
122 /* Perform standard checks */
123 emlxs_timer_checks(hba);
124
125 /* Restart the timer */
126 mutex_enter(&EMLXS_TIMER_LOCK);
127
128 hba->timer_flags &= ~EMLXS_TIMER_BUSY;
129
130 /* If timer is still enabled, restart it */
131 if (!(hba->timer_flags & EMLXS_TIMER_KILL)) {
132 hba->timer_id =
133 timeout(emlxs_timer, (void *)hba,
134 drv_sectohz(EMLXS_TIMER_PERIOD));
135 } else {
136 hba->timer_id = 0;
137 hba->timer_flags |= EMLXS_TIMER_ENDED;
138 }
139
140 mutex_exit(&EMLXS_TIMER_LOCK);
141
142 return;
143
144 } /* emlxs_timer() */
145
146
147 extern void
148 emlxs_timer_checks(emlxs_hba_t *hba)
149 {
150 emlxs_port_t *port = &PPORT;
151 uint8_t flag[MAX_CHANNEL];
152 uint32_t i;
153 uint32_t rc;
154
223 /* Always do this last */
224 emlxs_timer_check_channels(hba, flag);
225
226 return;
227
228 } /* emlxs_timer_checks() */
229
230
231 extern void
232 emlxs_timer_start(emlxs_hba_t *hba)
233 {
234 if (hba->timer_id) {
235 return;
236 }
237
238 /* Restart the timer */
239 mutex_enter(&EMLXS_TIMER_LOCK);
240 if (!hba->timer_id) {
241 hba->timer_flags = 0;
242 hba->timer_id =
243 timeout(emlxs_timer, (void *)hba, drv_sectohz(1));
244 }
245 mutex_exit(&EMLXS_TIMER_LOCK);
246
247 } /* emlxs_timer_start() */
248
249
250 extern void
251 emlxs_timer_stop(emlxs_hba_t *hba)
252 {
253 if (!hba->timer_id) {
254 return;
255 }
256
257 mutex_enter(&EMLXS_TIMER_LOCK);
258 hba->timer_flags |= EMLXS_TIMER_KILL;
259
260 while (hba->timer_id) {
261 mutex_exit(&EMLXS_TIMER_LOCK);
262 delay(drv_usectohz(500000));
263 mutex_enter(&EMLXS_TIMER_LOCK);
|