2006-05-29 14:55:07 +00:00
|
|
|
#ifndef _GPXE_RETRY_H
|
|
|
|
|
#define _GPXE_RETRY_H
|
|
|
|
|
|
|
|
|
|
/** @file
|
|
|
|
|
*
|
|
|
|
|
* Retry timers
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <gpxe/list.h>
|
|
|
|
|
|
2008-08-12 01:05:26 +01:00
|
|
|
/** Default timeout value */
|
|
|
|
|
#define DEFAULT_MIN_TIMEOUT ( TICKS_PER_SEC / 4 )
|
|
|
|
|
|
|
|
|
|
/** Limit after which the timeout will be deemed permanent */
|
|
|
|
|
#define DEFAULT_MAX_TIMEOUT ( 10 * TICKS_PER_SEC )
|
|
|
|
|
|
2006-05-29 14:55:07 +00:00
|
|
|
/** A retry timer */
|
|
|
|
|
struct retry_timer {
|
|
|
|
|
/** List of active timers */
|
|
|
|
|
struct list_head list;
|
2006-06-01 14:33:52 +00:00
|
|
|
/** Timeout value (in ticks) */
|
|
|
|
|
unsigned long timeout;
|
2008-08-12 01:05:26 +01:00
|
|
|
/** Minimum timeout value (in ticks)
|
|
|
|
|
*
|
|
|
|
|
* A value of zero means "use default timeout."
|
|
|
|
|
*/
|
|
|
|
|
unsigned long min_timeout;
|
|
|
|
|
/** Maximum timeout value before failure (in ticks)
|
|
|
|
|
*
|
|
|
|
|
* A value of zero means "use default timeout."
|
|
|
|
|
*/
|
|
|
|
|
unsigned long max_timeout;
|
2006-12-22 01:35:21 +00:00
|
|
|
/** Start time (in ticks)
|
|
|
|
|
*
|
|
|
|
|
* A start time of zero indicates a stopped timer.
|
|
|
|
|
*/
|
2006-06-01 14:33:52 +00:00
|
|
|
unsigned long start;
|
2006-08-09 15:54:17 +00:00
|
|
|
/** Retry count */
|
|
|
|
|
unsigned int count;
|
2006-05-29 14:55:07 +00:00
|
|
|
/** Timer expired callback
|
|
|
|
|
*
|
|
|
|
|
* @v timer Retry timer
|
2006-06-01 14:33:52 +00:00
|
|
|
* @v fail Failure indicator
|
|
|
|
|
*
|
|
|
|
|
* The timer will already be stopped when this method is
|
|
|
|
|
* called. The failure indicator will be True if the retry
|
|
|
|
|
* timeout has already exceeded @c MAX_TIMEOUT.
|
2006-05-29 14:55:07 +00:00
|
|
|
*/
|
2006-06-01 14:33:52 +00:00
|
|
|
void ( * expired ) ( struct retry_timer *timer, int over );
|
2006-05-29 14:55:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern void start_timer ( struct retry_timer *timer );
|
2008-06-11 09:37:58 +01:00
|
|
|
extern void start_timer_fixed ( struct retry_timer *timer,
|
|
|
|
|
unsigned long timeout );
|
2006-05-29 14:55:07 +00:00
|
|
|
extern void stop_timer ( struct retry_timer *timer );
|
|
|
|
|
|
2008-06-11 09:37:58 +01:00
|
|
|
/**
|
|
|
|
|
* Start timer with no delay
|
|
|
|
|
*
|
|
|
|
|
* @v timer Retry timer
|
|
|
|
|
*
|
|
|
|
|
* This starts the timer running with a zero timeout value.
|
|
|
|
|
*/
|
|
|
|
|
static inline void start_timer_nodelay ( struct retry_timer *timer ) {
|
|
|
|
|
start_timer_fixed ( timer, 0 );
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-26 15:00:56 +00:00
|
|
|
/**
|
|
|
|
|
* Test to see if timer is currently running
|
|
|
|
|
*
|
|
|
|
|
* @v timer Retry timer
|
|
|
|
|
* @ret running Non-zero if timer is running
|
|
|
|
|
*/
|
|
|
|
|
static inline __attribute__ (( always_inline )) unsigned long
|
|
|
|
|
timer_running ( struct retry_timer *timer ) {
|
|
|
|
|
return ( timer->start );
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-29 14:55:07 +00:00
|
|
|
#endif /* _GPXE_RETRY_H */
|