Skip to content

Commit

Permalink
QoS: Use params to profile map, carry pointer
Browse files Browse the repository at this point in the history
DPDK split the meter and profile config objects because in practice they
found a small number of latter. So instead of repeating it for every
entry we now only carry a pointer to the profile. The profile itself is
stored in params to profile map. Whenever we get a commandAdd, we lookup
if a profile was created using the same params. If found we use copy
it's address, else we insert and do the same.

Signed-off-by: Saikrishna Edupuganti <saikrishna.edupuganti@intel.com>
  • Loading branch information
krsna1729 committed Oct 16, 2021
1 parent a4c81d6 commit d2c0793
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 7 deletions.
29 changes: 23 additions & 6 deletions core/modules/qos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void Qos::ProcessBatch(Context *ctx, bess::PacketBatch *batch) {
if (ogate == METER_GATE) {
uint64_t time = rte_rdtsc();
uint32_t pkt_len = pkt->total_len() - val[j]->deduct_len;
uint8_t color = rte_meter_trtcm_color_blind_check(&val[j]->m, &val[j]->p,
uint8_t color = rte_meter_trtcm_color_blind_check(&val[j]->m, val[j]->p,
time, pkt_len);

DLOG(INFO) << "color : " << color << std::endl;
Expand Down Expand Up @@ -403,12 +403,28 @@ CommandResponse Qos::CommandAdd(const bess::pb::QosCommandAddArg &arg) {
struct rte_meter_trtcm_params app_trtcm_params = {
.cir = cir, .pir = pir, .cbs = cbs, .pbs = pbs};

int ret = rte_meter_trtcm_profile_config(&v.p, &app_trtcm_params);
if (ret)
return CommandFailure(
ret, "Insert Failed - rte_meter_trtcm_profile_config failed");
auto *result = params_map_.Find(app_trtcm_params);

ret = rte_meter_trtcm_config(&v.m, &v.p);
if (result == nullptr) {
struct rte_meter_trtcm_profile p;

int ret = rte_meter_trtcm_profile_config(&p, &app_trtcm_params);
if (ret)
return CommandFailure(
ret,
"Insert Failed - rte_meter_trtcm_profile_config creation failed");

result = params_map_.Insert(app_trtcm_params, p);
if (result == nullptr) {
return CommandFailure(
ret,
"Insert Failed - rte_meter_trtcm_profile_config map insert failed");
}
}

v.p = &result->second;

int ret = rte_meter_trtcm_config(&v.m, v.p);
if (ret) {
return CommandFailure(ret,
"Insert Failed - rte_meter_trtcm_config failed");
Expand All @@ -434,6 +450,7 @@ CommandResponse Qos::CommandClear(__attribute__((unused))

void Qos::Clear() {
table_.Clear();
params_map_.Clear();
}

void Qos::DeInit() {
Expand Down
21 changes: 20 additions & 1 deletion core/modules/qos.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
#include <rte_hash_crc.h>

#include "../pb/module_msg.pb.h"
#include "../utils/cuckoo_map.h"
#include "../utils/metering.h"

using bess::utils::CuckooMap;
using bess::utils::Metering;
using bess::utils::MeteringKey;

Expand All @@ -63,7 +65,7 @@ enum { FieldType = 0, ValueType };
struct value {
gate_idx_t ogate;
int64_t deduct_len;
struct rte_meter_trtcm_profile p;
struct rte_meter_trtcm_profile *p;
struct rte_meter_trtcm m;
MeteringKey Data;
} __attribute__((packed));
Expand All @@ -79,6 +81,21 @@ class Qos final : public Module {

static const Commands cmds;

struct Hash {
bess::utils::HashResult operator()(
const rte_meter_trtcm_params &key) const {
return rte_hash_crc(&key, sizeof(rte_meter_trtcm_params), 0);
}
};

struct EqualTo {
bool operator()(const rte_meter_trtcm_params &p1,
const rte_meter_trtcm_params &p2) const {
return (p1.cir == p2.cir) && (p1.pir == p2.pir) && (p1.cbs == p2.cbs) &&
(p1.pbs == p2.pbs);
}
};

Qos() : Module(), default_gate_(), total_key_size_(), fields_() {
max_allowed_workers_ = Worker::kMaxWorkers;
size_t len = sizeof(mask) / sizeof(uint64_t);
Expand Down Expand Up @@ -114,6 +131,8 @@ class Qos final : public Module {
std::vector<struct MeteringField> values_;
Metering<value> table_;
uint64_t mask[MAX_FIELDS];
CuckooMap<rte_meter_trtcm_params, rte_meter_trtcm_profile, Hash, EqualTo>
params_map_;
};

#endif // BESS_MODULES_QOS_H

0 comments on commit d2c0793

Please sign in to comment.