This is the common code structure for the module’s tcp_powertcp.c and the BPF
implementation’s powertcp.bpf.c. It uses direct #includes 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
#includes, including the requiredlinux/types.h(module) orvmlinux.h(BPF) -
An
#includedefining INT-related values and types in this order:-
Provide
max_n_hopsas 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_tsandmax_tx_bytes
This include should be named
tcp_powertcp_METHOD_head.cresp.powertcp_METHOD_head.bpf.c, e.g.tcp_powertcp_foobar_head.corpowertcp_tcp-int_head.bpf.c.powertcp_no-int_head.cshows the required content of this file. -
-
#defines 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#defines for the still undefinedPOWERTCP_*macros -
Additional (algorithm) parameter variables, other static/constant variables
-
Definitions of the required, module- or BPF-specific functions
-
An
#includedefining the INT-related functionsThis include should be named
tcp_powertcp_METHOD.cresp.powertcp_METHOD.bpf.c, e.g.tcp_powertcp_foobar.corpowertcp_tcp-int.bpf.c.powertcp_no-int.cshows the required content of this file. -
#include "powertcp.c"of the algorithm implementation -
Additional definitions of functions requiring the PowerTCP
tcp_congestion_opsinstances, e.g.module_initandmodule_exit