+static void
+adjust_limits(int *rate_limit, int *burst_limit)
+{
+ if (*rate_limit <= 0) {
+ *rate_limit = 1000;
+ }
+ if (*burst_limit <= 0) {
+ *burst_limit = *rate_limit / 4;
+ }
+ if (*burst_limit < 1) {
+ *burst_limit = 1;
+ }
+}
+
+/* Destroys 'q' and removes it from 'ps''s set of queues.
+ * (The caller must ensure that 'q' is empty.) */
+static void
+pinqueue_destroy(struct pinsched *ps, struct pinqueue *q)
+{
+ hmap_remove(&ps->queues, &q->node);
+ free(q);
+}
+
+static struct pinqueue *
+pinqueue_get(struct pinsched *ps, ofp_port_t port_no)
+{
+ uint32_t hash = hash_ofp_port(port_no);
+ struct pinqueue *q;
+
+ HMAP_FOR_EACH_IN_BUCKET (q, node, hash, &ps->queues) {
+ if (port_no == q->port_no) {
+ return q;
+ }
+ }
+
+ q = xmalloc(sizeof *q);
+ hmap_insert(&ps->queues, &q->node, hash);
+ q->port_no = port_no;
+ list_init(&q->packets);
+ q->n = 0;
+ return q;
+}
+