STRUCT HID_BPF_CTX(9)
π struct hid_bpf_ctx(9) β Kernel API Manual, but make it cute
okay bestie, so this is struct hid_bpf_ctx β it's literally the user-accessible data for all HID programs β¨. Like, every single one. That's the whole vibe.
β¨ SYNOPSIS β¨
struct hid_bpf_ctx {
struct hid_device *hid;
__u32 allocated_size;
union {
__s32 retval;
__s32 size;
};
};
no cap, that's exactly it, copy it character for character π«Ά
π Members π
hidβ thestruct hid_devicethat represents the device itself. main character energy, honestly πallocated_sizeβ how much data is allocated. the size of the data. that's it, that's the tweet π{unnamed_union}β anonymous. yes really, it's just chillin' there unnamed πretvalβ the return value of the previous program. lowkey important πsizeβ the valid data in the data field. the actual usable amount π₯
π¦ Description π¦
so here's the thing bestie β data is not directly accessible from the context. π like you can't just grab it. you gotta issue a call to hid_bpf_get_data in order to get a pointer to that field. that's the whole move, iykyk.
allocated_size is how much memory is available and can be requested by the HID program. and important note, fr fr: for HID_BPF_RDESC_FIXUP, that memory is set to 4096 (4 KB). periodt.
programs can get the available valid size in data by fetching this field. programs can also change this value by returning a positive number in the program. and to discard the event? return a negative error code. simple as that π
β οΈsizemust always be less or equal thanallocated_sizeβ and yes it's enforced once all BPF programs have been run. so don't try it, the kernel will vibe check you π€
and for the read/write tea: hid and allocated_size are read-only, while size and retval are read-write. slay, now you know πΈ
π SEE ALSO π
- Kernel file
./include/linux/hid_bpf.h struct hid_bpf_ops(9)
and that's the whole page, bestie! π this absolute icon came from ./include/linux, dated October 2026, and it's filed under struct hid_bpf_ctx(9) β go off, king π§β¨π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms