projects
/
cascardo
/
ovs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ofp-util: Define struct ofputil_async_cfg to hold async message config.
[cascardo/ovs.git]
/
ofproto
/
pinsched.c
diff --git
a/ofproto/pinsched.c
b/ofproto/pinsched.c
index
57e8e23
..
c7118a6
100644
(file)
--- a/
ofproto/pinsched.c
+++ b/
ofproto/pinsched.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012
, 2013, 2014, 2016
Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-21,6
+21,7
@@
#include <arpa/inet.h>
#include <stdint.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <stdint.h>
#include <stdlib.h>
+#include "flow.h"
#include "hash.h"
#include "hmap.h"
#include "ofpbuf.h"
#include "hash.h"
#include "hmap.h"
#include "ofpbuf.h"
@@
-30,13
+31,13
@@
#include "rconn.h"
#include "sat-math.h"
#include "timeval.h"
#include "rconn.h"
#include "sat-math.h"
#include "timeval.h"
-#include "token-bucket.h"
-#include "vconn.h"
+#include "
openvswitch/
token-bucket.h"
+#include "
openvswitch/
vconn.h"
struct pinqueue {
struct hmap_node node; /* In struct pinsched's 'queues' hmap. */
struct pinqueue {
struct hmap_node node; /* In struct pinsched's 'queues' hmap. */
-
uint16_t port_no;
/* Port number. */
- struct
list packets;
/* Contains "struct ofpbuf"s. */
+
ofp_port_t port_no;
/* Port number. */
+ struct
ovs_list packets;
/* Contains "struct ofpbuf"s. */
int n; /* Number of packets in 'packets'. */
};
int n; /* Number of packets in 'packets'. */
};
@@
-45,12
+46,9
@@
struct pinsched {
/* One queue per physical port. */
struct hmap queues; /* Contains "struct pinqueue"s. */
/* One queue per physical port. */
struct hmap queues; /* Contains "struct pinqueue"s. */
-
int n_queued;
/* Sum over queues[*].n. */
+
unsigned int n_queued;
/* Sum over queues[*].n. */
struct pinqueue *next_txq; /* Next pinqueue check in round-robin. */
struct pinqueue *next_txq; /* Next pinqueue check in round-robin. */
- /* Transmission queue. */
- int n_txq; /* No. of packets waiting in rconn for tx. */
-
/* Statistics reporting. */
unsigned long long n_normal; /* # txed w/o rate limit queuing. */
unsigned long long n_limited; /* # queued for rate limiting. */
/* Statistics reporting. */
unsigned long long n_normal; /* # txed w/o rate limit queuing. */
unsigned long long n_limited; /* # queued for rate limiting. */
@@
-101,9
+99,9
@@
pinqueue_destroy(struct pinsched *ps, struct pinqueue *q)
}
static struct pinqueue *
}
static struct pinqueue *
-pinqueue_get(struct pinsched *ps,
uint16
_t port_no)
+pinqueue_get(struct pinsched *ps,
ofp_port
_t port_no)
{
{
- uint32_t hash = hash_
int(port_no, 0
);
+ uint32_t hash = hash_
ofp_port(port_no
);
struct pinqueue *q;
HMAP_FOR_EACH_IN_BUCKET (q, node, hash, &ps->queues) {
struct pinqueue *q;
HMAP_FOR_EACH_IN_BUCKET (q, node, hash, &ps->queues) {
@@
-184,30
+182,24
@@
get_token(struct pinsched *ps)
}
void
}
void
-pinsched_send(struct pinsched *ps,
uint16
_t port_no,
- struct ofpbuf *packet,
pinsched_tx_cb *cb, void *aux
)
+pinsched_send(struct pinsched *ps,
ofp_port
_t port_no,
+ struct ofpbuf *packet,
struct ovs_list *txq
)
{
{
+ list_init(txq);
if (!ps) {
if (!ps) {
-
cb(packet, aux
);
+
list_push_back(txq, &packet->list_node
);
} else if (!ps->n_queued && get_token(ps)) {
/* In the common case where we are not constrained by the rate limit,
* let the packet take the normal path. */
ps->n_normal++;
} else if (!ps->n_queued && get_token(ps)) {
/* In the common case where we are not constrained by the rate limit,
* let the packet take the normal path. */
ps->n_normal++;
-
cb(packet, aux
);
+
list_push_back(txq, &packet->list_node
);
} else {
/* Otherwise queue it up for the periodic callback to drain out. */
} else {
/* Otherwise queue it up for the periodic callback to drain out. */
- struct pinqueue *q;
-
- /* We might be called with a buffer obtained from dpif_recv() that has
- * much more allocated space than actual content most of the time.
- * Since we're going to store the packet for some time, free up that
- * otherwise wasted space. */
- ofpbuf_trim(packet);
-
if (ps->n_queued * 1000 >= ps->token_bucket.burst) {
drop_packet(ps);
}
if (ps->n_queued * 1000 >= ps->token_bucket.burst) {
drop_packet(ps);
}
- q = pinqueue_get(ps, port_no);
+
+ struct pinqueue *q = pinqueue_get(ps, port_no);
list_push_back(&q->packets, &packet->list_node);
q->n++;
ps->n_queued++;
list_push_back(&q->packets, &packet->list_node);
q->n++;
ps->n_queued++;
@@
-216,15
+208,17
@@
pinsched_send(struct pinsched *ps, uint16_t port_no,
}
void
}
void
-pinsched_run(struct pinsched *ps,
pinsched_tx_cb *cb, void *aux
)
+pinsched_run(struct pinsched *ps,
struct ovs_list *txq
)
{
{
+ list_init(txq);
if (ps) {
int i;
/* Drain some packets out of the bucket if possible, but limit the
* number of iterations to allow other code to get work done too. */
for (i = 0; ps->n_queued && get_token(ps) && i < 50; i++) {
if (ps) {
int i;
/* Drain some packets out of the bucket if possible, but limit the
* number of iterations to allow other code to get work done too. */
for (i = 0; ps->n_queued && get_token(ps) && i < 50; i++) {
- cb(get_tx_packet(ps), aux);
+ struct ofpbuf *packet = get_tx_packet(ps);
+ list_push_back(txq, &packet->list_node);
}
}
}
}
}
}
@@
-252,7
+246,6
@@
pinsched_create(int rate_limit, int burst_limit)
hmap_init(&ps->queues);
ps->n_queued = 0;
ps->next_txq = NULL;
hmap_init(&ps->queues);
ps->n_queued = 0;
ps->next_txq = NULL;
- ps->n_txq = 0;
ps->n_normal = 0;
ps->n_limited = 0;
ps->n_queue_dropped = 0;
ps->n_normal = 0;
ps->n_limited = 0;
ps->n_queue_dropped = 0;
@@
-295,10
+288,17
@@
pinsched_set_limits(struct pinsched *ps, int rate_limit, int burst_limit)
}
}
}
}
-/* Ret
urns the number of packets scheduled to be sent eventually by 'ps'.
- *
Returns 0 if 'ps' is
null. */
-unsigned int
-pinsched_
count_txqlen(const struct pinsched *p
s)
+/* Ret
rieves statistics for 'ps'. The statistics will be all zero if 'ps' is
+ * null. */
+void
+pinsched_
get_stats(const struct pinsched *ps, struct pinsched_stats *stat
s)
{
{
- return ps ? ps->n_txq : 0;
+ if (ps) {
+ stats->n_queued = ps->n_queued;
+ stats->n_normal = ps->n_normal;
+ stats->n_limited = ps->n_limited;
+ stats->n_queue_dropped = ps->n_queue_dropped;
+ } else {
+ memset(stats, 0, sizeof *stats);
+ }
}
}