Files @ d6b9b2ac5869
Branch filter:

Location: vmkdrivers/BLD/build/HEADERS/vmkapi-current-all-public-bincomp/vmkernel64/release/base/vmkapi_time.h

unknown
ESXi-5.5-U2
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
/* **********************************************************
 * Copyright 2007 - 2010 VMware, Inc.  All rights reserved.
 * **********************************************************/

/*
 * @VMKAPIMOD_LICENSE@
 */

/*
 ***********************************************************************
 * Time                                                           */ /**
 *
 * \addtogroup Core
 * @{
 * \defgroup Time Time and Timers
 *
 * @{
 ***********************************************************************
 */

#ifndef _VMKAPI_TIME_H_
#define _VMKAPI_TIME_H_

/** \cond never */
#ifndef VMK_HEADER_INCLUDED_FROM_VMKAPI_H
#error This vmkapi file should never be included directly but only via vmkapi.h
#endif
/** \endcond never */

/** \brief Known invalid value for a timer */
#define VMK_INVALID_TIMER ((vmk_Timer)NULL)

/** \brief Known invalid value for a timer queue */
#define VMK_INVALID_TIMER_QUEUE ((vmk_TimerQueue)NULL)

typedef vmk_int64  vmk_TimerRelCycles;
typedef vmk_uint64 vmk_TimerCycles;

typedef vmk_AddrCookie vmk_TimerCookie;
typedef struct vmk_TimerInt *vmk_Timer;
typedef struct vmk_TimerQueueInt *vmk_TimerQueue;

/**
 * \brief Representation for Time
 */
typedef struct {
   vmk_int64 sec;                /* seconds */
   vmk_int64 usec;               /* microseconds */
} vmk_TimeVal;

/**
 * \brief Attributes dictating timer queue behavior
 */
typedef vmk_uint64 vmk_TimerQueueAttributes;

/** normal timer queue */
#define VMK_TIMER_QUEUE_ATTR_NONE (0)

/** low latency timer queue */
#define VMK_TIMER_QUEUE_ATTR_LOW_LATENCY (1 << 0)

/**
 * \brief Properties for a new timer queue
 */
typedef struct {
   vmk_Name name;
   vmk_ModuleID moduleID;
   vmk_HeapID heapID;
   vmk_TimerQueueAttributes attribs;
} vmk_TimerQueueProps;

/**
 * \brief Timer Attributes
 */
typedef vmk_uint64 vmk_TimerAttributes;

/** One shot timer */
#define VMK_TIMER_ATTR_NONE     (0)
/** Periodic timer */
#define VMK_TIMER_ATTR_PERIODIC (1 << 0)
/** Default tolerance value */
#define VMK_TIMER_DEFAULT_TOLERANCE  (-1)


/* Convenient time constants */
#define VMK_USEC_PER_SEC         1000000
#define VMK_MSEC_PER_SEC         1000
#define VMK_USEC_PER_MSEC        1000

/* Constants for specifying special timeouts. */

/**
 * \brief Constant for specifying a nonblocking timeout.
 */
#define VMK_TIMEOUT_NONBLOCKING (0)

/**
 * \brief Constant for specifying an unlimited timeout.
 */
#define VMK_TIMEOUT_UNLIMITED_MS (VMK_UINT32_MAX)


/*
 ***********************************************************************
 * vmk_TimerCallback --                                           */ /**
 *
 * \brief Callback function invoked when timer fires.
 *
 * \note This callback is allowed to block; however, ready timers on
 *       the same vmk_TimerQueue will not fire until the firing timer
 *       has finished, so blocking in this callback may delay other
 *       scheduled timers.
 *
 * \param[in] data  vmk_TimerCookie provided when timer scheduled.
 *
 ***********************************************************************
 */
typedef void (*vmk_TimerCallback)(vmk_TimerCookie data);


/*
 ***********************************************************************
 * vmk_GetTimerCycles --                                          */ /**
 *
 * \brief Return the time elapsed since the VMKernel was loaded.
 *
 * The time is obtained from a clock that is fast to read (typically
 * under 100 CPU cycles) but that may not be exactly synchronized
 * across different physical CPUs.  Therefore, time may appear to go
 * backward slightly (typically less than 100 usec) if you compare
 * readings taken close together in time on different PCPUs.  Most
 * applications can deal with this behavior by always treating the
 * difference between two times as a signed quantity and (if needed)
 * treating a negative difference as zero.  See also vmk_GetUptime.
 *
 * \note  This function will not block.
 *
 ***********************************************************************
 */
vmk_TimerCycles vmk_GetTimerCycles(void);

