+/* 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, uint16_t port_no)
+{
+ uint32_t hash = hash_int(port_no, 0);
+ 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;
+}
+