Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting specific priority queue depth or rate #566

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions targets/simple_switch/simple_switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ SimpleSwitch::set_egress_queue_depth(int port, const size_t depth_pkts) {
return 0;
}

int
SimpleSwitch::set_egress_priority_queue_depth(int port, size_t priority, const size_t depth_pkts) {
egress_buffers.set_capacity(port, priority, depth_pkts);
return 0;
}

int
SimpleSwitch::set_all_egress_queue_depths(const size_t depth_pkts) {
for (int i = 0; i < max_port; i++) {
Expand All @@ -196,6 +202,12 @@ SimpleSwitch::set_egress_queue_rate(int port, const uint64_t rate_pps) {
return 0;
}

int
SimpleSwitch::set_egress_priority_queue_rate(int port, size_t priority, const uint64_t rate_pps) {
egress_buffers.set_rate(port, priority, rate_pps);
return 0;
}

int
SimpleSwitch::set_all_egress_queue_rates(const uint64_t rate_pps) {
for (int i = 0; i < max_port; i++) {
Expand Down
2 changes: 2 additions & 0 deletions targets/simple_switch/simple_switch.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ class SimpleSwitch : public Switch {
}

int set_egress_queue_depth(int port, const size_t depth_pkts);
int set_egress_priority_queue_depth(int port, size_t priority, const size_t depth_pkts);
int set_all_egress_queue_depths(const size_t depth_pkts);

int set_egress_queue_rate(int port, const uint64_t rate_pps);
int set_egress_priority_queue_rate(int port, size_t priority, const uint64_t rate_pps);
int set_all_egress_queue_rates(const uint64_t rate_pps);

// returns the number of microseconds elapsed since the switch started
Expand Down
58 changes: 43 additions & 15 deletions targets/simple_switch/sswitch_CLI.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,41 +37,69 @@ def __init__(self, pre_type, standard_client, mc_client, sswitch_client):
standard_client, mc_client)
self.sswitch_client = sswitch_client

@runtime_CLI.handle_bad_input
def do_set_queue_depth(self, line):
"Set depth of one / all egress queue(s): set_queue_depth <nb_pkts> [<egress_port>]"
"Set depth of one / all egress queue(s): set_queue_depth <nb_pkts> [<egress_port>] [<priority>]"
args = line.split()
depth = int(args[0])
if len(args) > 1:
port = int(args[1])
self.sswitch_client.set_egress_queue_depth(port, depth)
else:
self.sswitch_client.set_all_egress_queue_depths(depth)

self.at_least_n_args(args, 1)

try:
depth = int(args[0])
if len(args) > 2:
port = int(args[1])
priority = int(args[2])
self.sswitch_client.set_egress_priority_queue_depth(port, priority, depth)
elif len(args) > 1:
port = int(args[1])
self.sswitch_client.set_egress_queue_depth(port, rate)
else:
self.sswitch_client.set_all_egress_queue_depths(depth)

except ValueError:
print "Invalid depth, port or priority value"

@runtime_CLI.handle_bad_input
def do_set_queue_rate(self, line):
"Set rate of one / all egress queue(s): set_queue_rate <rate_pps> [<egress_port>]"
"Set rate of one / all egress queue(s): set_queue_rate <rate_pps> [<egress_port>] [<priority>]"
args = line.split()
rate = int(args[0])
if len(args) > 1:
port = int(args[1])
self.sswitch_client.set_egress_queue_rate(port, rate)
else:
self.sswitch_client.set_all_egress_queue_rates(rate)


self.at_least_n_args(args,1)

try:
rate = int(args[0])
if len(args) > 2:
port = int(args[1])
priority = int(args[2])
self.sswitch_client.set_egress_priority_queue_rate(port, priority, rate)
elif len(args) > 1:
port = int(args[1])
self.sswitch_client.set_egress_queue_rate(port, rate)
else:
self.sswitch_client.set_all_egress_queue_rates(rate)
except ValueError:
print "Invalid rate, port or priority value"

@runtime_CLI.handle_bad_input
def do_mirroring_add(self, line):
"Add mirroring mapping: mirroring_add <mirror_id> <egress_port>"
args = line.split()
self.at_least_n_args(args,2)
mirror_id, egress_port = int(args[0]), int(args[1])
self.sswitch_client.mirroring_mapping_add(mirror_id, egress_port)

@runtime_CLI.handle_bad_input
def do_mirroring_delete(self, line):
"Delete mirroring mapping: mirroring_delete <mirror_id>"
mirror_id = int(line)
self.sswitch_client.mirroring_mapping_delete(mirror_id)

@runtime_CLI.handle_bad_input
def do_get_time_elapsed(self, line):
"Get time elapsed (in microseconds) since the switch started: get_time_elapsed"
print self.sswitch_client.get_time_elapsed_us()

@runtime_CLI.handle_bad_input
def do_get_time_since_epoch(self, line):
"Get time elapsed (in microseconds) since the switch clock's epoch: get_time_since_epoch"
print self.sswitch_client.get_time_since_epoch_us()
Expand Down
2 changes: 2 additions & 0 deletions targets/simple_switch/thrift/simple_switch.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ service SimpleSwitch {
i32 mirroring_mapping_get_egress_port(1:i32 mirror_id);

i32 set_egress_queue_depth(1:i32 port_num, 2:i32 depth_pkts);
i32 set_egress_priority_queue_depth(1:i32 port_num, 2:i32 priority, 3:i32 depth_pkts);
i32 set_all_egress_queue_depths(1:i32 depth_pkts);
i32 set_egress_queue_rate(1:i32 port_num, 2:i64 rate_pps);
i32 set_egress_priority_queue_rate(1:i32 port_num, 2:i32 priority, 3:i64 rate_pps);
i32 set_all_egress_queue_rates(1:i64 rate_pps);

// these methods are here as an experiment, prefer get_time_elapsed_us() when
Expand Down
18 changes: 18 additions & 0 deletions targets/simple_switch/thrift/src/SimpleSwitch_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ class SimpleSwitchHandler : virtual public SimpleSwitchIf {
static_cast<uint32_t>(depth_pkts));
}

int32_t set_egress_priority_queue_depth(const int32_t port_num,
const int32_t priority,
const int32_t depth_pkts) {
bm::Logger::get()->trace("set_egress_priority_queue_depth");
return switch_->set_egress_priority_queue_depth(port_num,
priority,
static_cast<uint32_t>(depth_pkts));
}

int32_t set_all_egress_queue_depths(const int32_t depth_pkts) {
bm::Logger::get()->trace("set_all_egress_queue_depths");
return switch_->set_all_egress_queue_depths(
Expand All @@ -84,6 +93,15 @@ class SimpleSwitchHandler : virtual public SimpleSwitchIf {
static_cast<uint64_t>(rate_pps));
}

int32_t set_egress_priority_queue_rate(const int32_t port_num,
const int32_t priority,
const int64_t rate_pps) {
bm::Logger::get()->trace("set_egress_priority_queue_rate");
return switch_->set_egress_priority_queue_rate(port_num,
priority,
static_cast<uint64_t>(rate_pps));
}

int32_t set_all_egress_queue_rates(const int64_t rate_pps) {
bm::Logger::get()->trace("set_all_egress_queue_rates");
return switch_->set_all_egress_queue_rates(static_cast<uint64_t>(rate_pps));
Expand Down