On Sun, 11 Oct 2026 18:21:54 +0000
Marat Khalili <[email protected]> wrote:
> --- a/lib/bpf/bpf_pkt.c
> +++ b/lib/bpf/bpf_pkt.c
> @@ -36,12 +36,12 @@
> * 2. Member `cb` of struct `bpf_eth_cbi`;
> * 3. Member `use` of struct `bpf_eth_cbi`;
> *
> - * BPF program is only executed if the first two are set, and increments
> `use` at the start and
> - * end of the callback execution so that in the safe state its value is even.
> + * BPF program is only executed if the first two are set, and sets `use` to
> 1 at the start and
> + * to 0 at the end of the callback execution.
> * This relies on only one thread calling the per-port/queue callback at a
> time.
> *
> * Unload processing starts with clearing the first two entities,
> - * then waits for `use` to become even before destroying the BPF program.
> + * then waits for `use` to become 0 before destroying the BPF program.
> * The whole operation is protected by a control-plane-only spinlock (not
> shown on the diagram).
> *
> * Typical sequence of synchronization actions between CP and DP on unload
> is shown below:
> @@ -52,7 +52,7 @@
> * | | | |
> | |
> * | |<---------------------- fetch callback
> -----------------------|
> * | | | |
> | |
> - * | | |<------------- increment to
> odd --------------|
> + * | | |<------------- store 1
> -----------------------|
> * | | | |
> | |
> * |-- remove callback -->| | |
> | rte_smp_mb()
> * | | | |
> | |
> @@ -62,17 +62,17 @@
> * | | | |
> | |
> * rte_smp_mb() | | |
> | |
> * | | | |
> | |
> - * +-if use is odd | | |
> | if cb not NULL-+
> + * +-while use is 1 | | |
> | if cb not NULL-+
> * | | | | |
> | | |
> - * | +------------ fetch odd ------------>| |
> |<-- execute --+ |
> + * | +------------ fetch 1 -------------->| |
> |<-- execute --+ |
> * | | | | |
> | BPF program | |
> - * | +-while use is same | | |
> | +-+
> - * | | | | | |
> | |
> - * | | +---------- fetch odd ------------>| |
> | rte_smp_rmb()
> - * | | | | | |
> | |
> - * +-+-+ | |<------------- increment to
> even -------------|
> + * | | | | |
> | +-+
> + * | | | | |
> | |
> + * | | | | |
> | rte_smp_rmb()
> + * | | | | |
> | |
> + * +-+ | |<------------- store 0
> -----------------------|
> * | | | |
> | |
> - * |------------- fetch even ------------>| |
> | |
> + * |------------- fetch 0 --------------->| |
> | |
> * | | | |
> | |
> * |----------------- destroy BPF program and cleanup
> ----------------->| |
> * | | | |
> | |
> @@ -87,7 +87,7 @@
> */
> struct __rte_cache_aligned bpf_eth_cbi {
> /* used by both data & control path */
> - RTE_ATOMIC(uint32_t) use; /*usage counter */
> + RTE_ATOMIC(uint32_t) use; /* usage flag: 1 when in use, 0 otherwise
> */
If it is only on/off now make it a bool.