/*
 ***********************************************************************
 * vmk_TimerCyclesPerSecond --                                    */ /**
 *
 * \brief Return the frequency in Hz of the vmk_GetTimerCycles() clock.
 *
 * \note  This function will not block.
 *
 ***********************************************************************
 */
vmk_uint64 vmk_TimerCyclesPerSecond(void);

/*
 ***********************************************************************
 * vmk_TimerUSToTC --                                             */ /**
 *
 * \brief Convert signed microseconds into signed timer cycles.
 *
 * \note  This function will not block.
 *
 ***********************************************************************
 */
vmk_TimerRelCycles vmk_TimerUSToTC(
   vmk_int64 us);

/*
 ***********************************************************************
 * vmk_TimerTCToUS --                                             */ /**
 *
 * \brief Convert signed timer cycles into signed microseconds.
 *
 * \note  This function will not block.
 *
 ***********************************************************************
 */
vmk_int64 vmk_TimerTCToUS(
   vmk_TimerRelCycles cycles);

/*
 ***********************************************************************
 * vmk_TimerMSToTC --                                             */ /**
 *
 * \brief Convert signed milliseconds into signed timer cycles.
 *
 * \note  This function will not block.
 *
 ***********************************************************************
 */
vmk_TimerRelCycles vmk_TimerMSToTC(
   vmk_int64 ms);

/*
 ***********************************************************************
 * vmk_TimerTCToMS --                                             */ /**
 *
 * \brief Convert signed timer cycles into signed milliseconds.
 *
 * \note  This function will not block.
 *
 ***********************************************************************
 */
vmk_int64 vmk_TimerTCToMS(
   vmk_TimerRelCycles cycles);

/*
 ***********************************************************************
 * vmk_TimerUnsignedUSToTC --                                     */ /**
 *
 * \brief Convert unsigned microseconds into unsigned timer cycles.
 *
 * \note  This function will not block.
 *
 ***********************************************************************
 */
vmk_TimerCycles vmk_TimerUnsignedUSToTC(
   vmk_uint64 us);

/*
 ***********************************************************************
 * vmk_TimerUnsignedTCToUS --                                     */ /**
 *
 * \brief Convert unsigned timer cycles into unsigned microseconds.
 *
 * \note  This function will not block.
 *
 ***********************************************************************
 */
vmk_uint64 vmk_TimerUnsignedTCToUS(
   vmk_TimerCycles cycles);

/*
 ***********************************************************************
 * vmk_TimerUnsignedMSToTC --                                     */ /**
 *
 * \brief Convert unsigned millieconds into unsigned timer cycles.
 *
 * \note  This function will not block.
 *
 ***********************************************************************
 */
vmk_TimerCycles vmk_TimerUnsignedMSToTC(
   vmk_uint64 ms);

/*
 ***********************************************************************
 * vmk_TimerUnsignedTCToMS --                                     */ /**
 *
 * \brief Convert unsigned timer cycles into unsigned milliseconds.
 *
 * \note  This function will not block.
 *
 ***********************************************************************
 */
vmk_uint64 vmk_TimerUnsignedTCToMS(
   vmk_TimerCycles cycles);

/*
 ***********************************************************************
 * VMK_ABS_TIMEOUT_MS --                                          */ /**
 *
 * \brief Convert a delay in milliseconds into an absolute timeout in
 *        milliseconds.
 *
 * \param[in] delay_ms  Millisecond delay to convert to absolute time.
 *
 * \return If delay_ms is nonzero, returns the absolute time in
 *         milliseconds that is delay_ms from the time of the call.  If
 *         delay_ms is 0, returns 0, avoiding a call to vmk_GetTimerCycles.
 *
 ***********************************************************************
 */
#define VMK_ABS_TIMEOUT_MS(delay_ms) \
   ((delay_ms) ? vmk_TimerUnsignedTCToMS(vmk_GetTimerCycles()) + (delay_ms) : 0)

/*
 ***********************************************************************
 * vmk_GetTimeOfDay --                                            */ /**
 *
 * \brief Get the time in vmk_TimeVal representation.
 *
 * \note  This function will not block.
 *
 ***********************************************************************
 */
void vmk_GetTimeOfDay(
   vmk_TimeVal *tv);

