Lines Matching refs:lh

26 static inline struct tfrc_loss_interval *tfrc_lh_peek(struct tfrc_loss_hist *lh)  in tfrc_lh_peek()  argument
28 return lh->counter ? lh->ring[LIH_INDEX(lh->counter - 1)] : NULL; in tfrc_lh_peek()
32 static inline u32 tfrc_lh_get_interval(struct tfrc_loss_hist *lh, const u8 i) in tfrc_lh_get_interval() argument
34 BUG_ON(i >= lh->counter); in tfrc_lh_get_interval()
35 return lh->ring[LIH_INDEX(lh->counter - i - 1)]->li_length; in tfrc_lh_get_interval()
41 static struct tfrc_loss_interval *tfrc_lh_demand_next(struct tfrc_loss_hist *lh) in tfrc_lh_demand_next() argument
43 if (lh->ring[LIH_INDEX(lh->counter)] == NULL) in tfrc_lh_demand_next()
44 lh->ring[LIH_INDEX(lh->counter)] = kmem_cache_alloc(tfrc_lh_slab, in tfrc_lh_demand_next()
46 return lh->ring[LIH_INDEX(lh->counter)]; in tfrc_lh_demand_next()
49 void tfrc_lh_cleanup(struct tfrc_loss_hist *lh) in tfrc_lh_cleanup() argument
51 if (!tfrc_lh_is_initialised(lh)) in tfrc_lh_cleanup()
54 for (lh->counter = 0; lh->counter < LIH_SIZE; lh->counter++) in tfrc_lh_cleanup()
55 if (lh->ring[LIH_INDEX(lh->counter)] != NULL) { in tfrc_lh_cleanup()
57 lh->ring[LIH_INDEX(lh->counter)]); in tfrc_lh_cleanup()
58 lh->ring[LIH_INDEX(lh->counter)] = NULL; in tfrc_lh_cleanup()
62 static void tfrc_lh_calc_i_mean(struct tfrc_loss_hist *lh) in tfrc_lh_calc_i_mean() argument
65 int i, k = tfrc_lh_length(lh) - 1; /* k is as in rfc3448bis, 5.4 */ in tfrc_lh_calc_i_mean()
71 i_i = tfrc_lh_get_interval(lh, i); in tfrc_lh_calc_i_mean()
81 lh->i_mean = max(i_tot0, i_tot1) / w_tot; in tfrc_lh_calc_i_mean()
88 u8 tfrc_lh_update_i_mean(struct tfrc_loss_hist *lh, struct sk_buff *skb) in tfrc_lh_update_i_mean() argument
90 struct tfrc_loss_interval *cur = tfrc_lh_peek(lh); in tfrc_lh_update_i_mean()
91 u32 old_i_mean = lh->i_mean; in tfrc_lh_update_i_mean()
113 if (tfrc_lh_length(lh) == 1) /* due to RFC 3448, 6.3.1 */ in tfrc_lh_update_i_mean()
117 tfrc_lh_calc_i_mean(lh); in tfrc_lh_update_i_mean()
119 return lh->i_mean < old_i_mean; in tfrc_lh_update_i_mean()
139 int tfrc_lh_interval_add(struct tfrc_loss_hist *lh, struct tfrc_rx_hist *rh, in tfrc_lh_interval_add() argument
142 struct tfrc_loss_interval *cur = tfrc_lh_peek(lh), *new; in tfrc_lh_interval_add()
147 new = tfrc_lh_demand_next(lh); in tfrc_lh_interval_add()
157 if (++lh->counter == 1) in tfrc_lh_interval_add()
158 lh->i_mean = new->li_length = (*calc_first_li)(sk); in tfrc_lh_interval_add()
163 if (lh->counter > (2*LIH_SIZE)) in tfrc_lh_interval_add()
164 lh->counter -= LIH_SIZE; in tfrc_lh_interval_add()
166 tfrc_lh_calc_i_mean(lh); in tfrc_lh_interval_add()