Path: blob/master/net/dccp/ccids/lib/loss_interval.h
15112 views
#ifndef _DCCP_LI_HIST_1#define _DCCP_LI_HIST_2/*3* Copyright (c) 2007 The University of Aberdeen, Scotland, UK4* Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand.5* Copyright (c) 2005-7 Ian McDonald <[email protected]>6* Copyright (c) 2005 Arnaldo Carvalho de Melo <[email protected]>7*8* This program is free software; you can redistribute it and/or modify it9* under the terms of the GNU General Public License as published by the Free10* Software Foundation; either version 2 of the License, or (at your option)11* any later version.12*/13#include <linux/ktime.h>14#include <linux/list.h>15#include <linux/slab.h>1617/*18* Number of loss intervals (RFC 4342, 8.6.1). The history size is one more than19* NINTERVAL, since the `open' interval I_0 is always stored as the first entry.20*/21#define NINTERVAL 822#define LIH_SIZE (NINTERVAL + 1)2324/**25* tfrc_loss_interval - Loss history record for TFRC-based protocols26* @li_seqno: Highest received seqno before the start of loss27* @li_ccval: The CCVal belonging to @li_seqno28* @li_is_closed: Whether @li_seqno is older than 1 RTT29* @li_length: Loss interval sequence length30*/31struct tfrc_loss_interval {32u64 li_seqno:48,33li_ccval:4,34li_is_closed:1;35u32 li_length;36};3738/**39* tfrc_loss_hist - Loss record database40* @ring: Circular queue managed in LIFO manner41* @counter: Current count of entries (can be more than %LIH_SIZE)42* @i_mean: Current Average Loss Interval [RFC 3448, 5.4]43*/44struct tfrc_loss_hist {45struct tfrc_loss_interval *ring[LIH_SIZE];46u8 counter;47u32 i_mean;48};4950static inline void tfrc_lh_init(struct tfrc_loss_hist *lh)51{52memset(lh, 0, sizeof(struct tfrc_loss_hist));53}5455static inline u8 tfrc_lh_is_initialised(struct tfrc_loss_hist *lh)56{57return lh->counter > 0;58}5960static inline u8 tfrc_lh_length(struct tfrc_loss_hist *lh)61{62return min(lh->counter, (u8)LIH_SIZE);63}6465struct tfrc_rx_hist;6667extern int tfrc_lh_interval_add(struct tfrc_loss_hist *, struct tfrc_rx_hist *,68u32 (*first_li)(struct sock *), struct sock *);69extern u8 tfrc_lh_update_i_mean(struct tfrc_loss_hist *lh, struct sk_buff *);70extern void tfrc_lh_cleanup(struct tfrc_loss_hist *lh);7172#endif /* _DCCP_LI_HIST_ */737475