loss_interval.h 2.2 KB

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