1 // SPDX-License-Identifier: GPL-2.0
2 #ifndef __NETCNT_COMMON_H
3 #define __NETCNT_COMMON_H
5 #include <linux/types.h>
7 #define MAX_PERCPU_PACKETS 32
9 /* sizeof(struct bpf_local_storage_elem):
11 * It is about 128 bytes on x86_64 and 512 bytes on s390x, but allocate more to
12 * account for possible layout changes, different architectures, etc.
13 * The kernel will wrap up to PAGE_SIZE internally anyway.
15 #define SIZEOF_BPF_LOCAL_STORAGE_ELEM 768
17 /* Try to estimate kernel's BPF_LOCAL_STORAGE_MAX_VALUE_SIZE: */
18 #define BPF_LOCAL_STORAGE_MAX_VALUE_SIZE (0xFFFF - \
19 SIZEOF_BPF_LOCAL_STORAGE_ELEM)
21 #define PCPU_MIN_UNIT_SIZE 32768
23 union percpu_net_cnt {
33 __u8 data[PCPU_MIN_UNIT_SIZE];
41 __u8 data[BPF_LOCAL_STORAGE_MAX_VALUE_SIZE];