Arnaldo Carvalho de Melo | ae6706f | 2005-08-27 23:03:09 -0300 | [diff] [blame] | 1 | #ifndef _DCCP_LI_HIST_ |
| 2 | #define _DCCP_LI_HIST_ |
| 3 | /* |
Gerrit Renker | 8a9c7e9 | 2007-12-12 13:50:51 -0200 | [diff] [blame] | 4 | * Copyright (c) 2007 The University of Aberdeen, Scotland, UK |
Ian McDonald | b2f41ff | 2007-05-28 12:23:29 -0300 | [diff] [blame] | 5 | * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. |
| 6 | * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz> |
Arnaldo Carvalho de Melo | ae6706f | 2005-08-27 23:03:09 -0300 | [diff] [blame] | 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 | */ |
Arnaldo Carvalho de Melo | e7c2335 | 2007-08-19 17:17:51 -0700 | [diff] [blame] | 14 | #include <linux/ktime.h> |
Arnaldo Carvalho de Melo | ae6706f | 2005-08-27 23:03:09 -0300 | [diff] [blame] | 15 | #include <linux/list.h> |
Gerrit Renker | 8a9c7e9 | 2007-12-12 13:50:51 -0200 | [diff] [blame] | 16 | #include <linux/slab.h> |
| 17 | |
| 18 | /* |
| 19 | * Number of loss intervals (RFC 4342, 8.6.1). The history size is one more than |
| 20 | * NINTERVAL, since the `open' interval I_0 is always stored as the first entry. |
| 21 | */ |
| 22 | #define NINTERVAL 8 |
| 23 | #define LIH_SIZE (NINTERVAL + 1) |
| 24 | |
| 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 | /** |
| 40 | * tfrc_loss_hist - Loss record database |
| 41 | * @ring: Circular queue managed in LIFO manner |
| 42 | * @counter: Current count of entries (can be more than %LIH_SIZE) |
| 43 | * @i_mean: Current Average Loss Interval [RFC 3448, 5.4] |
| 44 | */ |
| 45 | struct tfrc_loss_hist { |
| 46 | struct tfrc_loss_interval *ring[LIH_SIZE]; |
| 47 | u8 counter; |
| 48 | u32 i_mean; |
| 49 | }; |
| 50 | |
| 51 | static inline void tfrc_lh_init(struct tfrc_loss_hist *lh) |
| 52 | { |
| 53 | memset(lh, 0, sizeof(struct tfrc_loss_hist)); |
| 54 | } |
| 55 | |
| 56 | static inline u8 tfrc_lh_is_initialised(struct tfrc_loss_hist *lh) |
| 57 | { |
| 58 | return lh->counter > 0; |
| 59 | } |
| 60 | |
| 61 | static inline u8 tfrc_lh_length(struct tfrc_loss_hist *lh) |
| 62 | { |
| 63 | return min(lh->counter, (u8)LIH_SIZE); |
| 64 | } |
Arnaldo Carvalho de Melo | ae6706f | 2005-08-27 23:03:09 -0300 | [diff] [blame] | 65 | |
Gerrit Renker | 8a9c7e9 | 2007-12-12 13:50:51 -0200 | [diff] [blame] | 66 | struct tfrc_rx_hist; |
Gerrit Renker | 3f71c81 | 2007-12-12 14:23:08 -0200 | [diff] [blame] | 67 | |
Joe Perches | a402a5a | 2013-10-18 13:48:23 -0700 | [diff] [blame] | 68 | int tfrc_lh_interval_add(struct tfrc_loss_hist *, struct tfrc_rx_hist *, |
| 69 | u32 (*first_li)(struct sock *), struct sock *); |
| 70 | u8 tfrc_lh_update_i_mean(struct tfrc_loss_hist *lh, struct sk_buff *); |
| 71 | void tfrc_lh_cleanup(struct tfrc_loss_hist *lh); |
Arnaldo Carvalho de Melo | ae6706f | 2005-08-27 23:03:09 -0300 | [diff] [blame] | 72 | |
Arnaldo Carvalho de Melo | ae6706f | 2005-08-27 23:03:09 -0300 | [diff] [blame] | 73 | #endif /* _DCCP_LI_HIST_ */ |