Skip to content

Queue schedulers: input and output fields instead of one rank - #126

Merged
Mingyumaz merged 1 commit into
mainfrom
feat/pifo-tree
Dec 1, 2026
Merged

Mingyumaz merged 1 commit into
mainfrom
feat/pifo-tree

Conversation

@Mingyumaz

Copy link
Copy Markdown
Contributor

Motivation

Phase 3 adds PIFO trees (hierarchical scheduling, Sivaraman et al., SIGCOMM 2016). A tree needs more from the switch than #123's interface gives: per packet a leaf and one rank per level, and before the egress the rank that each level actually popped (a reference popped at an upper level can carry another packet's rank, so per-node virtual time in the P4 program needs it). This PR generalises the interface first, without changing behaviour; the tree scheduler comes in the next PR.

What changes

  • P4QueueScheduler::GetInputFields(): the user-metadata fields that the switch reads when a packet enters the queues, into P4QueueMetadata::fields. Replaces GetRankFieldName() and P4QueueMetadata::rank.
  • P4QueueScheduler::GetOutputFields(): fields that the switch writes before the egress, with the values that Dequeue() returns in P4DequeueInfo::fields.
  • Dequeue(port, &packet, &info): one P4DequeueInfo (qid, deq_qdepth, output values) instead of two out-parameters.
  • At most 8 fields each; each names the attribute it came from, so a missing field says "no metadata field "x" for RankField". A field without a name is skipped.
  • P4CoreV1model: FindRankField → FindMetadataField (attribute in the messages), GetRankField → GetSchedulerInputFields / GetSchedulerOutputFields; fields are looked up at start and after a program swap, as before.
  • P4PifoScheduler names RankField as its one input; strict priority names none.
  • New test case with a test scheduler (3 inputs, 3 outputs, one 64-bit, one unnamed each) and test/p4src/pifo/fields_v1model.p4.

Scope

  • In: the interface, the core's reading and writing of the fields, the test, a paragraph in switch.md.
  • Out: the PIFO tree scheduler, its example and docs (next PR); doc/TODO.md (changed by Add rank examples LAS and EDF, with SP-PIFO and AIFO next to the PIFO (re-land of #124) #125, updated with the tree).
  • Tested (ns-3.39 and ns-3.49, Docker):
    • run-tests.sh passes: 24 suites, 254 cases (one new), 44 example runs; build without warnings.
    • All 44 example runs give the same exit codes, files and output as main; only the lines with wall-clock times differ.
    • 9 mutants (output fields not written or from the wrong index, input fields shifted, a reused P4DequeueInfo, no lookup after a swap, the attribute missing from the message, the PIFO's rank index, deq_qdepth of either scheduler) are all caught by p4-queue-scheduler.
    • clang-format clean; the test program's JSON is compiled with p4c 1.2.5.19 (the CI image).
  • Not tested: a scheduler that names more than 8 fields (the switch stops with a message; not unit-testable).

Two reviews are needed before merging.

🤖 Generated with Claude Code

A PIFO tree needs more than one rank per packet (a leaf and a rank per
level), and the egress must learn the rank that each level popped. So a
P4QueueScheduler now names lists of user-metadata fields:

- GetInputFields(): the switch reads them when a packet enters the
  queues, into P4QueueMetadata::fields (replaces GetRankFieldName() and
  P4QueueMetadata::rank).
- GetOutputFields(): the switch writes them before the egress, with the
  values of P4DequeueInfo::fields that Dequeue() returns. Dequeue() now
  fills a P4DequeueInfo (qid, deq_qdepth, fields) instead of two
  out-parameters.
- At most 8 of each. Each field names the attribute it came from, for the
  messages. A field without a name is skipped (an input then reads 0).

P4CoreV1model looks them up at start and after a program swap
(ResolveSchedulerFields; FindRankField becomes FindMetadataField with the
attribute in its messages; GetRankField becomes GetSchedulerInputFields
and GetSchedulerOutputFields). P4PifoScheduler names RankField as its one
input field; strict priority names none. No behaviour changes.

Test: a scheduler with three input and three output fields (one 64 bits
wide, one without a name each) and program test/p4src/pifo/fields: the
values reach the scheduler and the egress.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Mingyumaz
Mingyumaz merged commit 6bf8e7e into main Dec 1, 2026
2 checks passed
@Mingyumaz
Mingyumaz deleted the feat/pifo-tree branch December 1, 2026 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant