cc.h (4e4c84f8d101216ebf303f04ce9d4327c3328059) cc.h (b8d60729deefa0bd13e6a395fcab4928e6e10445)
1/*-
2 * Copyright (c) 2007-2008
3 * Swinburne University of Technology, Melbourne, Australia.
4 * Copyright (c) 2009-2010 Lawrence Stewart <lstewart@freebsd.org>
5 * Copyright (c) 2010 The FreeBSD Foundation
6 * All rights reserved.
7 *
8 * This software was developed at the Centre for Advanced Internet

--- 39 unchanged lines hidden (view full) ---

48 * http://caia.swin.edu.au/urp/newtcp/
49 */
50
51#ifndef _NETINET_CC_CC_H_
52#define _NETINET_CC_CC_H_
53
54#ifdef _KERNEL
55
1/*-
2 * Copyright (c) 2007-2008
3 * Swinburne University of Technology, Melbourne, Australia.
4 * Copyright (c) 2009-2010 Lawrence Stewart <lstewart@freebsd.org>
5 * Copyright (c) 2010 The FreeBSD Foundation
6 * All rights reserved.
7 *
8 * This software was developed at the Centre for Advanced Internet

--- 39 unchanged lines hidden (view full) ---

48 * http://caia.swin.edu.au/urp/newtcp/
49 */
50
51#ifndef _NETINET_CC_CC_H_
52#define _NETINET_CC_CC_H_
53
54#ifdef _KERNEL
55
56MALLOC_DECLARE(M_CC_MEM);
57
56/* Global CC vars. */
57extern STAILQ_HEAD(cc_head, cc_algo) cc_list;
58extern const int tcprexmtthresh;
58/* Global CC vars. */
59extern STAILQ_HEAD(cc_head, cc_algo) cc_list;
60extern const int tcprexmtthresh;
59extern struct cc_algo newreno_cc_algo;
60
61/* Per-netstack bits. */
62VNET_DECLARE(struct cc_algo *, default_cc_ptr);
63#define V_default_cc_ptr VNET(default_cc_ptr)
64
65VNET_DECLARE(int, cc_do_abe);
66#define V_cc_do_abe VNET(cc_do_abe)
67

--- 66 unchanged lines hidden (view full) ---

134 char name[TCP_CA_NAME_MAX];
135
136 /* Init global module state on kldload. */
137 int (*mod_init)(void);
138
139 /* Cleanup global module state on kldunload. */
140 int (*mod_destroy)(void);
141
61
62/* Per-netstack bits. */
63VNET_DECLARE(struct cc_algo *, default_cc_ptr);
64#define V_default_cc_ptr VNET(default_cc_ptr)
65
66VNET_DECLARE(int, cc_do_abe);
67#define V_cc_do_abe VNET(cc_do_abe)
68

--- 66 unchanged lines hidden (view full) ---

135 char name[TCP_CA_NAME_MAX];
136
137 /* Init global module state on kldload. */
138 int (*mod_init)(void);
139
140 /* Cleanup global module state on kldunload. */
141 int (*mod_destroy)(void);
142
142 /* Init CC state for a new control block. */
143 int (*cb_init)(struct cc_var *ccv);
143 /* Return the size of the void pointer the CC needs for state */
144 size_t (*cc_data_sz)(void);
144
145
146 /*
147 * Init CC state for a new control block. The CC
148 * module may be passed a NULL ptr indicating that
149 * it must allocate the memory. If it is passed a
150 * non-null pointer it is pre-allocated memory by
151 * the caller and the cb_init is expected to use that memory.
152 * It is not expected to fail if memory is passed in and
153 * all currently defined modules do not.
154 */
155 int (*cb_init)(struct cc_var *ccv, void *ptr);
156
145 /* Cleanup CC state for a terminating control block. */
146 void (*cb_destroy)(struct cc_var *ccv);
147
148 /* Init variables for a newly established connection. */
149 void (*conn_init)(struct cc_var *ccv);
150
151 /* Called on receipt of an ack. */
152 void (*ack_received)(struct cc_var *ccv, uint16_t type);

--- 18 unchanged lines hidden (view full) ---

