STRUCT FWCTL_OPS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct fwctl_ops(9) β€” bestie's guide to the Kernel API Manual

okay so picture this: it's a whole struct of driver-provided operations, and honestly? it's giving "the plug for your firmware" fr fr. Let's get into it πŸ’–


✨ NAME ✨

struct fwctl_ops β€” the operations that the driver provides. that's it, that's the vibe πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

struct fwctl_ops {
    enum fwctl_device_type device_type;
    size_t uctx_size;
    int (*open_uctx)(struct fwctl_uctx *uctx);
    void (*close_uctx)(struct fwctl_uctx *uctx);
    void *(*info)(struct fwctl_uctx *uctx, size_t *length);
    void *(*fw_rpc)(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope,
void *rpc_in, size_t in_len, size_t *out_len);
 };

like, copy it exactly bestie, don't be out here "fixing" the indentation on that last line, it is what it is πŸ’€


🌸 Members 🌸 (the cast, the main characters)

  • device_type β€” the device_type number that the driver got assigned. this one is uABI, no cap, so treat it with respect πŸ‘‘
  • uctx_size β€” the size of the fwctl_uctx struct that's gonna get allocated. the first bytes of this memory will be a fwctl_uctx, and the driver can use the leftover bytes as its own private little memory stash πŸ“
  • open_uctx β€” gets called when a file descriptor is opened, and it happens before the uctx is ever used. early bird energy ⭐
  • close_uctx β€” gets called when the uctx is destroyed, which is usually when the FD is closed. it's the goodbye hug 🫢
  • info β€” implements FWCTL_INFO. return kmalloc memory, and that gets copied to out_device_data. on input, length indicates the size of the user buffer; on output it indicates the size of the memory. bestie, the driver can literally ignore length on input β€” the core code handles everything for you, iconic πŸ’…
  • fw_rpc β€” implements FWCTL_RPC. deliver rpc_in/in_len to the FW, then return the response and set out_len. rpc_in can be returned as the response pointer; otherwise the returned pointer gets freed with kvfree. so like, know which one you're doing 😭

πŸ”₯ Description πŸ”₯

fwctl_unregister will wait until all executing ops are completed before it returns. so drivers, please be mindful and don't let your ops run for too long β€” because that will block device hot unplug and module unloading. not the vibe, don't do it πŸ™ˆ

lowkey important: long-running ops = no hot unplug, no module unload. keep it snappy bestie πŸ’€

🌈 SEE ALSO 🌈

  • Kernel file ./include/linux/fwctl.h, struct fwctl_device(9), fwctl_alloc_device(9), struct fwctl_uctx(9) πŸ‘‘

✨ and that's the whole page! this lil icon came from ./include/linux, dated October 2026, and it's filed under struct fwctl_ops(9) β€” periodt, go read the source, mwah πŸ’œ

πŸ“¦ where this page comes from