loss_interval.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef _DCCP_LI_HIST_
  2. #define _DCCP_LI_HIST_
  3. /*
  4. * Copyright (c) 2007 The University of Aberdeen, Scotland, UK
  5. * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand.
  6. * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz>
  7. * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the Free
  11. * Software Foundation; either version 2 of the License, or (at your option)
  12. * any later version.
  13. */
  14. #include <linux/ktime.h>
  15. #include <linux/list.h>
  16. #include <linux/slab.h>
  17. /*
  18. * Number of loss intervals (RFC 4342, 8.6.1). The history size is one more than
  19. * NINTERVAL, since the `open' interval I_0 is always stored as the first entry.
  20. */
  21. #define NINTERVAL 8
  22. #define LIH_SIZE (NINTERVAL + 1)
  23. /**
  24. * tfrc_loss_interval - Loss history record for TFRC-based protocols
  25. * @li_seqno: Highest received seqno before the start of loss
  26. * @li_ccval: The CCVal belonging to @li_seqno
  27. * @li_is_closed: Whether @li_seqno is older than 1 RTT
  28. * @li_length: Loss interval sequence length
  29. */
  30. struct tfrc_loss_interval {
  31. u64 li_seqno:48,
  32. li_ccval:4,
  33. li_is_closed:1;
  34. u32 li_length;
  35. };
  36. /**
  37. * tfrc_loss_hist - Loss record database
  38. * @ring: Circular queue managed in LIFO manner
  39. * @counter: Current count of entries (can be more than %LIH_SIZE)
  40. * @i_mean: Current Average Loss Interval [RFC 3448, 5.4]
  41. */
  42. struct tfrc_loss_hist {
  43. struct tfrc_loss_interval *ring[LIH_SIZE];
  44. u8 counter;
  45. u32 i_mean;
  46. };
  47. static inline void tfrc_lh_init(struct tfrc_loss_hist *lh)
  48. {
  49. memset(lh, 0, sizeof(struct tfrc_loss_hist));
  50. }
  51. static inline u8 tfrc_lh_is_initialised(struct tfrc_loss_hist *lh)
  52. {
  53. return lh->counter > 0;
  54. }
  55. static inline u8 tfrc_lh_length(struct tfrc_loss_hist *lh)
  56. {
  57. return min(lh->counter, (u8)LIH_SIZE);
  58. }
  59. struct tfrc_rx_hist;
  60. int tfrc_lh_interval_add(struct tfrc_loss_hist *, struct tfrc_rx_hist *,
  61. u32 (*first_li)(struct sock *), struct sock *);
  62. u8 tfrc_lh_update_i_mean(struct tfrc_loss_hist *lh, struct sk_buff *);
  63. void tfrc_lh_cleanup(struct tfrc_loss_hist *lh);
  64. #endif /* _DCCP_LI_HIST_ */