iavf_txd_use_count(9)
π iavf_txd_use_count(9) π
okay so this is a page from the Kernel API Manual bestie, and it's literally about iavf_txd_use_count β the little math gremlin that estimates how many descriptors you need for Tx. no cap, it's more fun than it sounds π
β¨ NAME β¨
iavf_txd_use_count β estimate the number of descriptors needed for Tx π¦
πΈ SYNOPSIS πΈ
unsigned int iavf_txd_use_count (unsigned int size );
π ARGUMENTS π
sizeβ the transmit request size in bytes. that's it, that's the whole input, she's simple and she knows it π
π₯ DESCRIPTION π₯
okay so here's the tea β β because of hardware alignment restrictions (4K alignment, iconic), we have to assume we can't fit more than 12K of data per descriptor, even though each descriptor can actually take up to 16K - 1 bytes of aligned memory. rude, but fine.
so like, we need to divide by 12K. but division is slow! π and we don't do slow here. instead, we decompose the whole operation into shifts and one relatively cheap multiply operation. slay.
here's the breakdown, step by step, bestie:
- to divide by 12K, we first divide by 4K, then divide by 3
- to divide by 4K, shift right by 12 bits
- to divide by 3, multiply by 85, then divide by 256 (and dividing by 256 is done by shifting right by 8 bits)
- finally, we add one to round up β
because 256 isn't an exact multiple of 3, we'll underestimate near each multiple of 12K. and honestly? that's actually more accurate, because we have 4K - 1 of wiggle room that we can fit into the last segment π for our purposes this is accurate out to 1M, which is orders of magnitude greater than our largest possible GSO size. iykyk.
this would then be implemented as:
return (((size >> 12) * 85) >> 8) + 1;
and since multiplication and division are commutative (math girlies rise π), we can reorder operations into:
return ((size * 85) >> 20) + 1;
literally so clean. main character energy fr fr π
π«Ά SEE ALSO π«Ά
- Kernel file
./drivers/net/ethernet/intel/iavf/iavf_txrx.h iavf_xmit_descriptor_count(9)iavf_maybe_stop_tx(9)iavf_chk_linearize(9)txring_txq(9)
go read the friends, they're all in the same friend group π
and that's the whole page, bestie!! π this lil gem lives in ./drivers/net/ethernet/intel/iavf and the version is from October 2026 β go off, future manpage πβ¨πΈ
π¦ 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