1*d14abf15SRobert Mustacchi /*
2*d14abf15SRobert Mustacchi * CDDL HEADER START
3*d14abf15SRobert Mustacchi *
4*d14abf15SRobert Mustacchi * The contents of this file are subject to the terms of the
5*d14abf15SRobert Mustacchi * Common Development and Distribution License (the "License").
6*d14abf15SRobert Mustacchi * You may not use this file except in compliance with the License.
7*d14abf15SRobert Mustacchi *
8*d14abf15SRobert Mustacchi * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*d14abf15SRobert Mustacchi * or http://www.opensolaris.org/os/licensing.
10*d14abf15SRobert Mustacchi * See the License for the specific language governing permissions
11*d14abf15SRobert Mustacchi * and limitations under the License.
12*d14abf15SRobert Mustacchi *
13*d14abf15SRobert Mustacchi * When distributing Covered Code, include this CDDL HEADER in each
14*d14abf15SRobert Mustacchi * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*d14abf15SRobert Mustacchi * If applicable, add the following below this CDDL HEADER, with the
16*d14abf15SRobert Mustacchi * fields enclosed by brackets "[]" replaced with your own identifying
17*d14abf15SRobert Mustacchi * information: Portions Copyright [yyyy] [name of copyright owner]
18*d14abf15SRobert Mustacchi *
19*d14abf15SRobert Mustacchi * CDDL HEADER END
20*d14abf15SRobert Mustacchi */
21*d14abf15SRobert Mustacchi
22*d14abf15SRobert Mustacchi /*
23*d14abf15SRobert Mustacchi * Copyright 2014 QLogic Corporation
24*d14abf15SRobert Mustacchi * The contents of this file are subject to the terms of the
25*d14abf15SRobert Mustacchi * QLogic End User License (the "License").
26*d14abf15SRobert Mustacchi * You may not use this file except in compliance with the License.
27*d14abf15SRobert Mustacchi *
28*d14abf15SRobert Mustacchi * You can obtain a copy of the License at
29*d14abf15SRobert Mustacchi * http://www.qlogic.com/Resources/Documents/DriverDownloadHelp/
30*d14abf15SRobert Mustacchi * QLogic_End_User_Software_License.txt
31*d14abf15SRobert Mustacchi * See the License for the specific language governing permissions
32*d14abf15SRobert Mustacchi * and limitations under the License.
33*d14abf15SRobert Mustacchi */
34*d14abf15SRobert Mustacchi
35*d14abf15SRobert Mustacchi /*
36*d14abf15SRobert Mustacchi * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
37*d14abf15SRobert Mustacchi */
38*d14abf15SRobert Mustacchi
39*d14abf15SRobert Mustacchi #include "bnxe.h"
40*d14abf15SRobert Mustacchi
41*d14abf15SRobert Mustacchi #define BNXE_TIMER_INTERVAL 1000000 /* usecs (once a second for stats) */
42*d14abf15SRobert Mustacchi
43*d14abf15SRobert Mustacchi
BnxeTimer(void * pArg)44*d14abf15SRobert Mustacchi static void BnxeTimer(void * pArg)
45*d14abf15SRobert Mustacchi {
46*d14abf15SRobert Mustacchi um_device_t * pUM = (um_device_t *)pArg;
47*d14abf15SRobert Mustacchi lm_device_t * pLM = &pUM->lm_dev;
48*d14abf15SRobert Mustacchi
49*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_TIMER(pUM);
50*d14abf15SRobert Mustacchi
51*d14abf15SRobert Mustacchi if (pUM->timerEnabled != B_TRUE)
52*d14abf15SRobert Mustacchi {
53*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_TIMER(pUM);
54*d14abf15SRobert Mustacchi return;
55*d14abf15SRobert Mustacchi }
56*d14abf15SRobert Mustacchi
57*d14abf15SRobert Mustacchi lm_stats_on_timer(pLM);
58*d14abf15SRobert Mustacchi
59*d14abf15SRobert Mustacchi if (pUM->fmCapabilities &&
60*d14abf15SRobert Mustacchi BnxeCheckAccHandle(pLM->vars.reg_handle[BAR_0]) != DDI_FM_OK)
61*d14abf15SRobert Mustacchi {
62*d14abf15SRobert Mustacchi ddi_fm_service_impact(pUM->pDev, DDI_SERVICE_UNAFFECTED);
63*d14abf15SRobert Mustacchi }
64*d14abf15SRobert Mustacchi
65*d14abf15SRobert Mustacchi if (pUM->phyInitialized)
66*d14abf15SRobert Mustacchi {
67*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_PHY(pUM);
68*d14abf15SRobert Mustacchi lm_link_on_timer(pLM);
69*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_PHY(pUM);
70*d14abf15SRobert Mustacchi }
71*d14abf15SRobert Mustacchi
72*d14abf15SRobert Mustacchi pUM->timerID = timeout(BnxeTimer, (void *)pUM,
73*d14abf15SRobert Mustacchi drv_usectohz(BNXE_TIMER_INTERVAL));
74*d14abf15SRobert Mustacchi
75*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_TIMER(pUM);
76*d14abf15SRobert Mustacchi }
77*d14abf15SRobert Mustacchi
78*d14abf15SRobert Mustacchi
BnxeTimerStart(um_device_t * pUM)79*d14abf15SRobert Mustacchi void BnxeTimerStart(um_device_t * pUM)
80*d14abf15SRobert Mustacchi {
81*d14abf15SRobert Mustacchi atomic_swap_32(&pUM->timerEnabled, B_TRUE);
82*d14abf15SRobert Mustacchi
83*d14abf15SRobert Mustacchi pUM->lm_dev.vars.stats.stats_collect.timer_wakeup = 0; /* reset */
84*d14abf15SRobert Mustacchi
85*d14abf15SRobert Mustacchi pUM->timerID = timeout(BnxeTimer, (void *)pUM,
86*d14abf15SRobert Mustacchi drv_usectohz(BNXE_TIMER_INTERVAL));
87*d14abf15SRobert Mustacchi }
88*d14abf15SRobert Mustacchi
89*d14abf15SRobert Mustacchi
BnxeTimerStop(um_device_t * pUM)90*d14abf15SRobert Mustacchi void BnxeTimerStop(um_device_t * pUM)
91*d14abf15SRobert Mustacchi {
92*d14abf15SRobert Mustacchi atomic_swap_32(&pUM->timerEnabled, B_FALSE);
93*d14abf15SRobert Mustacchi
94*d14abf15SRobert Mustacchi BNXE_LOCK_ENTER_TIMER(pUM);
95*d14abf15SRobert Mustacchi BNXE_LOCK_EXIT_TIMER(pUM);
96*d14abf15SRobert Mustacchi
97*d14abf15SRobert Mustacchi untimeout(pUM->timerID);
98*d14abf15SRobert Mustacchi pUM->timerID = 0;
99*d14abf15SRobert Mustacchi }
100*d14abf15SRobert Mustacchi
101