include/net/red.h
Source file repositories/reference/linux-study-clean/include/net/red.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/red.h- Extension
.h- Size
- 11667 bytes
- Lines
- 466
- 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
linux/types.hlinux/bug.hnet/pkt_sched.hnet/inet_ecn.hnet/dsfield.hlinux/reciprocal_div.h
Detected Declarations
struct red_statsstruct red_parmsstruct red_varsfunction red_maxpfunction red_set_varsfunction red_check_paramsfunction red_get_flagsfunction red_validate_flagsfunction red_set_parmsfunction red_is_idlingfunction red_start_of_idle_periodfunction red_end_of_idle_periodfunction red_restartfunction red_calc_qavg_from_idle_timefunction red_calc_qavg_no_idle_timefunction red_calc_qavgfunction red_randomfunction red_mark_probabilityfunction red_cmp_threshfunction red_actionfunction red_adaptative_algo
Annotated Snippet
struct red_stats {
u32 prob_drop; /* Early probability drops */
u32 prob_mark; /* Early probability marks */
u32 forced_drop; /* Forced drops, qavg > max_thresh */
u32 forced_mark; /* Forced marks, qavg > max_thresh */
u32 pdrop; /* Drops due to queue limits */
};
struct red_parms {
/* Parameters */
u32 qth_min; /* Min avg length threshold: Wlog scaled */
u32 qth_max; /* Max avg length threshold: Wlog scaled */
u32 Scell_max;
u32 max_P; /* probability, [0 .. 1.0] 32 scaled */
/* reciprocal_value(max_P / qth_delta) */
struct reciprocal_value max_P_reciprocal;
u32 qth_delta; /* max_th - min_th */
u32 target_min; /* min_th + 0.4*(max_th - min_th) */
u32 target_max; /* min_th + 0.6*(max_th - min_th) */
u8 Scell_log;
u8 Wlog; /* log(W) */
u8 Plog; /* random number bits */
u8 Stab[RED_STAB_SIZE];
};
struct red_vars {
/* Variables */
int qcount; /* Number of packets since last random
number generation */
u32 qR; /* Cached random number */
unsigned long qavg; /* Average queue length: Wlog scaled */
ktime_t qidlestart; /* Start of current idle period */
};
static inline u32 red_maxp(u8 Plog)
{
return Plog < 32 ? (~0U >> Plog) : ~0U;
}
static inline void red_set_vars(struct red_vars *v)
{
/* Reset average queue length, the value is strictly bound
* to the parameters below, resetting hurts a bit but leaving
* it might result in an unreasonable qavg for a while. --TGR
*/
v->qavg = 0;
v->qcount = -1;
}
static inline bool red_check_params(u32 qth_min, u32 qth_max, u8 Wlog,
u8 Scell_log, u8 *stab)
{
if (fls(qth_min) + Wlog >= 32)
return false;
if (fls(qth_max) + Wlog >= 32)
return false;
if (Scell_log >= 32)
return false;
if (qth_max < qth_min)
return false;
if (stab) {
int i;
for (i = 0; i < RED_STAB_SIZE; i++)
if (stab[i] >= 32)
return false;
}
return true;
}
static inline int red_get_flags(unsigned char qopt_flags,
unsigned char historic_mask,
struct nlattr *flags_attr,
unsigned char supported_mask,
struct nla_bitfield32 *p_flags,
unsigned char *p_userbits,
struct netlink_ext_ack *extack)
{
struct nla_bitfield32 flags;
if (qopt_flags && flags_attr) {
NL_SET_ERR_MSG_MOD(extack, "flags should be passed either through qopt, or through a dedicated attribute");
return -EINVAL;
}
if (flags_attr) {
flags = nla_get_bitfield32(flags_attr);
} else {
Annotation
- Immediate include surface: `linux/types.h`, `linux/bug.h`, `net/pkt_sched.h`, `net/inet_ecn.h`, `net/dsfield.h`, `linux/reciprocal_div.h`.
- Detected declarations: `struct red_stats`, `struct red_parms`, `struct red_vars`, `function red_maxp`, `function red_set_vars`, `function red_check_params`, `function red_get_flags`, `function red_validate_flags`, `function red_set_parms`, `function red_is_idling`.
- 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.