Commit | Line | Data |
---|---|---|
8c60f3fa ACM |
1 | /* |
2 | * net/dccp/packet_history.h | |
3 | * | |
e6bccd35 | 4 | * Copyright (c) 2005-6 The University of Waikato, Hamilton, New Zealand. |
8c60f3fa ACM |
5 | * |
6 | * An implementation of the DCCP protocol | |
7 | * | |
8 | * This code has been developed by the University of Waikato WAND | |
9 | * research group. For further information please see http://www.wand.net.nz/ | |
e6bccd35 | 10 | * or e-mail Ian McDonald - ian.mcdonald@jandi.co.nz |
8c60f3fa ACM |
11 | * |
12 | * This code also uses code from Lulea University, rereleased as GPL by its | |
13 | * authors: | |
14 | * Copyright (c) 2003 Nils-Erik Mattsson, Joacim Haggmark, Magnus Erixzon | |
15 | * | |
16 | * Changes to meet Linux coding standards, to make it meet latest ccid3 draft | |
17 | * and to make it work as a loadable module in the DCCP stack written by | |
18 | * Arnaldo Carvalho de Melo <acme@conectiva.com.br>. | |
19 | * | |
20 | * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@conectiva.com.br> | |
21 | * | |
22 | * This program is free software; you can redistribute it and/or modify | |
23 | * it under the terms of the GNU General Public License as published by | |
24 | * the Free Software Foundation; either version 2 of the License, or | |
25 | * (at your option) any later version. | |
26 | * | |
27 | * This program is distributed in the hope that it will be useful, | |
28 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
29 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
30 | * GNU General Public License for more details. | |
31 | * | |
32 | * You should have received a copy of the GNU General Public License | |
33 | * along with this program; if not, write to the Free Software | |
34 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
35 | */ | |
36 | ||
37 | #ifndef _DCCP_PKT_HIST_ | |
38 | #define _DCCP_PKT_HIST_ | |
39 | ||
8c60f3fa ACM |
40 | #include <linux/list.h> |
41 | #include <linux/slab.h> | |
42 | #include <linux/time.h> | |
43 | ||
4524b259 | 44 | #include "../../dccp.h" |
8c60f3fa | 45 | |
072ab6c6 ACM |
46 | /* Number of later packets received before one is considered lost */ |
47 | #define TFRC_RECV_NUM_LATE_LOSS 3 | |
48 | ||
49 | #define TFRC_WIN_COUNT_PER_RTT 4 | |
50 | #define TFRC_WIN_COUNT_LIMIT 16 | |
51 | ||
8c60f3fa ACM |
52 | struct dccp_tx_hist_entry { |
53 | struct list_head dccphtx_node; | |
54 | u64 dccphtx_seqno:48, | |
c1734376 | 55 | dccphtx_ccval:4, |
8c60f3fa | 56 | dccphtx_sent:1; |
c1734376 | 57 | u32 dccphtx_rtt; |
8c60f3fa ACM |
58 | struct timeval dccphtx_tstamp; |
59 | }; | |
60 | ||
61 | struct dccp_rx_hist_entry { | |
62 | struct list_head dccphrx_node; | |
63 | u64 dccphrx_seqno:48, | |
c1734376 | 64 | dccphrx_ccval:4, |
8c60f3fa ACM |
65 | dccphrx_type:4; |
66 | u32 dccphrx_ndp; /* In fact it is from 8 to 24 bits */ | |
67 | struct timeval dccphrx_tstamp; | |
68 | }; | |
69 | ||
70 | struct dccp_tx_hist { | |
71 | kmem_cache_t *dccptxh_slab; | |
72 | }; | |
73 | ||
74 | extern struct dccp_tx_hist *dccp_tx_hist_new(const char *name); | |
75 | extern void dccp_tx_hist_delete(struct dccp_tx_hist *hist); | |
76 | ||
77 | struct dccp_rx_hist { | |
78 | kmem_cache_t *dccprxh_slab; | |
79 | }; | |
80 | ||
81 | extern struct dccp_rx_hist *dccp_rx_hist_new(const char *name); | |
82 | extern void dccp_rx_hist_delete(struct dccp_rx_hist *hist); | |
83 | extern struct dccp_rx_hist_entry * | |
84 | dccp_rx_hist_find_data_packet(const struct list_head *list); | |
85 | ||
86 | static inline struct dccp_tx_hist_entry * | |
a1d3a355 | 87 | dccp_tx_hist_entry_new(struct dccp_tx_hist *hist, |
dd0fc66f | 88 | const gfp_t prio) |
8c60f3fa ACM |
89 | { |
90 | struct dccp_tx_hist_entry *entry = kmem_cache_alloc(hist->dccptxh_slab, | |
91 | prio); | |
92 | ||
93 | if (entry != NULL) | |
94 | entry->dccphtx_sent = 0; | |
95 | ||
96 | return entry; | |
97 | } | |
98 | ||
99 | static inline void dccp_tx_hist_entry_delete(struct dccp_tx_hist *hist, | |
100 | struct dccp_tx_hist_entry *entry) | |
101 | { | |
102 | if (entry != NULL) | |
103 | kmem_cache_free(hist->dccptxh_slab, entry); | |
104 | } | |
105 | ||
106 | extern struct dccp_tx_hist_entry * | |
107 | dccp_tx_hist_find_entry(const struct list_head *list, | |
108 | const u64 seq); | |
109 | ||
110 | static inline void dccp_tx_hist_add_entry(struct list_head *list, | |
111 | struct dccp_tx_hist_entry *entry) | |
112 | { | |
113 | list_add(&entry->dccphtx_node, list); | |
114 | } | |
115 | ||
116 | extern void dccp_tx_hist_purge_older(struct dccp_tx_hist *hist, | |
117 | struct list_head *list, | |
118 | struct dccp_tx_hist_entry *next); | |
119 | ||
120 | extern void dccp_tx_hist_purge(struct dccp_tx_hist *hist, | |
121 | struct list_head *list); | |
122 | ||
7690af3f ACM |
123 | static inline struct dccp_tx_hist_entry * |
124 | dccp_tx_hist_head(struct list_head *list) | |
8c60f3fa ACM |
125 | { |
126 | struct dccp_tx_hist_entry *head = NULL; | |
127 | ||
128 | if (!list_empty(list)) | |
129 | head = list_entry(list->next, struct dccp_tx_hist_entry, | |
130 | dccphtx_node); | |
131 | return head; | |
132 | } | |
133 | ||
134 | static inline struct dccp_rx_hist_entry * | |
a1d3a355 | 135 | dccp_rx_hist_entry_new(struct dccp_rx_hist *hist, |
b0e56780 | 136 | const struct sock *sk, |
a1d3a355 ACM |
137 | const u32 ndp, |
138 | const struct sk_buff *skb, | |
dd0fc66f | 139 | const gfp_t prio) |
8c60f3fa ACM |
140 | { |
141 | struct dccp_rx_hist_entry *entry = kmem_cache_alloc(hist->dccprxh_slab, | |
142 | prio); | |
143 | ||
144 | if (entry != NULL) { | |
145 | const struct dccp_hdr *dh = dccp_hdr(skb); | |
146 | ||
c1734376 ACM |
147 | entry->dccphrx_seqno = DCCP_SKB_CB(skb)->dccpd_seq; |
148 | entry->dccphrx_ccval = dh->dccph_ccval; | |
149 | entry->dccphrx_type = dh->dccph_type; | |
150 | entry->dccphrx_ndp = ndp; | |
b0e56780 | 151 | dccp_timestamp(sk, &entry->dccphrx_tstamp); |
8c60f3fa ACM |
152 | } |
153 | ||
154 | return entry; | |
155 | } | |
156 | ||
157 | static inline void dccp_rx_hist_entry_delete(struct dccp_rx_hist *hist, | |
158 | struct dccp_rx_hist_entry *entry) | |
159 | { | |
160 | if (entry != NULL) | |
161 | kmem_cache_free(hist->dccprxh_slab, entry); | |
162 | } | |
163 | ||
164 | extern void dccp_rx_hist_purge(struct dccp_rx_hist *hist, | |
165 | struct list_head *list); | |
166 | ||
167 | static inline void dccp_rx_hist_add_entry(struct list_head *list, | |
168 | struct dccp_rx_hist_entry *entry) | |
169 | { | |
170 | list_add(&entry->dccphrx_node, list); | |
171 | } | |
172 | ||
7690af3f ACM |
173 | static inline struct dccp_rx_hist_entry * |
174 | dccp_rx_hist_head(struct list_head *list) | |
8c60f3fa ACM |
175 | { |
176 | struct dccp_rx_hist_entry *head = NULL; | |
177 | ||
178 | if (!list_empty(list)) | |
179 | head = list_entry(list->next, struct dccp_rx_hist_entry, | |
180 | dccphrx_node); | |
181 | return head; | |
182 | } | |
183 | ||
184 | static inline int | |
185 | dccp_rx_hist_entry_data_packet(const struct dccp_rx_hist_entry *entry) | |
186 | { | |
187 | return entry->dccphrx_type == DCCP_PKT_DATA || | |
188 | entry->dccphrx_type == DCCP_PKT_DATAACK; | |
189 | } | |
190 | ||
072ab6c6 ACM |
191 | extern int dccp_rx_hist_add_packet(struct dccp_rx_hist *hist, |
192 | struct list_head *rx_list, | |
193 | struct list_head *li_list, | |
194 | struct dccp_rx_hist_entry *packet); | |
195 | ||
29e4f8b3 ACM |
196 | extern u64 dccp_rx_hist_detect_loss(struct list_head *rx_list, |
197 | struct list_head *li_list, u8 *win_loss); | |
198 | ||
8c60f3fa | 199 | #endif /* _DCCP_PKT_HIST_ */ |