/*1* Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand.2* Copyright (c) 2007 The University of Aberdeen, Scotland, UK3*4* An implementation of the DCCP protocol5*6* This code has been developed by the University of Waikato WAND7* research group. For further information please see http://www.wand.net.nz/8* or e-mail Ian McDonald - [email protected]9*10* This code also uses code from Lulea University, rereleased as GPL by its11* authors:12* Copyright (c) 2003 Nils-Erik Mattsson, Joacim Haggmark, Magnus Erixzon13*14* Changes to meet Linux coding standards, to make it meet latest ccid3 draft15* and to make it work as a loadable module in the DCCP stack written by16* Arnaldo Carvalho de Melo <[email protected]>.17*18* Copyright (c) 2005 Arnaldo Carvalho de Melo <[email protected]>19*20* This program is free software; you can redistribute it and/or modify21* it under the terms of the GNU General Public License as published by22* the Free Software Foundation; either version 2 of the License, or23* (at your option) any later version.24*25* This program is distributed in the hope that it will be useful,26* but WITHOUT ANY WARRANTY; without even the implied warranty of27* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the28* GNU General Public License for more details.29*30* You should have received a copy of the GNU General Public License31* along with this program; if not, write to the Free Software32* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.33*/34#ifndef _DCCP_CCID3_H_35#define _DCCP_CCID3_H_3637#include <linux/ktime.h>38#include <linux/list.h>39#include <linux/types.h>40#include <linux/tfrc.h>41#include "lib/tfrc.h"42#include "../ccid.h"4344/* Two seconds as per RFC 5348, 4.2 */45#define TFRC_INITIAL_TIMEOUT (2 * USEC_PER_SEC)4647/* Parameter t_mbi from [RFC 3448, 4.3]: backoff interval in seconds */48#define TFRC_T_MBI 644950/*51* The t_delta parameter (RFC 5348, 8.3): delays of less than %USEC_PER_MSEC are52* rounded down to 0, since sk_reset_timer() here uses millisecond granularity.53* Hence we can use a constant t_delta = %USEC_PER_MSEC when HZ >= 500. A coarse54* resolution of HZ < 500 means that the error is below one timer tick (t_gran)55* when using the constant t_delta = t_gran / 2 = %USEC_PER_SEC / (2 * HZ).56*/57#if (HZ >= 500)58# define TFRC_T_DELTA USEC_PER_MSEC59#else60# define TFRC_T_DELTA (USEC_PER_SEC / (2 * HZ))61#endif6263enum ccid3_options {64TFRC_OPT_LOSS_EVENT_RATE = 192,65TFRC_OPT_LOSS_INTERVALS = 193,66TFRC_OPT_RECEIVE_RATE = 194,67};6869/* TFRC sender states */70enum ccid3_hc_tx_states {71TFRC_SSTATE_NO_SENT = 1,72TFRC_SSTATE_NO_FBACK,73TFRC_SSTATE_FBACK,74};7576/**77* struct ccid3_hc_tx_sock - CCID3 sender half-connection socket78* @tx_x: Current sending rate in 64 * bytes per second79* @tx_x_recv: Receive rate in 64 * bytes per second80* @tx_x_calc: Calculated rate in bytes per second81* @tx_rtt: Estimate of current round trip time in usecs82* @tx_p: Current loss event rate (0-1) scaled by 100000083* @tx_s: Packet size in bytes84* @tx_t_rto: Nofeedback Timer setting in usecs85* @tx_t_ipi: Interpacket (send) interval (RFC 3448, 4.6) in usecs86* @tx_state: Sender state, one of %ccid3_hc_tx_states87* @tx_last_win_count: Last window counter sent88* @tx_t_last_win_count: Timestamp of earliest packet89* with last_win_count value sent90* @tx_no_feedback_timer: Handle to no feedback timer91* @tx_t_ld: Time last doubled during slow start92* @tx_t_nom: Nominal send time of next packet93* @tx_hist: Packet history94*/95struct ccid3_hc_tx_sock {96u64 tx_x;97u64 tx_x_recv;98u32 tx_x_calc;99u32 tx_rtt;100u32 tx_p;101u32 tx_t_rto;102u32 tx_t_ipi;103u16 tx_s;104enum ccid3_hc_tx_states tx_state:8;105u8 tx_last_win_count;106ktime_t tx_t_last_win_count;107struct timer_list tx_no_feedback_timer;108ktime_t tx_t_ld;109ktime_t tx_t_nom;110struct tfrc_tx_hist_entry *tx_hist;111};112113static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk)114{115struct ccid3_hc_tx_sock *hctx = ccid_priv(dccp_sk(sk)->dccps_hc_tx_ccid);116BUG_ON(hctx == NULL);117return hctx;118}119120/* TFRC receiver states */121enum ccid3_hc_rx_states {122TFRC_RSTATE_NO_DATA = 1,123TFRC_RSTATE_DATA,124};125126/**127* struct ccid3_hc_rx_sock - CCID3 receiver half-connection socket128* @rx_last_counter: Tracks window counter (RFC 4342, 8.1)129* @rx_state: Receiver state, one of %ccid3_hc_rx_states130* @rx_bytes_recv: Total sum of DCCP payload bytes131* @rx_x_recv: Receiver estimate of send rate (RFC 3448, sec. 4.3)132* @rx_rtt: Receiver estimate of RTT133* @rx_tstamp_last_feedback: Time at which last feedback was sent134* @rx_hist: Packet history (loss detection + RTT sampling)135* @rx_li_hist: Loss Interval database136* @rx_s: Received packet size in bytes137* @rx_pinv: Inverse of Loss Event Rate (RFC 4342, sec. 8.5)138*/139struct ccid3_hc_rx_sock {140u8 rx_last_counter:4;141enum ccid3_hc_rx_states rx_state:8;142u32 rx_bytes_recv;143u32 rx_x_recv;144u32 rx_rtt;145ktime_t rx_tstamp_last_feedback;146struct tfrc_rx_hist rx_hist;147struct tfrc_loss_hist rx_li_hist;148u16 rx_s;149#define rx_pinv rx_li_hist.i_mean150};151152static inline struct ccid3_hc_rx_sock *ccid3_hc_rx_sk(const struct sock *sk)153{154struct ccid3_hc_rx_sock *hcrx = ccid_priv(dccp_sk(sk)->dccps_hc_rx_ccid);155BUG_ON(hcrx == NULL);156return hcrx;157}158159#endif /* _DCCP_CCID3_H_ */160161162