ionic_bitid_to_qid(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… ionic_bitid_to_qid β€” Kernel API Manual, bestie edition πŸŽ€

okay so literally welcome to the Kernel API Manual entry for ionic_bitid_to_qid(9) β€” yes the (9) is part of the name, it's giving very section-nine of her ✨


🌸 NAME 🌸

ionic_bitid_to_qid β€” transform a resource bit index into a queue id. that's it. that's the whole vibe check πŸ¦‹


✨ SYNOPSIS ✨

u32 ionic_bitid_to_qid (u32 bitid , u8 qgrp_shift , u8 half_qid_shift );

three args, one u32 coming back out, no cap πŸ”₯


πŸŽ€ ARGUMENTS πŸŽ€

  • bitid β€” the bit index, aka the thing we're transforming πŸ’–
  • qgrp_shift β€” the Log2 number of queues per queue group (yes, Log2, capital L, she's fancy)
  • half_qid_shift β€” the Log2 of half the total number of queues. half!! not the whole thing!! read the label bestie πŸ™ˆ

⭐ RETURN ⭐

the queue id. that's the whole return value, she's simple like that 🫢


πŸ‘‘ DESCRIPTION πŸ‘‘

so here's the lore. Udma-constrained queues (that's QPs and CQs, both of them, don't forget) are associated with their udma by queue group. even queue groups go with udma0, odd queue groups go with udma1. periodt. 🌈

for allocating queue ids, we want to arrange the bits into two halves β€” even queue groups of udma0 in the lower half of the bitset, and odd queue groups of udma1 in the upper half of the bitset. why? because then one or two calls of find_next_zero_bit can examine all the bits for queues of an entire udma in one go. iconic efficiency behavior honestly πŸ’…

for example, assuming eight queue groups with qgrp qids per group:

bitid 0*qgrp..1*qgrp-1 : qid 0*qgrp..1*qgrp-1
bitid 1*qgrp..2*qgrp-1 : qid 2*qgrp..3*qgrp-1
bitid 2*qgrp..3*qgrp-1 : qid 4*qgrp..5*qgrp-1
bitid 3*qgrp..4*qgrp-1 : qid 6*qgrp..7*qgrp-1
bitid 4*qgrp..5*qgrp-1 : qid 1*qgrp..2*qgrp-1
bitid 5*qgrp..6*qgrp-1 : qid 3*qgrp..4*qgrp-1
bitid 6*qgrp..7*qgrp-1 : qid 5*qgrp..6*qgrp-1
bitid 7*qgrp..8*qgrp-1 : qid 7*qgrp..8*qgrp-1

see how the second half of the bitids maps back down into the first half of the qids? that's the whole point bestie, the rearrangement is the moment 🧚

there are three important ranges of bits in the qid, and you will learn them:

  • the udma bit "U" sits at qgrp_shift. it's the least significant bit of the group index, and it determines which udma a queue is associated with. main character bit, honestly πŸ‘‘
  • the bits of lesser significance? we call those the idx bits "I" β€” the index of the queue within the group πŸ“
  • the bits of greater significance? those are the grp bits "G" β€” other bits of the group index that do not determine the udma. those bits are just rearranged in the bit index in the bitset, no drama πŸ’œ

a bitid has the udma bit in the most significant place, then the grp bits, then the idx bits. look at her go:

bitid: 00000000000000 U GGG IIIIII
qid:   00000000000000 GGG U IIIIII

notice how U migrated from the front-ish to the middle? she moved. she's thriving. ✨

transforming from bit index to qid β€” or from qid to bit index β€” can be accomplished by rearranging the bits by masking and shifting. that's it. masking and shifting. no magic, just bits πŸ˜­πŸ’–


πŸ”₯ SEE ALSO πŸ”₯


lowkey everything above is in the Kernel API Manual, and the whole thing lives in ./drivers/infiniband/hw/ionic, dated October 2026, filed under ionic_bitid_to_qid(9). that's the sign-off, mwah πŸ’‹πŸ¦‹πŸŒΈ
πŸ“¦ where this page comes from