/*
 ***********************************************************************
 * vmk_GetUptime --                                               */ /**
 *
 * \brief Get the uptime in vmk_TimeVal representation.
 *
 * vmk_GetUptime returns the system uptime as measured by a
 * rate-corrected clock.  The zero point is the same as that of
 * vmk_GetTimerCycles, but a rate correction computed by the system's
 * clock synchronization daemon is applied to measure the uptime more
 * accurately.  Note that this implies vmk_GetUptime may run slightly
 * faster or slower than vmk_GetTimerCycles.  Unlike
 * vmk_GetTimerCycles, vmk_GetUptime contains internal synchronization
 * that ensures it cannot appear to go backward even if you compare
 * readings taken on different physical CPUs.  Unlike
 * vmk_GetTimeOfDay, which is rate-corrected in the same way but also
 * can be reset from user space by the settimeofday system call,
 * vmk_GetUptime always moves forward smoothly.  The synchronization
 * and rate-correction make vmk_GetUptime slower to read than
 * vmk_GetTimerCycles.
 *
 * \note  This function will not block.
 *
 ***********************************************************************
 */
void vmk_GetUptime(
   vmk_TimeVal *tv);

/*
 ***********************************************************************
 * vmk_DelayUsecs --                                            */ /**
 *
 * \brief Spin-wait for a specified number of microseconds.
 *
 * \note  This function will not block.
 *
 ***********************************************************************
 */
void vmk_DelayUsecs(
   vmk_uint32 uSecs);


/*
 ***********************************************************************
 * vmk_TimerScheduleCustom --                                     */ /**
 *
 * \brief Schedule a timer
 *
 * The VMKernel can schedule simultaneously a limited number of timers
 * for each CPU.
 *
 * \note  This function will not block.
 *
 * \warning Timers are a limited resource.  The VMKernel does not
 *          guarantee to provide more than 100 concurrent timers per CPU
 *          system-wide, and exceeding the limit is a fatal error.
 *
 * \param[in]  moduleID    ID of the module to which callback belongs
 * \param[in]  queue       The timer queue to use for the timer
 * \param[in]  callback    Timer callback.
 * \param[in]  data        Argument passed to the timer callback on
 *                         timeout.
 * \param[in]  timeoutUS   Timeout in microseconds.
 * \param[in]  toleranceUS Tolerance in microseconds.  Indicates a
 *                         request that the timer fire approximately
 *                         no later than the provided value from the
 *                         requested time.  The majority of callers
 *                         should specify a tolerance of
 *                         VMK_TIMER_DEFAULT_TOLERANCE and only use
 *                         other values for timers that have strict
 *                         timing requirements.
 * \param[in]  attributes  Additional timer attributes
 * \param[in]  lockDomain  Lock domain in which to check the lock rank.
 *                         Note that if lockDomain is set to invalid
 *                         then rank has to be set to unranked and if
 *                         lockDomain is set to a valid value then
 *                         rank has to contain a valid rank value.
 * \param[in]  lockRank    Rank of the timer
 * \param[out] wasPending  If rescheduling a timer, was it previously
 *                         pending? (optional)
 * \param[out] timer       Timer Handle
 *
 * \retval VMK_NO_RESOURCES Couldn't schedule the timer.
 * \retval VMK_OK           The timer was successfully scheduled.
 *
 ***********************************************************************
 */

VMK_ReturnStatus vmk_TimerScheduleCustom(
   vmk_ModuleID moduleID,
   vmk_TimerQueue queue,
   vmk_TimerCallback callback,
   vmk_TimerCookie data,
   vmk_int64 timeoutUS,
   vmk_int64 toleranceUS,
   vmk_TimerAttributes attributes,
   vmk_LockDomainID lockDomain,
   vmk_LockRank lockRank,
   vmk_Bool *wasPending,
   vmk_Timer *timer);


/*
 ***********************************************************************
 * vmk_TimerSchedule --                                           */ /**
 *
 * \brief Schedule a timer
 *
 * The VMKernel can schedule simultaneously a limited number of timers
 * for each CPU.
 *
 * \note  This function will not block.
 *
 * \warning Timers are a limited resource.  The VMKernel does not
 *          guarantee to provide more than 100 concurrent timers per CPU
 *          system-wide, and exceeding the limit is a fatal error.
 *
 * \param[in]  queue       The timer queue to use for the timer
 * \param[in]  callback    Timer callback.
 * \param[in]  data        Argument passed to the timer callback on
 *                         timeout.
 * \param[in]  timeoutUS   Timeout in microseconds.
 * \param[in]  toleranceUS Tolerance in microseconds.  Indicates a
 *                         request that the timer fire approximately
 *                         no later than the provided value from the
 *                         requested time.  The majority of callers
 *                         should specify a tolerance of
 *                         VMK_TIMER_DEFAULT_TOLERANCE and only use
 *                         other values for timers that have strict
 *                         timing requirements.
 * \param[in]  attributes  Additional timer attributes
 * \param[in]  lockDomain  Lock domain in which to check the lock rank.
 *                         Note that if lockDomain is set to invalid
 *                         then rank has to be set to unranked and if
 *                         lockDomain is set to a valid value then
 *                         rank has to contain a valid rank value.
 * \param[in]  lockRank    Rank of the timer
 * \param[out] timer       Timer Handle
 *
 * \retval VMK_NO_RESOURCES Couldn't schedule the timer.
 * \retval VMK_OK           The timer was successfully scheduled.
 *
 ***********************************************************************
 */

