retry.h

Go to the documentation of this file.
00001 #ifndef _GPXE_RETRY_H
00002 #define _GPXE_RETRY_H
00003 
00004 /** @file
00005  *
00006  * Retry timers
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER );
00011 
00012 #include <gpxe/list.h>
00013 
00014 /** Default timeout value */
00015 #define DEFAULT_MIN_TIMEOUT ( TICKS_PER_SEC / 4 )
00016 
00017 /** Limit after which the timeout will be deemed permanent */
00018 #define DEFAULT_MAX_TIMEOUT ( 10 * TICKS_PER_SEC )
00019 
00020 /** A retry timer */
00021 struct retry_timer {
00022         /** List of active timers */
00023         struct list_head list;
00024         /** Timer is currently running */
00025         unsigned int running;
00026         /** Timeout value (in ticks) */
00027         unsigned long timeout;
00028         /** Minimum timeout value (in ticks)
00029          *
00030          * A value of zero means "use default timeout."
00031          */
00032         unsigned long min_timeout;
00033         /** Maximum timeout value before failure (in ticks)
00034          *
00035          * A value of zero means "use default timeout."
00036          */
00037         unsigned long max_timeout;
00038         /** Start time (in ticks) */
00039         unsigned long start;
00040         /** Retry count */
00041         unsigned int count;
00042         /** Timer expired callback
00043          *
00044          * @v timer     Retry timer
00045          * @v fail      Failure indicator
00046          *
00047          * The timer will already be stopped when this method is
00048          * called.  The failure indicator will be True if the retry
00049          * timeout has already exceeded @c MAX_TIMEOUT.
00050          */
00051         void ( * expired ) ( struct retry_timer *timer, int over );
00052 };
00053 
00054 extern void start_timer ( struct retry_timer *timer );
00055 extern void start_timer_fixed ( struct retry_timer *timer,
00056                                 unsigned long timeout );
00057 extern void stop_timer ( struct retry_timer *timer );
00058 
00059 /**
00060  * Start timer with no delay
00061  *
00062  * @v timer             Retry timer
00063  *
00064  * This starts the timer running with a zero timeout value.
00065  */
00066 static inline void start_timer_nodelay ( struct retry_timer *timer ) {
00067         start_timer_fixed ( timer, 0 );
00068 }
00069 
00070 /**
00071  * Test to see if timer is currently running
00072  *
00073  * @v timer             Retry timer
00074  * @ret running         Non-zero if timer is running
00075  */
00076 static inline __attribute__ (( always_inline )) unsigned long
00077 timer_running ( struct retry_timer *timer ) {
00078         return ( timer->running );
00079 }
00080 
00081 #endif /* _GPXE_RETRY_H */

Generated on Tue Apr 6 20:01:08 2010 for gPXE by  doxygen 1.5.7.1