Skip to content

Commit

Permalink
set rx rate to unlimited for knet
Browse files Browse the repository at this point in the history
Since KNET uses a different channel for packets than OpenFlow and is
much more efficient, higher packet rates than 1024 (the default) is
easily doable.

So set the rx rate to unlimited by default when using KNET, but leave it
at 1024 pps for TAP.

In case this causes issue, add a flag to set a custom limit.

Signed-off-by: Jonas Gorski <[email protected]>
  • Loading branch information
KanjiMonster committed Aug 23, 2024
1 parent 70d828c commit 4da7814
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/systemd/sysconfig.template
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
#
# Vlan ID used for untagged traffic on unbridged ports (1-4095):
# FLAGS_port_untagged_vid=1
#
# Set a Packets per Seconds rate limit for traffic to controller.
# -1 = auto (unlimited for KNET, 1024 for TAP)
# 0 = force unlimited
# Default is auto.
# FLAGS_rx_rate_limit=-1

### glog logging configuration
#
Expand Down
2 changes: 2 additions & 0 deletions src/baseboxd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ DEFINE_bool(clear_switch_configuration, true,
"Clear switch configuration on connect");
DEFINE_int32(port_untagged_vid, 1,
"VLAN ID used for untagged traffic on unbridged ports");
DEFINE_int32(rx_rate_limit, -1,
"PPS limit for traffic to controller (-1 = auto, 0 = force unlimited)"

static bool validate_port(const char *flagname, gflags::int32 value) {
VLOG(3) << __FUNCTION__ << ": flagname=" << flagname << ", value=" << value;
Expand Down
16 changes: 16 additions & 0 deletions src/of-dpa/controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "utils/rofl-utils.h"

DECLARE_bool(clear_switch_configuration);
DECLARE_bool(use_knet);
DECLARE_int32(rx_rate_limit);

namespace basebox {

Expand Down Expand Up @@ -100,6 +102,20 @@ void controller::handle_dpt_open(rofl::crofdpt &dpt) {
ofdpa->ofdpaStgReset();
}

int rate = FLAGS_rx_rate_limit;
if (rate < 0) {
if (FLAGS_use_knet)
// Packets use a different channel, so set unlimited.
rate = 0;
else
// TAP packets use the same channel as control traffic, so set the
// default limit of 1024 pps (about ~11 Mbit/s) to ensure the OpenFlow
// connection is stable.
rate = 1024;
}

ofdpa->ofdpaRxRateSet(rate);

dpt.send_features_request(rofl::cauxid(0), 1);
dpt.send_desc_stats_request(rofl::cauxid(0), 0, 1);

Expand Down
18 changes: 18 additions & 0 deletions src/of-dpa/ofdpa_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -513,4 +513,22 @@ ofdpa_client::ofdpaTrunkPortPSCSet(uint32_t lag_id, uint8_t mode) {
return response.status();
}

ofdpa::OfdpaStatus::OfdpaStatusCode
ofdpa_client::ofdpaRxRateSet(int32_t pps) {
::OfdpaStatus response;
::ClientContext context;
::Pps request;

context.set_wait_for_ready(true);

request.set_pps(pps);

::Status rv = stub_->ofdpaRxRateSet(&context, request, &response);
if (not rv.ok()) {
return ofdpa::OfdpaStatus::OFDPA_E_RPC;
}

return response.status();
}

} // namespace basebox
1 change: 1 addition & 0 deletions src/of-dpa/ofdpa_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class ofdpa_client {

ofdpa::OfdpaStatus::OfdpaStatusCode ofdpaTrunkPortPSCSet(uint32_t lag_id,
uint8_t mode);
ofdpa::OfdpaStatus::OfdpaStatusCode ofdpaRxRateSet(int32_t pps);

private:
ofdpa::OfdpaStatus::OfdpaStatusCode
Expand Down

0 comments on commit 4da7814

Please sign in to comment.