This is the common code structure for the module’s tcp_powertcp.c
and the BPF
implementation’s powertcp.bpf.c
. It uses direct #include
s of source files
(instead of using multiple compilation units with headers) to enable full
inlining and other optimizations for both the module and BPF implementation.
The parts must appear in this order:
-
General
#include
s, including the requiredlinux/types.h
(module) orvmlinux.h
(BPF) -
An
#include
defining INT-related values and types in this order:-
Provide
max_n_hops
as an enumerator -
#include "powertcp_int.c"
which providesstruct powertcp_int
(requiresmax_n_hops
) and other structs -
Provide a typedef for
powertcp_int_impl_t
, which can alias e.g. a struct or a pointer, and constantsmax_ts
andmax_tx_bytes
This include should be named
tcp_powertcp_METHOD_head.c
resp.powertcp_METHOD_head.bpf.c
, e.g.tcp_powertcp_foobar_head.c
orpowertcp_tcp-int_head.bpf.c
.powertcp_no-int_head.c
shows the required content of this file. -
-
#define
s for variousPOWERTCP_*
macros as needed; their default values are defined inpowertcp_head.c
-
#include "powertcp_head.c"
providing the corestruct powertcp
(requirespowertcp_int_impl_t
), the variables for the algorithm parameters, and default#define
s for the still undefinedPOWERTCP_*
macros -
Additional (algorithm) parameter variables, other static/constant variables
-
Definitions of the required, module- or BPF-specific functions
-
An
#include
defining the INT-related functionsThis include should be named
tcp_powertcp_METHOD.c
resp.powertcp_METHOD.bpf.c
, e.g.tcp_powertcp_foobar.c
orpowertcp_tcp-int.bpf.c
.powertcp_no-int.c
shows the required content of this file. -
#include "powertcp.c"
of the algorithm implementation -
Additional definitions of functions requiring the PowerTCP
tcp_congestion_ops
instances, e.g.module_init
andmodule_exit