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

Support 64-bit bandwidths #395

Merged
merged 14 commits into from
Oct 1, 2024
Merged
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
3 changes: 2 additions & 1 deletion elements/ip/iprewriterbase.hh
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,8 @@ template<class T> inline IPRewriterEntry *
IPRewriterBase::search_migrate_entry(const IPFlowID &flowid, per_thread<T> &vstate)
{
//If the flow does not exist, it may be in other thread's stack if there was a migration
if (vstate->rebalance > 0 && click_jiffies() - vstate->rebalance < THREAD_MIGRATION_TIMEOUT * CLICK_HZ ) {
if (vstate->rebalance > 0 &&
click_jiffies() - vstate->rebalance < THREAD_MIGRATION_TIMEOUT * CLICK_HZ / 1000) {
//Search in other thread's stacks for the flow
for (int i = 0; i < vstate.weight(); i++) {
if (vstate.get_mapping(i) == click_current_cpu_id())
Expand Down
8 changes: 4 additions & 4 deletions elements/standard/bandwidthmeter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ BandwidthMeter::configure(Vector<String> &conf, ErrorHandler *errh)
if (conf.size() == 0)
return errh->error("too few arguments to BandwidthMeter(bandwidth, ...)");

Vector<unsigned> vals(conf.size(), 0);
Vector<uint64_t> vals(conf.size(), 0);
BandwidthArg ba;
for (int i = 0; i < conf.size(); i++)
if (!ba.parse(conf[i], vals[i]))
Expand All @@ -63,8 +63,8 @@ BandwidthMeter::configure(Vector<String> &conf, ErrorHandler *errh)
_meter1 = vals[0];
_nmeters = 1;
} else {
_meters = new unsigned[vals.size()];
memcpy(_meters, &vals[0], vals.size() * sizeof(int));
_meters = new uint64_t[vals.size()];
memcpy(_meters, &vals[0], vals.size() * sizeof(uint64_t));
_nmeters = vals.size();
}

Expand All @@ -83,7 +83,7 @@ BandwidthMeter::push(int, Packet *p)
int n = (r >= _meter1);
output(n).push(p);
} else {
unsigned *meters = _meters;
uint64_t *meters = _meters;
int nmeters = _nmeters;
for (int i = 0; i < nmeters; i++)
if (r < meters[i]) {
Expand Down
4 changes: 2 additions & 2 deletions elements/standard/bandwidthmeter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class BandwidthMeter : public Element { protected:

RateEWMA _rate;

unsigned _meter1;
unsigned *_meters;
uint64_t _meter1;
uint64_t *_meters;
int _nmeters;

static String meters_read_handler(Element *, void *) CLICK_COLD;
Expand Down
2 changes: 1 addition & 1 deletion elements/standard/bwratedunqueue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ BandwidthRatedUnqueue::run_task(Task *)
}
}
} else {
_timer.schedule_after(Timestamp::make_jiffies(_tb.time_until_contains(tb_bandwidth_thresh)));
_timer.schedule_after(Timestamp::make_usec(_tb.time_until_contains(tb_bandwidth_thresh)));
_empty_runs++;
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion elements/standard/linkunqueue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ LinkUnqueue::write_handler(const String &s, Element *e, void *thunk, ErrorHandle
break;
}
case H_BANDWIDTH: {
uint32_t bw;
uint64_t bw;
if (!cp_bandwidth(s, &bw)) {
return errh->error("invalid bandwidth");
} else if (bw < 100) {
Expand Down
2 changes: 1 addition & 1 deletion elements/standard/linkunqueue.hh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class LinkUnqueue : public Element, public Storage { public:
Timestamp _latency;
// enum { S_TASK, S_TIMER, S_ASLEEP } _state;
bool _back_to_back;
uint32_t _bandwidth;
uint64_t _bandwidth;
Task _task;
Timer _timer;
NotifierSignal _signal;
Expand Down
4 changes: 2 additions & 2 deletions elements/standard/meter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ Meter::push(int, Packet *p)
{
_rate.update(1); // packets, not bytes

unsigned r = _rate.scaled_average();
uint64_t r = _rate.scaled_average();
if (_nmeters < 2) {
int n = (r >= _meter1);
output(n).push(p);
} else {
unsigned *meters = _meters;
uint64_t *meters = _meters;
int nmeters = _nmeters;
for (int i = 0; i < nmeters; i++)
if (r < meters[i]) {
Expand Down
10 changes: 5 additions & 5 deletions elements/standard/ratedsource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ RatedSource::configure(Vector<String> &conf, ErrorHandler *errh)

String data =
"Random bullshit in a packet, at least 64 bytes long. Well, now it is.";
unsigned rate = 10;
unsigned bandwidth = 0;
uint64_t rate = 10;
uint64_t bandwidth = 0;
int limit = -1;
int datasize = -1;
bool active = true, stop = false;
Expand Down Expand Up @@ -179,7 +179,7 @@ RatedSource::run_task(Task *)

count++;
} else {
_timer.schedule_after(Timestamp::make_jiffies(_tb.time_until_contains(_batch_size)));
_timer.schedule_after(Timestamp::make_usec(_tb.time_until_contains(_batch_size)));
return false;
}
}
Expand All @@ -194,7 +194,7 @@ RatedSource::run_task(Task *)
} else {
if (_end_h && _limit >= 0 && _count >= (ucounter_t) _limit)
(void) _end_h->call_write();
_timer.schedule_after(Timestamp::make_jiffies(_tb.time_until_contains(1)));
_timer.schedule_after(Timestamp::make_usec(_tb.time_until_contains(1)));

return false;
}
Expand All @@ -209,7 +209,7 @@ RatedSource::run_task(Task *)
} else {
if (_end_h && _limit >= 0 && _count >= (ucounter_t) _limit)
(void) _end_h->call_write();
_timer.schedule_after(Timestamp::make_jiffies(_tb.time_until_contains(1)));
_timer.schedule_after(Timestamp::make_usec(_tb.time_until_contains(1)));

return false;
}
Expand Down
6 changes: 3 additions & 3 deletions elements/standard/ratedunqueue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ RatedUnqueue::configure(Vector<String> &conf, ErrorHandler *errh)
int
RatedUnqueue::configure_helper(TokenBucket *tb, bool is_bandwidth, Element *elt, Vector<String> &conf, ErrorHandler *errh)
{
unsigned r;
uint64_t r;
unsigned dur_msec = 20;
unsigned tokens;
uint64_t tokens;
bool dur_specified, tokens_specified;
const char *burst_size = is_bandwidth ? "BURST_BYTES" : "BURST_SIZE";

Expand Down Expand Up @@ -133,7 +133,7 @@ RatedUnqueue::run_task(Task *)
}
#endif
} else {
_timer.schedule_after(Timestamp::make_jiffies(_tb.time_until_contains(1)));
_timer.schedule_after(Timestamp::make_usec(_tb.time_until_contains(1)));
_empty_runs++;
return false;
}
Expand Down
10 changes: 5 additions & 5 deletions elements/standard/ratedunqueue.hh
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ class RatedUnqueue : public BatchElement { public:
Task _task;
Timer _timer;
NotifierSignal _signal;
uint32_t _runs;
uint32_t _packets;
uint32_t _pushes;
uint32_t _failed_pulls;
uint32_t _empty_runs;
uint64_t _runs;
uint64_t _packets;
uint64_t _pushes;
uint64_t _failed_pulls;
uint64_t _empty_runs;
uint32_t _burst;

enum { h_calls, h_rate };
Expand Down
2 changes: 1 addition & 1 deletion elements/standard/shaper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Shaper::Shaper()
int
Shaper::configure(Vector<String> &conf, ErrorHandler *errh)
{
uint32_t rate;
uint64_t rate;
Args args(conf, this, errh);
if (is_bandwidth())
args.read_mp("RATE", BandwidthArg(), rate);
Expand Down
Loading
Loading