include/net/tc_act/tc_police.h
Source file repositories/reference/linux-study-clean/include/net/tc_act/tc_police.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/tc_act/tc_police.h- Extension
.h- Size
- 4729 bytes
- Lines
- 185
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
net/act_api.h
Detected Declarations
struct tcf_police_paramsstruct tcf_policestruct tc_police_compatfunction tcf_police_rate_bytes_psfunction tcf_police_burstfunction tcf_police_rate_pkt_psfunction tcf_police_burst_pktfunction tcf_police_tcfp_mtufunction tcf_police_peakrate_bytes_psfunction tcf_police_tcfp_ewma_ratefunction tcf_police_rate_overhead
Annotated Snippet
struct tcf_police_params {
int action;
int tcfp_result;
u32 tcfp_ewma_rate;
u32 tcfp_mtu;
s64 tcfp_burst;
s64 tcfp_mtu_ptoks;
s64 tcfp_pkt_burst;
struct psched_ratecfg rate;
bool rate_present;
struct psched_ratecfg peak;
bool peak_present;
struct psched_pktrate ppsrate;
bool pps_present;
struct rcu_head rcu;
};
struct tcf_police {
struct tc_action common;
struct tcf_police_params __rcu *params;
spinlock_t tcfp_lock ____cacheline_aligned_in_smp;
s64 tcfp_toks;
s64 tcfp_ptoks;
s64 tcfp_pkttoks;
s64 tcfp_t_c;
};
#define to_police(pc) ((struct tcf_police *)pc)
/* old policer structure from before tc actions */
struct tc_police_compat {
u32 index;
int action;
u32 limit;
u32 burst;
u32 mtu;
struct tc_ratespec rate;
struct tc_ratespec peakrate;
};
static inline u64 tcf_police_rate_bytes_ps(const struct tc_action *act)
{
struct tcf_police *police = to_police(act);
struct tcf_police_params *params;
params = rcu_dereference_protected(police->params,
lockdep_is_held(&police->tcf_lock));
return params->rate.rate_bytes_ps;
}
static inline u32 tcf_police_burst(const struct tc_action *act)
{
struct tcf_police *police = to_police(act);
struct tcf_police_params *params;
u32 burst;
params = rcu_dereference_protected(police->params,
lockdep_is_held(&police->tcf_lock));
/*
* "rate" bytes "burst" nanoseconds
* ------------ * -------------------
* 1 second 2^6 ticks
*
* ------------------------------------
* NSEC_PER_SEC nanoseconds
* ------------------------
* 2^6 ticks
*
* "rate" bytes "burst" nanoseconds 2^6 ticks
* = ------------ * ------------------- * ------------------------
* 1 second 2^6 ticks NSEC_PER_SEC nanoseconds
*
* "rate" * "burst"
* = ---------------- bytes/nanosecond
* NSEC_PER_SEC^2
*
*
* "rate" * "burst"
* = ---------------- bytes/second
* NSEC_PER_SEC
*/
burst = div_u64(params->tcfp_burst * params->rate.rate_bytes_ps,
NSEC_PER_SEC);
return burst;
}
static inline u64 tcf_police_rate_pkt_ps(const struct tc_action *act)
Annotation
- Immediate include surface: `net/act_api.h`.
- Detected declarations: `struct tcf_police_params`, `struct tcf_police`, `struct tc_police_compat`, `function tcf_police_rate_bytes_ps`, `function tcf_police_burst`, `function tcf_police_rate_pkt_ps`, `function tcf_police_burst_pkt`, `function tcf_police_tcfp_mtu`, `function tcf_police_peakrate_bytes_ps`, `function tcf_police_tcfp_ewma_rate`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.