timer.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * linux/include/linux/sunrpc/timer.h
  3. *
  4. * Declarations for the RPC transport timer.
  5. *
  6. * Copyright (C) 2002 Trond Myklebust <trond.myklebust@fys.uio.no>
  7. */
  8. #ifndef _LINUX_SUNRPC_TIMER_H
  9. #define _LINUX_SUNRPC_TIMER_H
  10. #include <asm/atomic.h>
  11. struct rpc_rtt {
  12. unsigned long timeo; /* default timeout value */
  13. unsigned long srtt[5]; /* smoothed round trip time << 3 */
  14. unsigned long sdrtt[5]; /* smoothed medium deviation of RTT */
  15. int ntimeouts[5]; /* Number of timeouts for the last request */
  16. };
  17. extern void rpc_init_rtt(struct rpc_rtt *rt, unsigned long timeo);
  18. extern void rpc_update_rtt(struct rpc_rtt *rt, unsigned timer, long m);
  19. extern unsigned long rpc_calc_rto(struct rpc_rtt *rt, unsigned timer);
  20. static inline void rpc_set_timeo(struct rpc_rtt *rt, int timer, int ntimeo)
  21. {
  22. int *t;
  23. if (!timer)
  24. return;
  25. t = &rt->ntimeouts[timer-1];
  26. if (ntimeo < *t) {
  27. if (*t > 0)
  28. (*t)--;
  29. } else {
  30. if (ntimeo > 8)
  31. ntimeo = 8;
  32. *t = ntimeo;
  33. }
  34. }
  35. static inline int rpc_ntimeo(struct rpc_rtt *rt, int timer)
  36. {
  37. if (!timer)
  38. return 0;
  39. return rt->ntimeouts[timer-1];
  40. }
  41. #endif /* _LINUX_SUNRPC_TIMER_H */