Lines Matching refs:h
123 void tfrc_rx_hist_add_packet(struct tfrc_rx_hist *h, in tfrc_rx_hist_add_packet() argument
127 struct tfrc_rx_hist_entry *entry = tfrc_rx_hist_last_rcv(h); in tfrc_rx_hist_add_packet()
133 int tfrc_rx_hist_duplicate(struct tfrc_rx_hist *h, struct sk_buff *skb) in tfrc_rx_hist_duplicate() argument
138 if (dccp_delta_seqno(tfrc_rx_hist_loss_prev(h)->tfrchrx_seqno, seq) <= 0) in tfrc_rx_hist_duplicate()
141 for (i = 1; i <= h->loss_count; i++) in tfrc_rx_hist_duplicate()
142 if (tfrc_rx_hist_entry(h, i)->tfrchrx_seqno == seq) in tfrc_rx_hist_duplicate()
148 static void tfrc_rx_hist_swap(struct tfrc_rx_hist *h, const u8 a, const u8 b) in tfrc_rx_hist_swap() argument
150 const u8 idx_a = tfrc_rx_hist_index(h, a), in tfrc_rx_hist_swap()
151 idx_b = tfrc_rx_hist_index(h, b); in tfrc_rx_hist_swap()
152 struct tfrc_rx_hist_entry *tmp = h->ring[idx_a]; in tfrc_rx_hist_swap()
154 h->ring[idx_a] = h->ring[idx_b]; in tfrc_rx_hist_swap()
155 h->ring[idx_b] = tmp; in tfrc_rx_hist_swap()
167 static void __do_track_loss(struct tfrc_rx_hist *h, struct sk_buff *skb, u64 n1) in __do_track_loss() argument
169 u64 s0 = tfrc_rx_hist_loss_prev(h)->tfrchrx_seqno, in __do_track_loss()
173 h->loss_count = 1; in __do_track_loss()
174 tfrc_rx_hist_entry_from_skb(tfrc_rx_hist_entry(h, 1), skb, n1); in __do_track_loss()
178 static void __one_after_loss(struct tfrc_rx_hist *h, struct sk_buff *skb, u32 n2) in __one_after_loss() argument
180 u64 s0 = tfrc_rx_hist_loss_prev(h)->tfrchrx_seqno, in __one_after_loss()
181 s1 = tfrc_rx_hist_entry(h, 1)->tfrchrx_seqno, in __one_after_loss()
185 h->loss_count = 2; in __one_after_loss()
186 tfrc_rx_hist_entry_from_skb(tfrc_rx_hist_entry(h, 2), skb, n2); in __one_after_loss()
193 u64 n1 = tfrc_rx_hist_entry(h, 1)->tfrchrx_ndp; in __one_after_loss()
197 h->loss_count = 0; in __one_after_loss()
198 h->loss_start = tfrc_rx_hist_index(h, 1); in __one_after_loss()
201 tfrc_rx_hist_entry_from_skb(tfrc_rx_hist_loss_prev(h), skb, n2); in __one_after_loss()
207 tfrc_rx_hist_swap(h, 0, 3); in __one_after_loss()
208 h->loss_start = tfrc_rx_hist_index(h, 3); in __one_after_loss()
209 tfrc_rx_hist_entry_from_skb(tfrc_rx_hist_entry(h, 1), skb, n2); in __one_after_loss()
210 h->loss_count = 2; in __one_after_loss()
215 static int __two_after_loss(struct tfrc_rx_hist *h, struct sk_buff *skb, u32 n3) in __two_after_loss() argument
217 u64 s0 = tfrc_rx_hist_loss_prev(h)->tfrchrx_seqno, in __two_after_loss()
218 s1 = tfrc_rx_hist_entry(h, 1)->tfrchrx_seqno, in __two_after_loss()
219 s2 = tfrc_rx_hist_entry(h, 2)->tfrchrx_seqno, in __two_after_loss()
223 h->loss_count = 3; in __two_after_loss()
224 tfrc_rx_hist_entry_from_skb(tfrc_rx_hist_entry(h, 3), skb, n3); in __two_after_loss()
234 tfrc_rx_hist_swap(h, 2, 3); in __two_after_loss()
235 tfrc_rx_hist_entry_from_skb(tfrc_rx_hist_entry(h, 2), skb, n3); in __two_after_loss()
236 h->loss_count = 3; in __two_after_loss()
243 u64 n1 = tfrc_rx_hist_entry(h, 1)->tfrchrx_ndp; in __two_after_loss()
247 u64 n2 = tfrc_rx_hist_entry(h, 2)->tfrchrx_ndp; in __two_after_loss()
251 h->loss_start = tfrc_rx_hist_index(h, 2); in __two_after_loss()
252 h->loss_count = 0; in __two_after_loss()
255 h->loss_start = tfrc_rx_hist_index(h, 1); in __two_after_loss()
256 h->loss_count = 1; in __two_after_loss()
260 tfrc_rx_hist_entry_from_skb(tfrc_rx_hist_loss_prev(h), skb, n3); in __two_after_loss()
269 tfrc_rx_hist_swap(h, 0, 3); in __two_after_loss()
270 h->loss_start = tfrc_rx_hist_index(h, 3); in __two_after_loss()
271 tfrc_rx_hist_entry_from_skb(tfrc_rx_hist_entry(h, 1), skb, n3); in __two_after_loss()
272 h->loss_count = 3; in __two_after_loss()
278 static void __three_after_loss(struct tfrc_rx_hist *h) in __three_after_loss() argument
286 u64 s1 = tfrc_rx_hist_entry(h, 1)->tfrchrx_seqno, in __three_after_loss()
287 s2 = tfrc_rx_hist_entry(h, 2)->tfrchrx_seqno, in __three_after_loss()
288 s3 = tfrc_rx_hist_entry(h, 3)->tfrchrx_seqno; in __three_after_loss()
289 u64 n2 = tfrc_rx_hist_entry(h, 2)->tfrchrx_ndp, in __three_after_loss()
290 n3 = tfrc_rx_hist_entry(h, 3)->tfrchrx_ndp; in __three_after_loss()
296 h->loss_start = tfrc_rx_hist_index(h, 3); in __three_after_loss()
297 h->loss_count = 0; in __three_after_loss()
300 h->loss_start = tfrc_rx_hist_index(h, 2); in __three_after_loss()
301 h->loss_count = 1; in __three_after_loss()
305 h->loss_start = tfrc_rx_hist_index(h, 1); in __three_after_loss()
306 h->loss_count = 2; in __three_after_loss()
326 int tfrc_rx_handle_loss(struct tfrc_rx_hist *h, in tfrc_rx_handle_loss() argument
333 if (h->loss_count == 0) { in tfrc_rx_handle_loss()
334 __do_track_loss(h, skb, ndp); in tfrc_rx_handle_loss()
335 } else if (h->loss_count == 1) { in tfrc_rx_handle_loss()
336 __one_after_loss(h, skb, ndp); in tfrc_rx_handle_loss()
337 } else if (h->loss_count != 2) { in tfrc_rx_handle_loss()
338 DCCP_BUG("invalid loss_count %d", h->loss_count); in tfrc_rx_handle_loss()
339 } else if (__two_after_loss(h, skb, ndp)) { in tfrc_rx_handle_loss()
343 is_new_loss = tfrc_lh_interval_add(lh, h, calc_first_li, sk); in tfrc_rx_handle_loss()
344 __three_after_loss(h); in tfrc_rx_handle_loss()
349 int tfrc_rx_hist_alloc(struct tfrc_rx_hist *h) in tfrc_rx_hist_alloc() argument
354 h->ring[i] = kmem_cache_alloc(tfrc_rx_hist_slab, GFP_ATOMIC); in tfrc_rx_hist_alloc()
355 if (h->ring[i] == NULL) in tfrc_rx_hist_alloc()
359 h->loss_count = h->loss_start = 0; in tfrc_rx_hist_alloc()
364 kmem_cache_free(tfrc_rx_hist_slab, h->ring[i]); in tfrc_rx_hist_alloc()
365 h->ring[i] = NULL; in tfrc_rx_hist_alloc()
370 void tfrc_rx_hist_purge(struct tfrc_rx_hist *h) in tfrc_rx_hist_purge() argument
375 if (h->ring[i] != NULL) { in tfrc_rx_hist_purge()
376 kmem_cache_free(tfrc_rx_hist_slab, h->ring[i]); in tfrc_rx_hist_purge()
377 h->ring[i] = NULL; in tfrc_rx_hist_purge()
385 tfrc_rx_hist_rtt_last_s(const struct tfrc_rx_hist *h) in tfrc_rx_hist_rtt_last_s() argument
387 return h->ring[0]; in tfrc_rx_hist_rtt_last_s()
394 tfrc_rx_hist_rtt_prev_s(const struct tfrc_rx_hist *h) in tfrc_rx_hist_rtt_prev_s() argument
396 return h->ring[h->rtt_sample_prev]; in tfrc_rx_hist_rtt_prev_s()
404 u32 tfrc_rx_hist_sample_rtt(struct tfrc_rx_hist *h, const struct sk_buff *skb) in tfrc_rx_hist_sample_rtt() argument
408 tfrc_rx_hist_rtt_last_s(h)->tfrchrx_ccval); in tfrc_rx_hist_sample_rtt()
411 if (h->rtt_sample_prev == 2) { /* previous candidate stored */ in tfrc_rx_hist_sample_rtt()
412 sample = SUB16(tfrc_rx_hist_rtt_prev_s(h)->tfrchrx_ccval, in tfrc_rx_hist_sample_rtt()
413 tfrc_rx_hist_rtt_last_s(h)->tfrchrx_ccval); in tfrc_rx_hist_sample_rtt()
416 ktime_us_delta(tfrc_rx_hist_rtt_prev_s(h)->tfrchrx_tstamp, in tfrc_rx_hist_sample_rtt()
417 tfrc_rx_hist_rtt_last_s(h)->tfrchrx_tstamp); in tfrc_rx_hist_sample_rtt()
426 tfrc_rx_hist_rtt_prev_s(h)->tfrchrx_ccval, in tfrc_rx_hist_sample_rtt()
427 tfrc_rx_hist_rtt_last_s(h)->tfrchrx_ccval); in tfrc_rx_hist_sample_rtt()
429 h->rtt_sample_prev = 1; in tfrc_rx_hist_sample_rtt()
434 sample = ktime_to_us(net_timedelta(tfrc_rx_hist_rtt_last_s(h)->tfrchrx_tstamp)); in tfrc_rx_hist_sample_rtt()
436 h->rtt_sample_prev = 2; in tfrc_rx_hist_sample_rtt()
445 h->rtt_sample_prev = 0; /* use current entry as next reference */ in tfrc_rx_hist_sample_rtt()