Skip to content

Commit

Permalink
Set enqueue and dequeue qdepth to the size of the priority queue (#1270)
Browse files Browse the repository at this point in the history
Fixes #1258

Signed-off-by: Rizky Ramadhana <[email protected]>
  • Loading branch information
rizkyramadhana26 authored Oct 24, 2024
1 parent 199af48 commit 2db81fb
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions targets/simple_switch/simple_switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,18 +406,19 @@ SimpleSwitch::enqueue(port_t egress_port, std::unique_ptr<Packet> &&packet) {

PHV *phv = packet->get_phv();

if (with_queueing_metadata) {
phv->get_field("queueing_metadata.enq_timestamp").set(get_ts().count());
phv->get_field("queueing_metadata.enq_qdepth")
.set(egress_buffers.size(egress_port));
}

size_t priority = phv->has_field(SSWITCH_PRIORITY_QUEUEING_SRC) ?
phv->get_field(SSWITCH_PRIORITY_QUEUEING_SRC).get<size_t>() : 0u;
if (priority >= nb_queues_per_port) {
bm::Logger::get()->error("Priority out of range, dropping packet");
return;
}

if (with_queueing_metadata) {
phv->get_field("queueing_metadata.enq_timestamp").set(get_ts().count());
phv->get_field("queueing_metadata.enq_qdepth")
.set(egress_buffers.size(egress_port, priority));
}

egress_buffers.push_front(
egress_port, nb_queues_per_port - 1 - priority,
std::move(packet));
Expand Down Expand Up @@ -667,7 +668,7 @@ SimpleSwitch::egress_thread(size_t worker_id) {
phv->get_field("queueing_metadata.deq_timedelta").set(
get_ts().count() - enq_timestamp);
phv->get_field("queueing_metadata.deq_qdepth").set(
egress_buffers.size(port));
egress_buffers.size(port, priority));
if (phv->has_field("queueing_metadata.qid")) {
auto &qid_f = phv->get_field("queueing_metadata.qid");
qid_f.set(nb_queues_per_port - 1 - priority);
Expand Down

0 comments on commit 2db81fb

Please sign in to comment.