loss_interval.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. extern void dccp_li_hist_purge(struct list_head *list);
  62. struct tfrc_rx_hist;
  63. extern int tfrc_lh_interval_add(struct tfrc_loss_hist *, struct tfrc_rx_hist *,
  64. u32 (*first_li)(struct sock *), struct sock *);
  65. extern u8 tfrc_lh_update_i_mean(struct tfrc_loss_hist *lh, struct sk_buff *);
  66. extern void tfrc_lh_cleanup(struct tfrc_loss_hist *lh);
  67. extern u32 dccp_li_hist_calc_i_mean(struct list_head *list);
  68. extern void dccp_li_update_li(struct sock *sk,
  69. struct list_head *li_hist_list,
  70. struct list_head *hist_list,
  71. ktime_t last_feedback, u16 s,
  72. u32 bytes_recv, u32 previous_x_recv,
  73. u64 seq_loss, u8 win_loss);
  74. #endif /* _DCCP_LI_HIST_ */