can_skb_get_frame_len(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

can_skb_get_frame_len(9) β€” Kernel API Manual πŸŽ€

✨ NAME ✨

okay so bestie, <pink>can_skb_get_frame_len</pink> is the function that calculates the CAN Frame length in bytes of a given skb. that's the whole job. main character energy only ✨

🌸 SYNOPSIS 🌸

unsigned int can_skb_get_frame_len (const struct sk_buff *skb );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • skb β€” socket buffer of a CAN message. that's the input, bestie 🫢

πŸ’– DESCRIPTION πŸ’–

okay so here's the vibe: this does a rough calculation β€” bit stuffing is ignored, and the length in bits is rounded up to a length in bytes. no cap 🫢

πŸ’­ Rationale

the rationale is literally that this function is to be used for the BQL functions (netdev_sent_queue and netdev_completed_queue), which expect a value in bytes. just using skb->len is insufficient because it will return the constant value of CAN(FD)_MTU. doing the bit stuffing calculation would be too expensive in terms of computing resources for no noticeable gain. like, not worth it πŸ’€

🧠 Remarks

the payload of CAN FD frames with the BRS flag are sent at a different bitrate. currently, the can-utils canbusload tool does not support CAN-FD yet, and so we could not run any benchmark to measure the impact. there might be possible improvement here πŸ‘€

πŸ‘‘ RETURN πŸ‘‘

length in bytes. periodt πŸ’…

🌈 SEE ALSO 🌈

  • Kernel file ./drivers/net/can/dev/length.c β€” go peek, bestie πŸ¦‹

source/version: ./drivers/net/can/dev Β· date: October 2026 Β· page: can_skb_get_frame_len(9) β€” byeee bestie, stay iconic πŸ’…βœ¨

πŸ“¦ where this page comes from