[PATCH RFC net-next 1/4] net: flow_offload: let drivers report byte counter semantics

Daniel Golle
2026-04-09T13:07:37Z

Hardware flow offload engines count bytes at different points --
some report ingress L2 frame bytes, others egress L2, others L3.
Add an enum so drivers can declare what their counters represent.
The framework can then convert to L3 as needed for conntrack.

Default is FLOW_STATS_BYTES_L3 (zero), preserving existing
behaviour for all current drivers.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
include/net/flow_offload.h | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
index 70a02ee143080..7f5ef29b3abce 100644
--- a/include/net/flow_offload.h
+++ b/include/net/flow_offload.h
@@ -541,12 +541,19 @@ static inline bool flow_rule_match_has_control_flags(const struct flow_rule *rul
return flow_rule_has_control_flags(match.mask->flags, extack);
}

+enum flow_stats_byte_type {
+ FLOW_STATS_BYTES_L3 = 0, /* L3 (inner IP) bytes */
+ FLOW_STATS_BYTES_INGRESS_L2, /* full ingress L2 frame bytes */
+ FLOW_STATS_BYTES_EGRESS_L2, /* full egress L2 frame bytes */
+};
+
struct flow_stats {
u64 pkts;
u64 bytes;
u64 drops;
u64 lastused;
enum flow_action_hw_stats used_hw_stats;
+ enum flow_stats_byte_type byte_type;
bool used_hw_stats_valid;
};

--
2.53.0