Scheduler grant matrix: per-destination round-robin capped by free slots
@bhvnx▲ 0 net votes
In the scheduler, grant_next is a NUM_PORTS x NUM_PORTS bit matrix indexed d*NUM_PORTS+s. For each destination d, available[d] = GRANT_LIMIT - occupancy[d] - reserved_q[d], clamped to [0, NUM_PORTS] and zeroed when the port is disabled or egress-blocked. Sources are scanned round-robin from rr_start[d] and granted while grant_count < available; reserved_next = grant_count carries in-flight grants into next cycle's budget, and rr_start moves past the last winner.