X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=ofproto%2Fpinsched.c;h=831afefb2836417850cad30919d585fa137ab417;hb=28c5588e8e1a8d091c5d2275232c35f2968a97fa;hp=57e8e2327b36fe877f9216e5bf51dda43dd25049;hpb=648f4f1fe4ee22cf9d5e9dc0eb9b53a40f9035db;p=sliver-openvswitch.git diff --git a/ofproto/pinsched.c b/ofproto/pinsched.c index 57e8e2327..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. @@ -21,6 +21,7 @@ #include #include #include +#include "flow.h" #include "hash.h" #include "hmap.h" #include "ofpbuf.h" @@ -35,7 +36,7 @@ struct pinqueue { struct hmap_node node; /* In struct pinsched's 'queues' hmap. */ - uint16_t port_no; /* Port number. */ + ofp_port_t port_no; /* Port number. */ struct list packets; /* Contains "struct ofpbuf"s. */ int n; /* Number of packets in 'packets'. */ }; @@ -101,9 +102,9 @@ pinqueue_destroy(struct pinsched *ps, struct pinqueue *q) } 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) { @@ -184,16 +185,17 @@ get_token(struct pinsched *ps) } 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 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; @@ -216,15 +218,17 @@ pinsched_send(struct pinsched *ps, uint16_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); } } }