}
/* Rate limiting. */
- if (s->rate_limit) {
- if (s->rate_limit < 100) {
- VLOG_WARN("Rate limit set to unusually low value %d",
- s->rate_limit);
- }
- if (!s->burst_limit) {
- s->burst_limit = s->rate_limit / 4;
- }
- s->burst_limit = MAX(s->burst_limit, 1);
- s->burst_limit = MIN(s->burst_limit, INT_MAX / 1000);
+ if (s->rate_limit && s->rate_limit < 100) {
+ VLOG_WARN("Rate limit set to unusually low value %d", s->rate_limit);
}
}
ofproto_set_rate_limit(struct ofproto *ofproto,
int rate_limit, int burst_limit)
{
- if (rate_limit) {
+ if (rate_limit > 0) {
if (!ofproto->miss_sched) {
ofproto->miss_sched = pinsched_create(rate_limit, burst_limit,
ofproto->switch_status);
struct pinsched *ps;
ps = xcalloc(1, sizeof *ps);
- ps->rate_limit = rate_limit;
- ps->burst_limit = burst_limit;
port_array_init(&ps->queues);
ps->n_queued = 0;
ps->last_tx_port = PORT_ARRAY_SIZE;
ps->n_normal = 0;
ps->n_limited = 0;
ps->n_queue_dropped = 0;
+ pinsched_set_limits(ps, rate_limit, burst_limit);
if (ss) {
ps->ss_cat = switch_status_register(ss, "rate-limit",
void
pinsched_set_limits(struct pinsched *ps, int rate_limit, int burst_limit)
{
+ if (rate_limit <= 0) {
+ rate_limit = 1000;
+ }
+ if (burst_limit <= 0) {
+ burst_limit = rate_limit / 4;
+ }
+ burst_limit = MAX(burst_limit, 1);
+ burst_limit = MIN(burst_limit, INT_MAX / 1000);
+
ps->rate_limit = rate_limit;
ps->burst_limit = burst_limit;
while (ps->n_queued > burst_limit) {