-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpowertcp_head.c
90 lines (75 loc) · 2.93 KB
/
powertcp_head.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// SPDX-License-Identifier: GPL-2.0 OR MIT
#ifndef POWERTCP_CONG_OPS_ATTRS
#define POWERTCP_CONG_OPS_ATTRS
#endif
#ifndef POWERTCP_CONG_OPS_FUNC
#define POWERTCP_CONG_OPS_FUNC(name, args...) name(args)
#endif
#ifndef POWERTCP_CONG_OPS_FUNC_PTR
#define POWERTCP_CONG_OPS_FUNC_PTR
#endif
#ifndef POWERTCP_CONG_OPS_NAME_PREFIX
#define POWERTCP_CONG_OPS_NAME_PREFIX
#endif
#ifndef POWERTCP_LIKELY
#define POWERTCP_LIKELY(cond) cond
#endif
#ifndef POWERTCP_PARAM_ATTRS
#define POWERTCP_PARAM_ATTRS
#endif
#ifndef POWERTCP_UNLIKELY
#define POWERTCP_UNLIKELY(cond) cond
#endif
#ifndef __stringify
#define __stringify_1(x...) #x
#define __stringify(x...) __stringify_1(x)
#endif
struct old_cwnd {
u32 snd_nxt;
unsigned long cwnd;
};
#define POWERTCP_STRUCT(struct_name, ...) \
struct struct_name { \
unsigned long base_rtt; \
unsigned long snd_cwnd; \
\
unsigned long beta; /* number of packets scaled by cwnd_scale */ \
\
struct old_cwnd old_cwnd; \
\
unsigned long p_smooth; \
\
/* powertcp_cong_control() seems to (unexpectedly) get called once before \
* powertcp_init(). host_bw is still 0 then, thanks to \
* tcp_assign_congestion_control(), and we use that as an indicator whether \
* we are initialized. \
*/ \
unsigned long host_bw; /* Mbit/s */ \
\
__VA_ARGS__ \
}
#define POWERTCP_STRUCT_FIELDS(fields) fields
// clang-format off
POWERTCP_STRUCT(powertcp);
POWERTCP_STRUCT(ptcp_powertcp,
POWERTCP_STRUCT_FIELDS(
powertcp_int_impl_t int_impl;
)
);
POWERTCP_STRUCT(rttptcp_powertcp,
POWERTCP_STRUCT_FIELDS(
u32 last_updated;
unsigned long prev_rtt_us;
u64 t; /* in ns */
u64 t_prev; /* in ns */
)
);
// clang-format on
#undef POWERTCP_STRUCT
#undef POWERTCP_STRUCT_FIELDS
POWERTCP_PARAM_ATTRS long base_rtt = default_base_rtt;
POWERTCP_PARAM_ATTRS long beta = default_beta; /* Number of packets */
POWERTCP_PARAM_ATTRS long expected_flows = default_expected_flows;
POWERTCP_PARAM_ATTRS long gamma = default_gamma;
POWERTCP_PARAM_ATTRS long hop_bw = default_hop_bw; /* Mbit/s */
POWERTCP_PARAM_ATTRS long host_bw = fallback_host_bw; /* Mbit/s */