171 * send the cwnd in).
172 */
173 void (*rttsample)(struct cc_var *ccv, uint32_t usec_rtt, uint32_t rxtcnt, uint32_t fas);
174
175 /* Called for {get|set}sockopt() on a TCP socket with TCP_CCALGOOPT. */
176 int (*ctl_output)(struct cc_var *, struct sockopt *, void *);
177
178 STAILQ_ENTRY (cc_algo) entries;
157 /* Cleanup CC state for a terminating control block. */
158 void (*cb_destroy)(struct cc_var *ccv);
159
160 /* Init variables for a newly established connection. */
161 void (*conn_init)(struct cc_var *ccv);
162
163 /* Called on receipt of an ack. */
164 void (*ack_received)(struct cc_var *ccv, uint16_t type);

--- 18 unchanged lines hidden (view full) ---

183 * send the cwnd in).
184 */
185 void (*rttsample)(struct cc_var *ccv, uint32_t usec_rtt, uint32_t rxtcnt, uint32_t fas);
186
187 /* Called for {get|set}sockopt() on a TCP socket with TCP_CCALGOOPT. */
188 int (*ctl_output)(struct cc_var *, struct sockopt *, void *);
189
190 STAILQ_ENTRY (cc_algo) entries;
191 uint8_t flags;
179};
180
192};
193
194#define CC_MODULE_BEING_REMOVED 0x01 /* The module is being removed */
195
181/* Macro to obtain the CC algo's struct ptr. */
182#define CC_ALGO(tp) ((tp)->cc_algo)
183
184/* Macro to obtain the CC algo's data ptr. */
185#define CC_DATA(tp) ((tp)->ccv->cc_data)
186
187/* Macro to obtain the system default CC algo's struct ptr. */
196/* Macro to obtain the CC algo's struct ptr. */
197#define CC_ALGO(tp) ((tp)->cc_algo)
198
199/* Macro to obtain the CC algo's data ptr. */
200#define CC_DATA(tp) ((tp)->ccv->cc_data)
201
202/* Macro to obtain the system default CC algo's struct ptr. */
188#define CC_DEFAULT() V_default_cc_ptr
203#define CC_DEFAULT_ALGO() V_default_cc_ptr
189
190extern struct rwlock cc_list_lock;
191#define CC_LIST_LOCK_INIT() rw_init(&cc_list_lock, "cc_list")
192#define CC_LIST_LOCK_DESTROY() rw_destroy(&cc_list_lock)
193#define CC_LIST_RLOCK() rw_rlock(&cc_list_lock)
194#define CC_LIST_RUNLOCK() rw_runlock(&cc_list_lock)
195#define CC_LIST_WLOCK() rw_wlock(&cc_list_lock)
196#define CC_LIST_WUNLOCK() rw_wunlock(&cc_list_lock)
197#define CC_LIST_LOCK_ASSERT() rw_assert(&cc_list_lock, RA_LOCKED)
198
199#define CC_ALGOOPT_LIMIT 2048
200
204
205extern struct rwlock cc_list_lock;
206#define CC_LIST_LOCK_INIT() rw_init(&cc_list_lock, "cc_list")
207#define CC_LIST_LOCK_DESTROY() rw_destroy(&cc_list_lock)
208#define CC_LIST_RLOCK() rw_rlock(&cc_list_lock)
209#define CC_LIST_RUNLOCK() rw_runlock(&cc_list_lock)
210#define CC_LIST_WLOCK() rw_wlock(&cc_list_lock)
211#define CC_LIST_WUNLOCK() rw_wunlock(&cc_list_lock)
212#define CC_LIST_LOCK_ASSERT() rw_assert(&cc_list_lock, RA_LOCKED)
213
214#define CC_ALGOOPT_LIMIT 2048
215
216/*
217 * These routines give NewReno behavior to the caller
218 * they require no state and can be used by any other CC
219 * module that wishes to use NewReno type behaviour (along
220 * with anything else they may add on, pre or post call).
221 */
222void newreno_cc_post_recovery(struct cc_var *);
223void newreno_cc_after_idle(struct cc_var *);
224void newreno_cc_cong_signal(struct cc_var *, uint32_t );
225void newreno_cc_ack_received(struct cc_var *, uint16_t);
226
201#endif /* _KERNEL */
202#endif /* _NETINET_CC_CC_H_ */
227#endif /* _KERNEL */
228#endif /* _NETINET_CC_CC_H_ */