linux/net/dccp/ccids/lib/loss_interval.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0-or-later */
   2#ifndef _DCCP_LI_HIST_
   3#define _DCCP_LI_HIST_
   4/*
   5 *  Copyright (c) 2007   The University of Aberdeen, Scotland, UK
   6 *  Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand.
   7 *  Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz>
   8 *  Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
   9 */
  10#include <linux/ktime.h>
  11#include <linux/list.h>
  12#include <linux/slab.h>
  13
  14/*
  15 * Number of loss intervals (RFC 4342, 8.6.1). The history size is one more than
  16 * NINTERVAL, since the `open' interval I_0 is always stored as the first entry.
  17 */
  18#define NINTERVAL       8
  19#define LIH_SIZE        (NINTERVAL + 1)
  20
  21/**
  22 *  tfrc_loss_interval  -  Loss history record for TFRC-based protocols
  23 *  @li_seqno:          Highest received seqno before the start of loss
  24 *  @li_ccval:          The CCVal belonging to @li_seqno
  25 *  @li_is_closed:      Whether @li_seqno is older than 1 RTT
  26 *  @li_length:         Loss interval sequence length
  27 */
  28struct tfrc_loss_interval {
  29        u64              li_seqno:48,
  30                         li_ccval:4,
  31                         li_is_closed:1;
  32        u32              li_length;
  33};
  34
  35/**
  36 *  tfrc_loss_hist  -  Loss record database
  37 *  @ring:      Circular queue managed in LIFO manner
  38 *  @counter:   Current count of entries (can be more than %LIH_SIZE)
  39 *  @i_mean:    Current Average Loss Interval [RFC 3448, 5.4]
  40 */
  41struct tfrc_loss_hist {
  42        struct tfrc_loss_interval       *ring[LIH_SIZE];
  43        u8                              counter;
  44        u32                             i_mean;
  45};
  46
  47static inline void tfrc_lh_init(struct tfrc_loss_hist *lh)
  48{
  49        memset(lh, 0, sizeof(struct tfrc_loss_hist));
  50}
  51
  52static inline u8 tfrc_lh_is_initialised(struct tfrc_loss_hist *lh)
  53{
  54        return lh->counter > 0;
  55}
  56
  57static inline u8 tfrc_lh_length(struct tfrc_loss_hist *lh)
  58{
  59        return min(lh->counter, (u8)LIH_SIZE);
  60}
  61
  62struct tfrc_rx_hist;
  63
  64int tfrc_lh_interval_add(struct tfrc_loss_hist *, struct tfrc_rx_hist *,
  65                         u32 (*first_li)(struct sock *), struct sock *);
  66u8 tfrc_lh_update_i_mean(struct tfrc_loss_hist *lh, struct sk_buff *);
  67void tfrc_lh_cleanup(struct tfrc_loss_hist *lh);
  68
  69#endif /* _DCCP_LI_HIST_ */
  70