diff options
author | Ben Pfaff <blp@nicira.com> | 2013-10-22 21:58:58 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2013-10-23 08:37:41 -0700 |
commit | a6f7596183f8d3f629889c8c90b388556d48978e (patch) | |
tree | 52067059fdf3f9818402811656ff2f0ede9ca010 /ofproto/pinsched.c | |
parent | cfa955b083c5617212a29a03423e063ff6cb350a (diff) | |
download | openvswitch-a6f7596183f8d3f629889c8c90b388556d48978e.tar.gz |
pinsched: Eliminate function callback in interface.
I'm not a fan of function callbacks because I feel that they obscure
interfaces. This eliminates the function callback used until now in
the pinsched code.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'ofproto/pinsched.c')
-rw-r--r-- | ofproto/pinsched.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/ofproto/pinsched.c b/ofproto/pinsched.c index 91e9c411c..831afefb2 100644 --- 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 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -186,15 +186,16 @@ get_token(struct pinsched *ps) void pinsched_send(struct pinsched *ps, ofp_port_t port_no, - struct ofpbuf *packet, pinsched_tx_cb *cb, void *aux) + struct ofpbuf *packet, struct list *txq) { + list_init(txq); 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++; - cb(packet, aux); + list_push_back(txq, &packet->list_node); } else { /* Otherwise queue it up for the periodic callback to drain out. */ struct pinqueue *q; @@ -217,15 +218,17 @@ pinsched_send(struct pinsched *ps, ofp_port_t port_no, } void -pinsched_run(struct pinsched *ps, pinsched_tx_cb *cb, void *aux) +pinsched_run(struct pinsched *ps, struct 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++) { - cb(get_tx_packet(ps), aux); + struct ofpbuf *packet = get_tx_packet(ps); + list_push_back(txq, &packet->list_node); } } } |