17c657876SArnaldo Carvalho de Melo /* 27c657876SArnaldo Carvalho de Melo * net/dccp/ccids/ccid3.h 37c657876SArnaldo Carvalho de Melo * 4e6bccd35SIan McDonald * Copyright (c) 2005-6 The University of Waikato, Hamilton, New Zealand. 57c657876SArnaldo Carvalho de Melo * 67c657876SArnaldo Carvalho de Melo * An implementation of the DCCP protocol 77c657876SArnaldo Carvalho de Melo * 87c657876SArnaldo Carvalho de Melo * This code has been developed by the University of Waikato WAND 97c657876SArnaldo Carvalho de Melo * research group. For further information please see http://www.wand.net.nz/ 10e6bccd35SIan McDonald * or e-mail Ian McDonald - ian.mcdonald@jandi.co.nz 117c657876SArnaldo Carvalho de Melo * 127c657876SArnaldo Carvalho de Melo * This code also uses code from Lulea University, rereleased as GPL by its 137c657876SArnaldo Carvalho de Melo * authors: 147c657876SArnaldo Carvalho de Melo * Copyright (c) 2003 Nils-Erik Mattsson, Joacim Haggmark, Magnus Erixzon 157c657876SArnaldo Carvalho de Melo * 167c657876SArnaldo Carvalho de Melo * Changes to meet Linux coding standards, to make it meet latest ccid3 draft 177c657876SArnaldo Carvalho de Melo * and to make it work as a loadable module in the DCCP stack written by 187c657876SArnaldo Carvalho de Melo * Arnaldo Carvalho de Melo <acme@conectiva.com.br>. 197c657876SArnaldo Carvalho de Melo * 207c657876SArnaldo Carvalho de Melo * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@conectiva.com.br> 217c657876SArnaldo Carvalho de Melo * 227c657876SArnaldo Carvalho de Melo * This program is free software; you can redistribute it and/or modify 237c657876SArnaldo Carvalho de Melo * it under the terms of the GNU General Public License as published by 247c657876SArnaldo Carvalho de Melo * the Free Software Foundation; either version 2 of the License, or 257c657876SArnaldo Carvalho de Melo * (at your option) any later version. 267c657876SArnaldo Carvalho de Melo * 277c657876SArnaldo Carvalho de Melo * This program is distributed in the hope that it will be useful, 287c657876SArnaldo Carvalho de Melo * but WITHOUT ANY WARRANTY; without even the implied warranty of 297c657876SArnaldo Carvalho de Melo * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 307c657876SArnaldo Carvalho de Melo * GNU General Public License for more details. 317c657876SArnaldo Carvalho de Melo * 327c657876SArnaldo Carvalho de Melo * You should have received a copy of the GNU General Public License 337c657876SArnaldo Carvalho de Melo * along with this program; if not, write to the Free Software 347c657876SArnaldo Carvalho de Melo * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 357c657876SArnaldo Carvalho de Melo */ 367c657876SArnaldo Carvalho de Melo #ifndef _DCCP_CCID3_H_ 377c657876SArnaldo Carvalho de Melo #define _DCCP_CCID3_H_ 387c657876SArnaldo Carvalho de Melo 398132da4dSGerrit Renker #include <linux/ktime.h> 407c657876SArnaldo Carvalho de Melo #include <linux/list.h> 41cfc3c525SArnaldo Carvalho de Melo #include <linux/types.h> 4265299d6cSArnaldo Carvalho de Melo #include <linux/tfrc.h> 4391f0ebf7SArnaldo Carvalho de Melo #include "../ccid.h" 44cfc3c525SArnaldo Carvalho de Melo 4548e03eeeSGerrit Renker /* Two seconds as per RFC 3448 4.2 */ 46cfc3c525SArnaldo Carvalho de Melo #define TFRC_INITIAL_TIMEOUT (2 * USEC_PER_SEC) 47cfc3c525SArnaldo Carvalho de Melo 48cfc3c525SArnaldo Carvalho de Melo /* In usecs - half the scheduling granularity as per RFC3448 4.6 */ 49cfc3c525SArnaldo Carvalho de Melo #define TFRC_OPSYS_HALF_TIME_GRAN (USEC_PER_SEC / (2 * HZ)) 50cfc3c525SArnaldo Carvalho de Melo 51a79ef76fSGerrit Renker /* Parameter t_mbi from [RFC 3448, 4.3]: backoff interval in seconds */ 52a79ef76fSGerrit Renker #define TFRC_T_MBI 64 53cfc3c525SArnaldo Carvalho de Melo 54cfc3c525SArnaldo Carvalho de Melo enum ccid3_options { 55cfc3c525SArnaldo Carvalho de Melo TFRC_OPT_LOSS_EVENT_RATE = 192, 56cfc3c525SArnaldo Carvalho de Melo TFRC_OPT_LOSS_INTERVALS = 193, 57cfc3c525SArnaldo Carvalho de Melo TFRC_OPT_RECEIVE_RATE = 194, 58cfc3c525SArnaldo Carvalho de Melo }; 597c657876SArnaldo Carvalho de Melo 607c657876SArnaldo Carvalho de Melo struct ccid3_options_received { 617c657876SArnaldo Carvalho de Melo u64 ccid3or_seqno:48, 627c657876SArnaldo Carvalho de Melo ccid3or_loss_intervals_idx:16; 637c657876SArnaldo Carvalho de Melo u16 ccid3or_loss_intervals_len; 647c657876SArnaldo Carvalho de Melo u32 ccid3or_loss_event_rate; 657c657876SArnaldo Carvalho de Melo u32 ccid3or_receive_rate; 667c657876SArnaldo Carvalho de Melo }; 677c657876SArnaldo Carvalho de Melo 683c695262SGerrit Renker /* TFRC sender states */ 693c695262SGerrit Renker enum ccid3_hc_tx_states { 703c695262SGerrit Renker TFRC_SSTATE_NO_SENT = 1, 713c695262SGerrit Renker TFRC_SSTATE_NO_FBACK, 723c695262SGerrit Renker TFRC_SSTATE_FBACK, 733c695262SGerrit Renker TFRC_SSTATE_TERM, 743c695262SGerrit Renker }; 753c695262SGerrit Renker 7623ea8945SGerrit Renker /** struct ccid3_hc_tx_sock - CCID3 sender half-connection socket 777c657876SArnaldo Carvalho de Melo * 781a21e49aSGerrit Renker * @ccid3hctx_x - Current sending rate in 64 * bytes per second 791a21e49aSGerrit Renker * @ccid3hctx_x_recv - Receive rate in 64 * bytes per second 801a21e49aSGerrit Renker * @ccid3hctx_x_calc - Calculated rate in bytes per second 817c657876SArnaldo Carvalho de Melo * @ccid3hctx_rtt - Estimate of current round trip time in usecs 8223ea8945SGerrit Renker * @ccid3hctx_p - Current loss event rate (0-1) scaled by 1000000 831a21e49aSGerrit Renker * @ccid3hctx_s - Packet size in bytes 841a21e49aSGerrit Renker * @ccid3hctx_t_rto - Nofeedback Timer setting in usecs 851a21e49aSGerrit Renker * @ccid3hctx_t_ipi - Interpacket (send) interval (RFC 3448, 4.6) in usecs 8623ea8945SGerrit Renker * @ccid3hctx_state - Sender state, one of %ccid3_hc_tx_states 877c657876SArnaldo Carvalho de Melo * @ccid3hctx_last_win_count - Last window counter sent 88cfc3c525SArnaldo Carvalho de Melo * @ccid3hctx_t_last_win_count - Timestamp of earliest packet 89cfc3c525SArnaldo Carvalho de Melo * with last_win_count value sent 907c657876SArnaldo Carvalho de Melo * @ccid3hctx_no_feedback_timer - Handle to no feedback timer 9123ea8945SGerrit Renker * @ccid3hctx_idle - Flag indicating that sender is idling 927c657876SArnaldo Carvalho de Melo * @ccid3hctx_t_ld - Time last doubled during slow start 937c657876SArnaldo Carvalho de Melo * @ccid3hctx_t_nom - Nominal send time of next packet 941a21e49aSGerrit Renker * @ccid3hctx_delta - Send timer delta (RFC 3448, 4.6) in usecs 957c657876SArnaldo Carvalho de Melo * @ccid3hctx_hist - Packet history 9623ea8945SGerrit Renker * @ccid3hctx_options_received - Parsed set of retrieved options 977c657876SArnaldo Carvalho de Melo */ 987c657876SArnaldo Carvalho de Melo struct ccid3_hc_tx_sock { 9965299d6cSArnaldo Carvalho de Melo struct tfrc_tx_info ccid3hctx_tfrc; 10065299d6cSArnaldo Carvalho de Melo #define ccid3hctx_x ccid3hctx_tfrc.tfrctx_x 10165299d6cSArnaldo Carvalho de Melo #define ccid3hctx_x_recv ccid3hctx_tfrc.tfrctx_x_recv 10265299d6cSArnaldo Carvalho de Melo #define ccid3hctx_x_calc ccid3hctx_tfrc.tfrctx_x_calc 10365299d6cSArnaldo Carvalho de Melo #define ccid3hctx_rtt ccid3hctx_tfrc.tfrctx_rtt 10465299d6cSArnaldo Carvalho de Melo #define ccid3hctx_p ccid3hctx_tfrc.tfrctx_p 10565299d6cSArnaldo Carvalho de Melo #define ccid3hctx_t_rto ccid3hctx_tfrc.tfrctx_rto 10665299d6cSArnaldo Carvalho de Melo #define ccid3hctx_t_ipi ccid3hctx_tfrc.tfrctx_ipi 1077c657876SArnaldo Carvalho de Melo u16 ccid3hctx_s; 1083c695262SGerrit Renker enum ccid3_hc_tx_states ccid3hctx_state:8; 1097c657876SArnaldo Carvalho de Melo u8 ccid3hctx_last_win_count; 1107c657876SArnaldo Carvalho de Melo u8 ccid3hctx_idle; 1118132da4dSGerrit Renker ktime_t ccid3hctx_t_last_win_count; 1127c657876SArnaldo Carvalho de Melo struct timer_list ccid3hctx_no_feedback_timer; 11323f062afSArnaldo Carvalho de Melo ktime_t ccid3hctx_t_ld; 1148132da4dSGerrit Renker ktime_t ccid3hctx_t_nom; 1157c657876SArnaldo Carvalho de Melo u32 ccid3hctx_delta; 1167c657876SArnaldo Carvalho de Melo struct list_head ccid3hctx_hist; 1177c657876SArnaldo Carvalho de Melo struct ccid3_options_received ccid3hctx_options_received; 1187c657876SArnaldo Carvalho de Melo }; 1197c657876SArnaldo Carvalho de Melo 1203c695262SGerrit Renker /* TFRC receiver states */ 1213c695262SGerrit Renker enum ccid3_hc_rx_states { 1223c695262SGerrit Renker TFRC_RSTATE_NO_DATA = 1, 1233c695262SGerrit Renker TFRC_RSTATE_DATA, 1243c695262SGerrit Renker TFRC_RSTATE_TERM = 127, 1253c695262SGerrit Renker }; 1263c695262SGerrit Renker 12723ea8945SGerrit Renker /** struct ccid3_hc_rx_sock - CCID3 receiver half-connection socket 12823ea8945SGerrit Renker * 12923ea8945SGerrit Renker * @ccid3hcrx_x_recv - Receiver estimate of send rate (RFC 3448 4.3) 13023ea8945SGerrit Renker * @ccid3hcrx_rtt - Receiver estimate of rtt (non-standard) 13123ea8945SGerrit Renker * @ccid3hcrx_p - current loss event rate (RFC 3448 5.4) 13223ea8945SGerrit Renker * @ccid3hcrx_seqno_nonloss - Last received non-loss sequence number 13323ea8945SGerrit Renker * @ccid3hcrx_ccval_nonloss - Last received non-loss Window CCVal 13423ea8945SGerrit Renker * @ccid3hcrx_ccval_last_counter - Tracks window counter (RFC 4342, 8.1) 13523ea8945SGerrit Renker * @ccid3hcrx_state - receiver state, one of %ccid3_hc_rx_states 13623ea8945SGerrit Renker * @ccid3hcrx_bytes_recv - Total sum of DCCP payload bytes 13723ea8945SGerrit Renker * @ccid3hcrx_tstamp_last_feedback - Time at which last feedback was sent 13823ea8945SGerrit Renker * @ccid3hcrx_tstamp_last_ack - Time at which last feedback was sent 13923ea8945SGerrit Renker * @ccid3hcrx_hist - Packet history 14023ea8945SGerrit Renker * @ccid3hcrx_li_hist - Loss Interval History 14123ea8945SGerrit Renker * @ccid3hcrx_s - Received packet size in bytes 14223ea8945SGerrit Renker * @ccid3hcrx_pinv - Inverse of Loss Event Rate (RFC 4342, sec. 8.5) 14323ea8945SGerrit Renker * @ccid3hcrx_elapsed_time - Time since packet reception 14423ea8945SGerrit Renker */ 1457c657876SArnaldo Carvalho de Melo struct ccid3_hc_rx_sock { 14665299d6cSArnaldo Carvalho de Melo struct tfrc_rx_info ccid3hcrx_tfrc; 14765299d6cSArnaldo Carvalho de Melo #define ccid3hcrx_x_recv ccid3hcrx_tfrc.tfrcrx_x_recv 14865299d6cSArnaldo Carvalho de Melo #define ccid3hcrx_rtt ccid3hcrx_tfrc.tfrcrx_rtt 14965299d6cSArnaldo Carvalho de Melo #define ccid3hcrx_p ccid3hcrx_tfrc.tfrcrx_p 15066a377c5SIan McDonald u64 ccid3hcrx_seqno_nonloss:48, 15166a377c5SIan McDonald ccid3hcrx_ccval_nonloss:4, 15266a377c5SIan McDonald ccid3hcrx_ccval_last_counter:4; 1533c695262SGerrit Renker enum ccid3_hc_rx_states ccid3hcrx_state:8; 1547c657876SArnaldo Carvalho de Melo u32 ccid3hcrx_bytes_recv; 1557c657876SArnaldo Carvalho de Melo struct timeval ccid3hcrx_tstamp_last_feedback; 1561faf0a1fSArnaldo Carvalho de Melo ktime_t ccid3hcrx_tstamp_last_ack; 1577c657876SArnaldo Carvalho de Melo struct list_head ccid3hcrx_hist; 158ae6706f0SArnaldo Carvalho de Melo struct list_head ccid3hcrx_li_hist; 1597c657876SArnaldo Carvalho de Melo u16 ccid3hcrx_s; 1607c657876SArnaldo Carvalho de Melo u32 ccid3hcrx_pinv; 1617c657876SArnaldo Carvalho de Melo u32 ccid3hcrx_elapsed_time; 1627c657876SArnaldo Carvalho de Melo }; 1637c657876SArnaldo Carvalho de Melo 16459725dc2SArnaldo Carvalho de Melo static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk) 16559725dc2SArnaldo Carvalho de Melo { 16691f0ebf7SArnaldo Carvalho de Melo return ccid_priv(dccp_sk(sk)->dccps_hc_tx_ccid); 16759725dc2SArnaldo Carvalho de Melo } 1687c657876SArnaldo Carvalho de Melo 16959725dc2SArnaldo Carvalho de Melo static inline struct ccid3_hc_rx_sock *ccid3_hc_rx_sk(const struct sock *sk) 17059725dc2SArnaldo Carvalho de Melo { 17191f0ebf7SArnaldo Carvalho de Melo return ccid_priv(dccp_sk(sk)->dccps_hc_rx_ccid); 17259725dc2SArnaldo Carvalho de Melo } 1737c657876SArnaldo Carvalho de Melo 1747c657876SArnaldo Carvalho de Melo #endif /* _DCCP_CCID3_H_ */ 175