Lines Matching refs:lh

22 static inline struct tfrc_loss_interval *tfrc_lh_peek(struct tfrc_loss_hist *lh)  in tfrc_lh_peek()  argument
24 return lh->counter ? lh->ring[LIH_INDEX(lh->counter - 1)] : NULL; in tfrc_lh_peek()
28 static inline u32 tfrc_lh_get_interval(struct tfrc_loss_hist *lh, const u8 i) in tfrc_lh_get_interval() argument
30 BUG_ON(i >= lh->counter); in tfrc_lh_get_interval()
31 return lh->ring[LIH_INDEX(lh->counter - i - 1)]->li_length; in tfrc_lh_get_interval()
37 static struct tfrc_loss_interval *tfrc_lh_demand_next(struct tfrc_loss_hist *lh) in tfrc_lh_demand_next() argument
39 if (lh->ring[LIH_INDEX(lh->counter)] == NULL) in tfrc_lh_demand_next()
40 lh->ring[LIH_INDEX(lh->counter)] = kmem_cache_alloc(tfrc_lh_slab, in tfrc_lh_demand_next()
42 return lh->ring[LIH_INDEX(lh->counter)]; in tfrc_lh_demand_next()
45 void tfrc_lh_cleanup(struct tfrc_loss_hist *lh) in tfrc_lh_cleanup() argument
47 if (!tfrc_lh_is_initialised(lh)) in tfrc_lh_cleanup()
50 for (lh->counter = 0; lh->counter < LIH_SIZE; lh->counter++) in tfrc_lh_cleanup()
51 if (lh->ring[LIH_INDEX(lh->counter)] != NULL) { in tfrc_lh_cleanup()
53 lh->ring[LIH_INDEX(lh->counter)]); in tfrc_lh_cleanup()
54 lh->ring[LIH_INDEX(lh->counter)] = NULL; in tfrc_lh_cleanup()
58 static void tfrc_lh_calc_i_mean(struct tfrc_loss_hist *lh) in tfrc_lh_calc_i_mean() argument
61 int i, k = tfrc_lh_length(lh) - 1; /* k is as in rfc3448bis, 5.4 */ in tfrc_lh_calc_i_mean()
67 i_i = tfrc_lh_get_interval(lh, i); in tfrc_lh_calc_i_mean()
77 lh->i_mean = max(i_tot0, i_tot1) / w_tot; in tfrc_lh_calc_i_mean()
87 u8 tfrc_lh_update_i_mean(struct tfrc_loss_hist *lh, struct sk_buff *skb) in tfrc_lh_update_i_mean() argument
89 struct tfrc_loss_interval *cur = tfrc_lh_peek(lh); in tfrc_lh_update_i_mean()
90 u32 old_i_mean = lh->i_mean; in tfrc_lh_update_i_mean()
112 if (tfrc_lh_length(lh) == 1) /* due to RFC 3448, 6.3.1 */ in tfrc_lh_update_i_mean()
116 tfrc_lh_calc_i_mean(lh); in tfrc_lh_update_i_mean()
118 return lh->i_mean < old_i_mean; in tfrc_lh_update_i_mean()
138 int tfrc_lh_interval_add(struct tfrc_loss_hist *lh, struct tfrc_rx_hist *rh, in tfrc_lh_interval_add() argument
141 struct tfrc_loss_interval *cur = tfrc_lh_peek(lh), *new; in tfrc_lh_interval_add()
146 new = tfrc_lh_demand_next(lh); in tfrc_lh_interval_add()
156 if (++lh->counter == 1) in tfrc_lh_interval_add()
157 lh->i_mean = new->li_length = (*calc_first_li)(sk); in tfrc_lh_interval_add()
162 if (lh->counter > (2*LIH_SIZE)) in tfrc_lh_interval_add()
163 lh->counter -= LIH_SIZE; in tfrc_lh_interval_add()
165 tfrc_lh_calc_i_mean(lh); in tfrc_lh_interval_add()