Lines Matching refs:lh

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