VMK_ReturnStatus vmk_TimerSchedule(
   vmk_TimerQueue queue,
   vmk_TimerCallback callback,
   vmk_TimerCookie data,
   vmk_int64 timeoutUS,
   vmk_int64 toleranceUS,
   vmk_TimerAttributes attributes,
   vmk_LockDomainID lockDomain,
   vmk_LockRank lockRank,
   vmk_Timer *timer);


/*
 ***********************************************************************
 * vmk_TimerCancel --                                             */ /**
 *
 * \brief Cancel a scheduled timer
 *
 * If wait is set to TRUE and the timer is currently executing, waits
 * until the timer has finished executing before returning.  If wait is
 * set to FALSE, returns immediately after attempting to cancel the
 * timer, even if the timer is still executing.
 *
 * \note  This function will not block.
 *
 * \warning If wait is set to TRUE then this function must not be
 *          called from the timer callback itself. It must be called
 *          with current lock rank less than the timer's rank.
 *
 * \param[in]  timer    A timer reference.
 * \param[in]  wait     Determines whether to wait for a timer that is
 *                      currently executing.
 *
 * \retval VMK_OK          The timer was successfully cancelled. If the
 *                         timer was one-shot, it did not fire and
 *                         never will.
 * \retval VMK_NOT_FOUND   The timer had previously been removed, was a
 *                         one-shot that already fired, or is
 *                         VMK_INVALID_TIMER.
 *
 ***********************************************************************
 */

VMK_ReturnStatus vmk_TimerCancel(
  vmk_Timer timer,
  vmk_Bool wait);


/*
 ***********************************************************************
 * vmk_TimerIsPending --                                            */ /**
 *
 * \brief Query a timer to see if it is pending.
 *
 * \note  This function will not block.
 *
 * \param[in]  timer  A timer reference.
 *
 * \retval VMK_TRUE   The timer is pending.  For one-shot timers, this
 *                    means the timer has neither fired nor been removed.
 *                    For periodic timers, it means the timer has not
 *                    been removed.
 * \retval VMK_FALSE  The timer is not pending.  For one-shot timers,
 *                    this means the timer has already fired, is in
 *                    the process of firing, or has been removed.  For
 *                    periodic timers, it means the timer has been
 *                    removed.  VMK_FALSE is also returned for
 *                    VMK_INVALID_TIMER.
 *
 ***********************************************************************
 */

vmk_Bool vmk_TimerIsPending(
   vmk_Timer timer);


/*
 ***********************************************************************
 * vmk_TimerQueueCreate --                                        */ /**
 *
 * \brief Create a timer queue.
 *
 * \note  This function will may block.
 *
 * \param[in]  props    Properties of the new timer queue.
 *
 * \param[out] queue    The newly created queue.
 *
 * \retval VMK_OK             The timer queue was created successfuly,
 *                            and can now be used to schedule timers.
 *
 * \retval VMK_BAD_PARAM      Invalid parameters passed into the function.
 *                            Make sure that all fields in the provided
 *                            properties are valid.
 *
 * \retval VMK_NO_RESOURCES   Ran out of resources to create the timer
 *                            queue.
 *
 ***********************************************************************
 */

VMK_ReturnStatus vmk_TimerQueueCreate(
      vmk_TimerQueueProps *props,
      vmk_TimerQueue *queue);


/*
 ***********************************************************************
 * vmk_TimerQueueDestroy --                                       */ /**
 *
 * \brief Destroy a timer queue. All timers in the queue are cancelled.
 *        Memory for the timer queue and associate timers is released
 *        back to the heap that the queue was allocated from.
 *
 * \note  This function will may block.
 *
 * \param[in]  queue    The queue.
 *
 * \retval VMK_OK       The timer queue is destroyed.
 *
 *
 ***********************************************************************
 */

VMK_ReturnStatus vmk_TimerQueueDestroy(
      vmk_TimerQueue queue);


#endif /* _VMKAPI_TIME_H_ */
/** @} */
/** @} */