summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith M Wesolowski <wesolows@foobazco.org>2014-05-15 16:18:41 +0000
committerKeith M Wesolowski <wesolows@foobazco.org>2014-05-15 16:18:41 +0000
commitf125c60e1c7047c3d568fc34ed448d43f760e75a (patch)
treed87547d1820559dd56e298613d797f17512514a5
parent2c35e403d8156729ded2f36e04dccd3896bbe9c0 (diff)
parent4d6a58d3c7586ed5866f9309d460081a9102c5e6 (diff)
downloadillumos-joyent-f125c60e1c7047c3d568fc34ed448d43f760e75a.tar.gz
[illumos-gate merge]
commit 4d6a58d3c7586ed5866f9309d460081a9102c5e6 4788 mac shouldn't abuse ddi_get_time(9f) commit 12928d597a28b7743c3fc254b6fcfc05560c1720 4787 ipf: remove rate_limit_message commit e5815e7afac983d9ae9b2316e5056c8401cf7e5e 4782 usba shouldn't abuse ddi_get_time(9f) commit 7c64340fe7f813fbf9b6874c9422f7765bc54eb8 4781 sd shouldn't abuse ddi_get_time(9f) commit 55a3a0ef881a0e1c7da841d46bb5878758497dc1 4780 comstar iSCSI target shouldn't abuse ddi_get_time(9f) commit aa6577ebdcd1cd4be810e610056636f5df7904f9 4779 vhci shouldn't abuse ddi_get_time(9f) commit 0529d5c654f682ce87e4f74affd1c83c429c50e1 4778 iprb shouldn't abuse ddi_get_time(9f) commit e1d3217b9afde782c4d3e946fda0e6ef36a61306 4777 ibdm shouldn't abuse ddi_get_time(9f) commit 084f5824534451de5631228a9637b2c7bc7322cd 4776 man: don't lie about ddi_get_time(9f) uses
-rw-r--r--usr/src/man/man9f/ddi_get_time.9f11
-rw-r--r--usr/src/uts/common/inet/ipf/ip_fil_solaris.c38
-rw-r--r--usr/src/uts/common/io/comstar/port/iscsit/iscsit.c8
-rw-r--r--usr/src/uts/common/io/ib/mgt/ibdm/ibdm.c79
-rw-r--r--usr/src/uts/common/io/iprb/iprb.c20
-rw-r--r--usr/src/uts/common/io/iprb/iprb.h17
-rw-r--r--usr/src/uts/common/io/mac/mac_protect.c27
-rw-r--r--usr/src/uts/common/io/scsi/adapters/scsi_vhci/scsi_vhci.c18
-rw-r--r--usr/src/uts/common/io/scsi/targets/sd.c12
-rw-r--r--usr/src/uts/common/io/usb/usba/hubdi.c13
-rw-r--r--usr/src/uts/common/sys/ib/mgt/ibdm/ibdm_ibnex.h5
-rw-r--r--usr/src/uts/common/sys/idm/idm_impl.h4
-rw-r--r--usr/src/uts/common/sys/scsi/adapters/scsi_vhci.h9
-rw-r--r--usr/src/uts/common/sys/scsi/targets/sddef.h3
-rw-r--r--usr/src/uts/common/sys/usb/hubd/hubdvar.h7
15 files changed, 122 insertions, 149 deletions
diff --git a/usr/src/man/man9f/ddi_get_time.9f b/usr/src/man/man9f/ddi_get_time.9f
index 98cf61de0e..16b383c0c4 100644
--- a/usr/src/man/man9f/ddi_get_time.9f
+++ b/usr/src/man/man9f/ddi_get_time.9f
@@ -1,10 +1,11 @@
'\" te
.\" Copyright (c) 2000, Sun Microsystems, Inc.
+.\" Copyright (c) 2014, Nexenta Systems, Inc.
.\" All Rights Reserved
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH DDI_GET_TIME 9F "Feb 18, 1998"
+.TH DDI_GET_TIME 9F "Apr 15, 2014"
.SH NAME
ddi_get_time \- returns the current time in seconds
.SH SYNOPSIS
@@ -27,7 +28,10 @@ Solaris DDI specific (Solaris DDI).
.sp
.LP
\fBddi_get_time()\fR returns the current time in seconds since 00:00:00 UTC,
-January 1, 1970. This value can be used to set of wait or expiration intervals.
+January 1, 1970. Changes in time of day clock may result in this value
+changing. In other words, the value is not monotonically increasing and
+therefore it must not be used to set wait or expiration intervals. For that,
+instead use \fBddi_get_lbolt\fR(9F) or \fBgethrtime\fR(9F).
.SH RETURN VALUES
.sp
.LP
@@ -39,7 +43,8 @@ January 1, 1970. This value can be used to set of wait or expiration intervals.
.SH SEE ALSO
.sp
.LP
-\fBddi_get_lbolt\fR(9F), \fBdrv_getparm\fR(9F), \fBdrv_usectohz\fR(9F)
+\fBddi_get_lbolt\fR(9F), \fBdrv_getparm\fR(9F), \fBdrv_usectohz\fR(9F),
+\fBgethrtime\fR(9F)
.sp
.LP
\fIWriting Device Drivers\fR
diff --git a/usr/src/uts/common/inet/ipf/ip_fil_solaris.c b/usr/src/uts/common/inet/ipf/ip_fil_solaris.c
index 0de9c6fa18..51d592617b 100644
--- a/usr/src/uts/common/inet/ipf/ip_fil_solaris.c
+++ b/usr/src/uts/common/inet/ipf/ip_fil_solaris.c
@@ -1589,44 +1589,6 @@ int dst;
#include <stdio.h>
#endif
-#define NULLADDR_RATE_LIMIT 10 /* 10 seconds */
-
-
-/*
- * Print out warning message at rate-limited speed.
- */
-static void rate_limit_message(ipf_stack_t *ifs,
- int rate, const char *message, ...)
-{
- static time_t last_time = 0;
- time_t now;
- va_list args;
- char msg_buf[256];
- int need_printed = 0;
-
- now = ddi_get_time();
-
- /* make sure, no multiple entries */
- ASSERT(MUTEX_NOT_HELD(&(ifs->ifs_ipf_rw.ipf_lk)));
- MUTEX_ENTER(&ifs->ifs_ipf_rw);
- if (now - last_time >= rate) {
- need_printed = 1;
- last_time = now;
- }
- MUTEX_EXIT(&ifs->ifs_ipf_rw);
-
- if (need_printed) {
- va_start(args, message);
- (void)vsnprintf(msg_buf, 255, message, args);
- va_end(args);
-#ifdef _KERNEL
- cmn_err(CE_WARN, msg_buf);
-#else
- fprintf(std_err, msg_buf);
-#endif
- }
-}
-
/*
* Return the first IP Address associated with an interface
* For IPv6, we walk through the list of logical interfaces and return
diff --git a/usr/src/uts/common/io/comstar/port/iscsit/iscsit.c b/usr/src/uts/common/io/comstar/port/iscsit/iscsit.c
index 810311b7ee..1e852526c3 100644
--- a/usr/src/uts/common/io/comstar/port/iscsit/iscsit.c
+++ b/usr/src/uts/common/io/comstar/port/iscsit/iscsit.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*
- * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
#include <sys/cpuvar.h>
@@ -3125,7 +3125,7 @@ iscsit_check_cmdsn_and_queue(idm_pdu_t *rx_pdu)
* staging queue, the commands are processed out of the
* queue in cmdSN order only.
*/
- rx_pdu->isp_queue_time = ddi_get_time();
+ rx_pdu->isp_queue_time = gethrtime();
iscsit_add_pdu_to_queue(ist, rx_pdu);
mutex_exit(&ist->ist_sn_mutex);
return (ISCSIT_CMDSN_GT_EXPCMDSN);
@@ -3395,8 +3395,8 @@ iscsit_rxpdu_queue_monitor_session(iscsit_sess_t *ist)
* stop scanning the staging queue until the timer
* fires again
*/
- if ((ddi_get_time() - next_pdu->isp_queue_time)
- < rxpdu_queue_threshold) {
+ if ((gethrtime() - next_pdu->isp_queue_time)
+ < (rxpdu_queue_threshold * NANOSEC)) {
mutex_exit(&ist->ist_sn_mutex);
return;
}
diff --git a/usr/src/uts/common/io/ib/mgt/ibdm/ibdm.c b/usr/src/uts/common/io/ib/mgt/ibdm/ibdm.c
index cecccf987d..c28ce4c429 100644
--- a/usr/src/uts/common/io/ib/mgt/ibdm/ibdm.c
+++ b/usr/src/uts/common/io/ib/mgt/ibdm/ibdm.c
@@ -21,6 +21,9 @@
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
*/
+/*
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
+ */
/*
* ibdm.c
@@ -36,6 +39,7 @@
* HCA's and IOC's (behind the IOU) present on the IB fabric.
*/
+#include <sys/sysmacros.h>
#include <sys/systm.h>
#include <sys/taskq.h>
#include <sys/ib/mgt/ibdm/ibdm_impl.h>
@@ -971,7 +975,7 @@ ibdm_handle_hca_attach(ib_guid_t hca_guid)
(sizeof (ibdm_port_attr_t) * hca_attr->hca_nports), KM_SLEEP);
hca_list->hl_hca_guid = hca_attr->hca_node_guid;
hca_list->hl_nports = hca_attr->hca_nports;
- hca_list->hl_attach_time = ddi_get_time();
+ hca_list->hl_attach_time = gethrtime();
hca_list->hl_hca_hdl = hca_hdl;
/*
@@ -4691,11 +4695,13 @@ ibdm_ibnex_unregister_callback()
* ibdm_get_waittime()
* Calculates the wait time based on the last HCA attach time
*/
-static time_t
-ibdm_get_waittime(ib_guid_t hca_guid, int dft_wait)
+static clock_t
+ibdm_get_waittime(ib_guid_t hca_guid, int dft_wait_sec)
{
- int ii;
- time_t temp, wait_time = 0;
+ const hrtime_t dft_wait = dft_wait_sec * NANOSEC;
+ hrtime_t temp, wait_time = 0;
+ clock_t usecs;
+ int i;
ibdm_hca_list_t *hca;
IBTF_DPRINTF_L4("ibdm", "\tget_waittime hcaguid:%llx"
@@ -4705,56 +4711,43 @@ ibdm_get_waittime(ib_guid_t hca_guid, int dft_wait)
hca = ibdm.ibdm_hca_list_head;
- if (hca_guid) {
- for (ii = 0; ii < ibdm.ibdm_hca_count; ii++) {
- if ((hca_guid == hca->hl_hca_guid) &&
- (hca->hl_nports != hca->hl_nports_active)) {
- wait_time =
- ddi_get_time() - hca->hl_attach_time;
- wait_time = ((wait_time >= dft_wait) ?
- 0 : (dft_wait - wait_time));
- break;
- }
- hca = hca->hl_next;
- }
- IBTF_DPRINTF_L2("ibdm", "\tget_waittime: wait_time = %ld secs",
- (long)wait_time);
- return (wait_time);
- }
+ for (i = 0; i < ibdm.ibdm_hca_count; i++, hca = hca->hl_next) {
+ if (hca->hl_nports == hca->hl_nports_active)
+ continue;
- for (ii = 0; ii < ibdm.ibdm_hca_count; ii++) {
- if (hca->hl_nports != hca->hl_nports_active) {
- temp = ddi_get_time() - hca->hl_attach_time;
- temp = ((temp >= dft_wait) ? 0 : (dft_wait - temp));
- wait_time = (temp > wait_time) ? temp : wait_time;
+ if (hca_guid && (hca_guid != hca->hl_hca_guid))
+ continue;
+
+ temp = gethrtime() - hca->hl_attach_time;
+ temp = MAX(0, (dft_wait - temp));
+
+ if (hca_guid) {
+ wait_time = temp;
+ break;
}
- hca = hca->hl_next;
+
+ wait_time = MAX(temp, wait_time);
}
- IBTF_DPRINTF_L2("ibdm", "\tget_waittime: wait_time = %ld secs",
- (long)wait_time);
- return (wait_time);
+
+ /* convert to microseconds */
+ usecs = MIN(wait_time, dft_wait) / (NANOSEC / MICROSEC);
+
+ IBTF_DPRINTF_L2("ibdm", "\tget_waittime: wait_time = %ld usecs",
+ (long)usecs);
+
+ return (drv_usectohz(usecs));
}
void
ibdm_ibnex_port_settle_wait(ib_guid_t hca_guid, int dft_wait)
{
- time_t wait_time;
- clock_t delta;
+ clock_t wait_time;
mutex_enter(&ibdm.ibdm_hl_mutex);
- while ((wait_time = ibdm_get_waittime(hca_guid, dft_wait)) > 0) {
- if (wait_time > dft_wait) {
- IBTF_DPRINTF_L1("ibdm",
- "\tibnex_port_settle_wait: wait_time = %ld secs; "
- "Resetting to %d secs",
- (long)wait_time, dft_wait);
- wait_time = dft_wait;
- }
- delta = drv_usectohz(wait_time * 1000000);
+ while ((wait_time = ibdm_get_waittime(hca_guid, dft_wait)) > 0)
(void) cv_reltimedwait(&ibdm.ibdm_port_settle_cv,
- &ibdm.ibdm_hl_mutex, delta, TR_CLOCK_TICK);
- }
+ &ibdm.ibdm_hl_mutex, wait_time, TR_CLOCK_TICK);
mutex_exit(&ibdm.ibdm_hl_mutex);
}
diff --git a/usr/src/uts/common/io/iprb/iprb.c b/usr/src/uts/common/io/iprb/iprb.c
index 14952254b9..0dfcce6e12 100644
--- a/usr/src/uts/common/io/iprb/iprb.c
+++ b/usr/src/uts/common/io/iprb/iprb.c
@@ -298,8 +298,8 @@ iprb_attach(dev_info_t *dip)
/*
* Precalculate watchdog times.
*/
- ip->tx_timeout = drv_usectohz(TX_WATCHDOG * 1000000);
- ip->rx_timeout = drv_usectohz(RX_WATCHDOG * 1000000);
+ ip->tx_timeout = TX_WATCHDOG;
+ ip->rx_timeout = RX_WATCHDOG;
iprb_identify(ip);
@@ -703,7 +703,7 @@ iprb_cmd_reclaim(iprb_t *ip)
if (ip->cmd_count == 0) {
ip->tx_wdog = 0;
} else {
- ip->tx_wdog = ddi_get_time();
+ ip->tx_wdog = gethrtime();
}
}
}
@@ -775,7 +775,7 @@ iprb_cmd_submit(iprb_t *ip, uint16_t cmd)
PUT8(ip, CSR_CMD, CUC_RESUME);
(void) GET8(ip, CSR_CMD); /* flush CSR */
- ip->tx_wdog = ddi_get_time();
+ ip->tx_wdog = gethrtime();
ip->cmd_last = ip->cmd_head;
ip->cmd_head++;
ip->cmd_head %= NUM_TX;
@@ -1010,15 +1010,15 @@ void
iprb_update_stats(iprb_t *ip)
{
iprb_dma_t *sp = &ip->stats;
- time_t tstamp;
+ hrtime_t tstamp;
int i;
ASSERT(mutex_owned(&ip->culock));
/* Collect the hardware stats, but don't keep redoing it */
- if ((tstamp = ddi_get_time()) == ip->stats_time) {
+ tstamp = gethrtime();
+ if (tstamp / NANOSEC == ip->stats_time / NANOSEC)
return;
- }
PUTSTAT(sp, STATS_DONE_OFFSET, 0);
SYNCSTATS(sp, 0, 0, DDI_DMA_SYNC_FORDEV);
@@ -1174,7 +1174,7 @@ iprb_rx(iprb_t *ip)
break;
}
- ip->rx_wdog = ddi_get_time();
+ ip->rx_wdog = gethrtime();
SYNCRFD(rfd, 0, 0, DDI_DMA_SYNC_FORKERNEL);
cnt = GETRFD16(rfd, RFD_CNT_OFFSET);
@@ -1663,7 +1663,7 @@ iprb_periodic(void *arg)
*/
if (ip->rxhangbug &&
((ip->miih == NULL) || (mii_get_speed(ip->miih) == 10000000)) &&
- ((ddi_get_time() - ip->rx_wdog) > ip->rx_timeout)) {
+ ((gethrtime() - ip->rx_wdog) > ip->rx_timeout)) {
cmn_err(CE_CONT, "?Possible RU hang, resetting.\n");
reset = B_TRUE;
}
@@ -1671,7 +1671,7 @@ iprb_periodic(void *arg)
/* update the statistics */
mutex_enter(&ip->culock);
- if (ip->tx_wdog && ((ddi_get_time() - ip->tx_wdog) > ip->tx_timeout)) {
+ if (ip->tx_wdog && ((gethrtime() - ip->tx_wdog) > ip->tx_timeout)) {
/* transmit/CU hang? */
cmn_err(CE_CONT, "?CU stalled, resetting.\n");
reset = B_TRUE;
diff --git a/usr/src/uts/common/io/iprb/iprb.h b/usr/src/uts/common/io/iprb/iprb.h
index 572502955e..8d31e3a4d6 100644
--- a/usr/src/uts/common/io/iprb/iprb.h
+++ b/usr/src/uts/common/io/iprb/iprb.h
@@ -10,7 +10,7 @@
*/
/*
- * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
#ifndef _IPRB_H
@@ -26,8 +26,9 @@
#define NUM_TX 128 /* outstanding tx queue */
#define NUM_RX 128 /* outstanding rx queue */
-#define RX_WATCHDOG 15 /* timeout for rx watchdog (sec) */
-#define TX_WATCHDOG 15 /* timeout for tx watchdog (sec) */
+/* timeouts for the rx and tx watchdogs (nsec) */
+#define RX_WATCHDOG (15 * NANOSEC)
+#define TX_WATCHDOG (15 * NANOSEC)
/*
* Driver structures.
@@ -72,7 +73,7 @@ typedef struct iprb {
iprb_dma_t cmds[NUM_TX];
iprb_dma_t rxb[NUM_RX];
iprb_dma_t stats;
- time_t stats_time;
+ hrtime_t stats_time;
uint16_t cmd_head;
uint16_t cmd_last;
@@ -81,10 +82,10 @@ typedef struct iprb {
uint16_t rx_index;
uint16_t rx_last;
- time_t rx_wdog;
- time_t rx_timeout;
- time_t tx_wdog;
- time_t tx_timeout;
+ hrtime_t rx_wdog;
+ hrtime_t rx_timeout;
+ hrtime_t tx_wdog;
+ hrtime_t tx_timeout;
uint16_t eeprom_bits;
diff --git a/usr/src/uts/common/io/mac/mac_protect.c b/usr/src/uts/common/io/mac/mac_protect.c
index 3c3266ac1d..cd0219e2ef 100644
--- a/usr/src/uts/common/io/mac/mac_protect.c
+++ b/usr/src/uts/common/io/mac/mac_protect.c
@@ -23,6 +23,9 @@
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, Joyent, Inc. All rights reserved.
*/
+/*
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
+ */
#include <sys/strsun.h>
#include <sys/sdt.h>
@@ -142,7 +145,7 @@
*/
static ulong_t dhcp_max_pending_txn = 512;
static ulong_t dhcp_max_completed_txn = 512;
-static time_t txn_cleanup_interval = 60;
+static hrtime_t txn_cleanup_interval = 60 * NANOSEC;
/*
* DHCPv4 transaction. It may be added to three different tables
@@ -150,7 +153,7 @@ static time_t txn_cleanup_interval = 60;
*/
typedef struct dhcpv4_txn {
uint32_t dt_xid;
- time_t dt_timestamp;
+ hrtime_t dt_timestamp;
uint8_t dt_cid[DHCP_MAX_OPT_SIZE];
uint8_t dt_cid_len;
ipaddr_t dt_ipaddr;
@@ -187,7 +190,7 @@ typedef struct dhcpv6_cid {
*/
typedef struct dhcpv6_txn {
uint32_t dt_xid;
- time_t dt_timestamp;
+ hrtime_t dt_timestamp;
dhcpv6_cid_t *dt_cid;
avl_node_t dt_node;
struct dhcpv6_txn *dt_next;
@@ -456,7 +459,7 @@ create_dhcpv4_txn(uint32_t xid, uint8_t *cid, uint8_t cid_len, ipaddr_t ipaddr)
return (NULL);
txn->dt_xid = xid;
- txn->dt_timestamp = ddi_get_time();
+ txn->dt_timestamp = gethrtime();
if (cid_len > 0)
bcopy(cid, &txn->dt_cid, cid_len);
txn->dt_cid_len = cid_len;
@@ -513,8 +516,7 @@ txn_cleanup_v4(mac_client_impl_t *mcip)
*/
for (txn = avl_first(&mcip->mci_v4_pending_txn); txn != NULL;
txn = avl_walk(&mcip->mci_v4_pending_txn, txn, AVL_AFTER)) {
- if (ddi_get_time() - txn->dt_timestamp >
- txn_cleanup_interval) {
+ if (gethrtime() - txn->dt_timestamp > txn_cleanup_interval) {
DTRACE_PROBE2(found__expired__txn,
mac_client_impl_t *, mcip,
dhcpv4_txn_t *, txn);
@@ -618,7 +620,7 @@ intercept_dhcpv4_outbound(mac_client_impl_t *mcip, ipha_t *ipha, uchar_t *end)
if ((txn = find_dhcpv4_pending_txn(mcip, dh4->xid)) != NULL) {
DTRACE_PROBE2(update, mac_client_impl_t *, mcip,
dhcpv4_txn_t *, txn);
- txn->dt_timestamp = ddi_get_time();
+ txn->dt_timestamp = gethrtime();
goto done;
}
@@ -1117,7 +1119,7 @@ create_dhcpv6_txn(uint32_t xid, dhcpv6_cid_t *cid)
txn->dt_xid = xid;
txn->dt_cid = cid;
- txn->dt_timestamp = ddi_get_time();
+ txn->dt_timestamp = gethrtime();
return (txn);
}
@@ -1184,8 +1186,7 @@ txn_cleanup_v6(mac_client_impl_t *mcip)
*/
for (txn = avl_first(&mcip->mci_v6_pending_txn); txn != NULL;
txn = avl_walk(&mcip->mci_v6_pending_txn, txn, AVL_AFTER)) {
- if (ddi_get_time() - txn->dt_timestamp >
- txn_cleanup_interval) {
+ if (gethrtime() - txn->dt_timestamp > txn_cleanup_interval) {
DTRACE_PROBE2(found__expired__txn,
mac_client_impl_t *, mcip,
dhcpv6_txn_t *, txn);
@@ -1249,7 +1250,7 @@ intercept_dhcpv6_outbound(mac_client_impl_t *mcip, ip6_t *ip6h, uchar_t *end)
if ((txn = find_dhcpv6_pending_txn(mcip, xid)) != NULL) {
DTRACE_PROBE2(update, mac_client_impl_t *, mcip,
dhcpv6_txn_t *, txn);
- txn->dt_timestamp = ddi_get_time();
+ txn->dt_timestamp = gethrtime();
goto done;
}
if ((txn = create_dhcpv6_txn(xid, cid)) == NULL)
@@ -1358,7 +1359,7 @@ txn_cleanup_timer(void *arg)
DTRACE_PROBE1(restarting__timer, mac_client_impl_t *, mcip);
mcip->mci_txn_cleanup_tid = timeout(txn_cleanup_timer, mcip,
- drv_usectohz(txn_cleanup_interval * 1000000));
+ drv_usectohz(txn_cleanup_interval / (NANOSEC / MICROSEC)));
}
mutex_exit(&mcip->mci_protect_lock);
}
@@ -1369,7 +1370,7 @@ start_txn_cleanup_timer(mac_client_impl_t *mcip)
ASSERT(MUTEX_HELD(&mcip->mci_protect_lock));
if (mcip->mci_txn_cleanup_tid == 0) {
mcip->mci_txn_cleanup_tid = timeout(txn_cleanup_timer, mcip,
- drv_usectohz(txn_cleanup_interval * 1000000));
+ drv_usectohz(txn_cleanup_interval / (NANOSEC / MICROSEC)));
}
}
diff --git a/usr/src/uts/common/io/scsi/adapters/scsi_vhci/scsi_vhci.c b/usr/src/uts/common/io/scsi/adapters/scsi_vhci/scsi_vhci.c
index 8808e30130..00668133ec 100644
--- a/usr/src/uts/common/io/scsi/adapters/scsi_vhci/scsi_vhci.c
+++ b/usr/src/uts/common/io/scsi/adapters/scsi_vhci/scsi_vhci.c
@@ -21,6 +21,9 @@
/*
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
*/
+/*
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
+ */
/*
* Multiplexed I/O SCSI vHCI implementation
@@ -2226,7 +2229,6 @@ vhci_bind_transport(struct scsi_address *ap, struct vhci_pkt *vpkt, int flags,
int held;
int mps_flag = MDI_SELECT_ONLINE_PATH;
struct scsi_vhci_lun *vlun;
- time_t tnow;
int path_instance = 0;
vlun = ADDR2VLUN(ap);
@@ -2364,7 +2366,7 @@ try_again:
if ((rval != MDI_SUCCESS) || (pip == NULL)) {
if (vlun->svl_waiting_for_activepath == 0) {
vlun->svl_waiting_for_activepath = 1;
- vlun->svl_wfa_time = ddi_get_time();
+ vlun->svl_wfa_time = gethrtime();
}
mps_flag |= MDI_SELECT_STANDBY_PATH;
rval = mdi_select_path(cdip,
@@ -2396,8 +2398,8 @@ try_again:
* show up obviating the need for a
* failover
*/
- tnow = ddi_get_time();
- if (tnow - vlun->svl_wfa_time >= 60) {
+ if ((gethrtime() - vlun->svl_wfa_time) >=
+ (60 * NANOSEC)) {
vlun->svl_waiting_for_activepath = 0;
} else {
drv_usecwait(1000);
@@ -3624,7 +3626,7 @@ vhci_handle_ext_fo(struct scsi_pkt *pkt, int fostat)
return (PKT_RETURN);
}
swarg->svs_svp = svp;
- swarg->svs_tos = ddi_get_time();
+ swarg->svs_tos = gethrtime();
swarg->svs_pi = vpkt->vpkt_path;
swarg->svs_release_lun = 0;
swarg->svs_done = 0;
@@ -3685,7 +3687,7 @@ vhci_efo_watch_cb(caddr_t arg, struct scsi_watch_result *resultp)
updt_paths = 0;
if (pkt->pkt_reason != CMD_CMPLT) {
- if ((ddi_get_time() - swarg->svs_tos) >= VHCI_EXTFO_TIMEOUT) {
+ if ((gethrtime() - swarg->svs_tos) >= VHCI_EXTFO_TIMEOUT) {
swarg->svs_release_lun = 1;
goto done;
}
@@ -3707,7 +3709,7 @@ vhci_efo_watch_cb(caddr_t arg, struct scsi_watch_result *resultp)
updt_paths = 1;
break;
default:
- if ((ddi_get_time() - swarg->svs_tos)
+ if ((gethrtime() - swarg->svs_tos)
>= VHCI_EXTFO_TIMEOUT) {
swarg->svs_release_lun = 1;
goto done;
@@ -3739,7 +3741,7 @@ vhci_efo_watch_cb(caddr_t arg, struct scsi_watch_result *resultp)
KM_SLEEP);
return (0);
}
- if ((ddi_get_time() - swarg->svs_tos) >= VHCI_EXTFO_TIMEOUT) {
+ if ((gethrtime() - swarg->svs_tos) >= VHCI_EXTFO_TIMEOUT) {
swarg->svs_release_lun = 1;
goto done;
}
diff --git a/usr/src/uts/common/io/scsi/targets/sd.c b/usr/src/uts/common/io/scsi/targets/sd.c
index adeb59c87f..dc5dc22e37 100644
--- a/usr/src/uts/common/io/scsi/targets/sd.c
+++ b/usr/src/uts/common/io/scsi/targets/sd.c
@@ -25,7 +25,7 @@
/*
* Copyright (c) 2011 Bayard G. Bell. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
- * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
* Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
*/
/*
@@ -6604,10 +6604,9 @@ sd_pm_state_change(struct sd_lun *un, int level, int flag)
static void
sd_pm_idletimeout_handler(void *arg)
{
+ const hrtime_t idletime = sd_pm_idletime * NANOSEC;
struct sd_lun *un = arg;
- time_t now;
-
mutex_enter(&sd_detach_mutex);
if (un->un_detach_count != 0) {
/* Abort if the instance is detaching */
@@ -6616,14 +6615,13 @@ sd_pm_idletimeout_handler(void *arg)
}
mutex_exit(&sd_detach_mutex);
- now = ddi_get_time();
/*
* Grab both mutexes, in the proper order, since we're accessing
* both PM and softstate variables.
*/
mutex_enter(SD_MUTEX(un));
mutex_enter(&un->un_pm_mutex);
- if (((now - un->un_pm_idle_time) > sd_pm_idletime) &&
+ if (((gethrtime() - un->un_pm_idle_time) > idletime) &&
(un->un_ncmds_in_driver == 0) && (un->un_pm_count == 0)) {
/*
* Update the chain types.
@@ -12524,7 +12522,7 @@ sd_buf_iodone(int index, struct sd_lun *un, struct buf *bp)
* This is for lowering the overhead, and therefore improving
* performance per I/O operation.
*/
- un->un_pm_idle_time = ddi_get_time();
+ un->un_pm_idle_time = gethrtime();
un->un_ncmds_in_driver--;
ASSERT(un->un_ncmds_in_driver >= 0);
@@ -12574,7 +12572,7 @@ sd_uscsi_iodone(int index, struct sd_lun *un, struct buf *bp)
* This is for lowering the overhead, and therefore improving
* performance per I/O operation.
*/
- un->un_pm_idle_time = ddi_get_time();
+ un->un_pm_idle_time = gethrtime();
un->un_ncmds_in_driver--;
ASSERT(un->un_ncmds_in_driver >= 0);
diff --git a/usr/src/uts/common/io/usb/usba/hubdi.c b/usr/src/uts/common/io/usb/usba/hubdi.c
index de454de41c..132b27bb16 100644
--- a/usr/src/uts/common/io/usb/usba/hubdi.c
+++ b/usr/src/uts/common/io/usb/usba/hubdi.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
/*
@@ -749,7 +750,7 @@ hubd_can_suspend(hubd_t *hubd)
* Don't go to lower power if haven't been at full power for enough
* time to let hotplug thread kickoff.
*/
- if (ddi_get_time() < (hubpm->hubp_time_at_full_power +
+ if (gethrtime() < (hubpm->hubp_time_at_full_power +
hubpm->hubp_min_pm_threshold)) {
return (USB_FAILURE);
@@ -1720,7 +1721,7 @@ hubd_pwrlvl3(hubd_t *hubd)
ASSERT(rval == USB_SUCCESS);
hubd->h_dev_state = USB_DEV_ONLINE;
hubpm->hubp_current_power = USB_DEV_OS_FULL_PWR;
- hubpm->hubp_time_at_full_power = ddi_get_time();
+ hubpm->hubp_time_at_full_power = gethrtime();
hubd_start_polling(hubd, 0);
/* FALLTHRU */
@@ -3712,7 +3713,7 @@ hubd_hotplug_thread(void *arg)
/* mark the root hub as full power */
hubpm->hubp_current_power = USB_DEV_OS_FULL_PWR;
- hubpm->hubp_time_at_full_power = ddi_get_time();
+ hubpm->hubp_time_at_full_power = gethrtime();
mutex_exit(HUBD_MUTEX(hubd));
USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle,
@@ -7273,8 +7274,8 @@ hubd_create_pm_components(dev_info_t *dip, hubd_t *hubd)
hubpm->hubp_hubd = hubd;
hubpm->hubp_pm_capabilities = 0;
hubpm->hubp_current_power = USB_DEV_OS_FULL_PWR;
- hubpm->hubp_time_at_full_power = ddi_get_time();
- hubpm->hubp_min_pm_threshold = hubdi_min_pm_threshold;
+ hubpm->hubp_time_at_full_power = gethrtime();
+ hubpm->hubp_min_pm_threshold = hubdi_min_pm_threshold * NANOSEC;
/* alloc memory to save power states of children */
hubpm->hubp_child_pwrstate = (uint8_t *)
@@ -8709,7 +8710,7 @@ hubd_reset_thread(void *arg)
/* mark the root hub as full power */
hubpm->hubp_current_power = USB_DEV_OS_FULL_PWR;
- hubpm->hubp_time_at_full_power = ddi_get_time();
+ hubpm->hubp_time_at_full_power = gethrtime();
mutex_exit(HUBD_MUTEX(hubd));
USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle,
diff --git a/usr/src/uts/common/sys/ib/mgt/ibdm/ibdm_ibnex.h b/usr/src/uts/common/sys/ib/mgt/ibdm/ibdm_ibnex.h
index 4929c10142..63f0768b59 100644
--- a/usr/src/uts/common/sys/ib/mgt/ibdm/ibdm_ibnex.h
+++ b/usr/src/uts/common/sys/ib/mgt/ibdm/ibdm_ibnex.h
@@ -22,6 +22,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
+ */
#ifndef _SYS_IB_MGT_IBDM_IBDM_IBNEX_H
#define _SYS_IB_MGT_IBDM_IBDM_IBNEX_H
@@ -215,7 +218,7 @@ typedef struct ibdm_hca_list_s {
ib_guid_t hl_hca_guid; /* HCA GUID */
uint32_t hl_nports; /* #ports of this HCA */
uint32_t hl_nports_active; /* #ports active */
- time_t hl_attach_time; /* attach time */
+ hrtime_t hl_attach_time; /* attach time */
ibt_hca_hdl_t hl_hca_hdl; /* HCA handle */
ibdm_port_attr_t *hl_hca_port_attr; /* Dummy Port Attr */
/* for HCA node */
diff --git a/usr/src/uts/common/sys/idm/idm_impl.h b/usr/src/uts/common/sys/idm/idm_impl.h
index 72641bbfad..87d3674ad1 100644
--- a/usr/src/uts/common/sys/idm/idm_impl.h
+++ b/usr/src/uts/common/sys/idm/idm_impl.h
@@ -22,7 +22,7 @@
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
- * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
#ifndef _IDM_IMPL_H_
@@ -377,7 +377,7 @@ typedef struct idm_pdu_s {
uint32_t isp_flags;
uint_t isp_hdrbuflen;
uint_t isp_databuflen;
- time_t isp_queue_time;
+ hrtime_t isp_queue_time;
/* Taskq dispatching state for deferred PDU */
taskq_ent_t isp_tqent;
diff --git a/usr/src/uts/common/sys/scsi/adapters/scsi_vhci.h b/usr/src/uts/common/sys/scsi/adapters/scsi_vhci.h
index 3f8b8f8229..d8d22c6802 100644
--- a/usr/src/uts/common/sys/scsi/adapters/scsi_vhci.h
+++ b/usr/src/uts/common/sys/scsi/adapters/scsi_vhci.h
@@ -22,6 +22,9 @@
/*
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
*/
+/*
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
+ */
#ifndef _SYS_SCSI_ADAPTERS_SCSI_VHCI_H
#define _SYS_SCSI_ADAPTERS_SCSI_VHCI_H
@@ -65,7 +68,7 @@ extern "C" {
#define TRAN2HBAPRIVATE(tran) ((struct scsi_vhci *)(tran)->tran_hba_private)
#define VHCI_INIT_WAIT_TIMEOUT 60000000
#define VHCI_FOWATCH_INTERVAL 1000000 /* in usecs */
-#define VHCI_EXTFO_TIMEOUT 3*60 /* 3 minutes */
+#define VHCI_EXTFO_TIMEOUT (3 * 60 * NANOSEC) /* 3 minutes in nsec */
#define SCBP_C(pkt) ((*(pkt)->pkt_scbp) & STATUS_MASK)
@@ -316,7 +319,7 @@ typedef struct scsi_vhci_lun {
* is still comng up
*/
int svl_waiting_for_activepath;
- time_t svl_wfa_time;
+ hrtime_t svl_wfa_time;
/*
* to keep the failover status in order to return the
@@ -462,7 +465,7 @@ typedef struct scsi_vhci_priv {
*/
typedef struct scsi_vhci_swarg {
scsi_vhci_priv_t *svs_svp;
- time_t svs_tos; /* time of submission */
+ hrtime_t svs_tos; /* time of submission */
mdi_pathinfo_t *svs_pi; /* pathinfo being "watched" */
int svs_release_lun;
int svs_done;
diff --git a/usr/src/uts/common/sys/scsi/targets/sddef.h b/usr/src/uts/common/sys/scsi/targets/sddef.h
index fde714789c..39c0ed9d0f 100644
--- a/usr/src/uts/common/sys/scsi/targets/sddef.h
+++ b/usr/src/uts/common/sys/scsi/targets/sddef.h
@@ -23,6 +23,7 @@
*/
/*
* Copyright 2011 cyril.galibern@opensvc.com
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
#ifndef _SYS_SCSI_TARGETS_SDDEF_H
@@ -516,7 +517,7 @@ struct sd_lun {
timeout_id_t un_retry_timeid;
- time_t un_pm_idle_time;
+ hrtime_t un_pm_idle_time;
timeout_id_t un_pm_idle_timeid;
/*
diff --git a/usr/src/uts/common/sys/usb/hubd/hubdvar.h b/usr/src/uts/common/sys/usb/hubd/hubdvar.h
index 3c85cefd51..3463ff2a8b 100644
--- a/usr/src/uts/common/sys/usb/hubd/hubdvar.h
+++ b/usr/src/uts/common/sys/usb/hubd/hubdvar.h
@@ -22,6 +22,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
+ */
#ifndef _SYS_USB_HUBDVAR_H
#define _SYS_USB_HUBDVAR_H
@@ -91,9 +94,9 @@ typedef struct hub_power_struct {
uint8_t hubp_current_power; /* current power level */
- time_t hubp_time_at_full_power; /* timestamp 0->3 */
+ hrtime_t hubp_time_at_full_power; /* timestamp 0->3 */
- uint8_t hubp_min_pm_threshold; /* in seconds */
+ hrtime_t hubp_min_pm_threshold; /* in nanoseconds */
/* power state of all children are tracked here */
uint8_t *hubp_child_pwrstate;