-typedef void netdev_dump_queues_cb(unsigned int queue_id,
- const struct smap *details, void *aux);
-int netdev_dump_queues(const struct netdev *,
- netdev_dump_queues_cb *, void *aux);
+struct netdev_queue_dump {
+ struct netdev *netdev;
+ int error;
+ void *state;
+};
+void netdev_queue_dump_start(struct netdev_queue_dump *,
+ const struct netdev *);
+bool netdev_queue_dump_next(struct netdev_queue_dump *,
+ unsigned int *queue_id, struct smap *details);
+int netdev_queue_dump_done(struct netdev_queue_dump *);
+
+/* Iterates through each queue in NETDEV, using DUMP as state. Fills QUEUE_ID
+ * and DETAILS with information about queues. The client must initialize and
+ * destroy DETAILS.
+ *
+ * Arguments all have pointer type.
+ *
+ * If you break out of the loop, then you need to free the dump structure by
+ * hand using netdev_queue_dump_done(). */
+#define NETDEV_QUEUE_FOR_EACH(QUEUE_ID, DETAILS, DUMP, NETDEV) \
+ for (netdev_queue_dump_start(DUMP, NETDEV); \
+ (netdev_queue_dump_next(DUMP, QUEUE_ID, DETAILS) \
+ ? true \
+ : (netdev_queue_dump_done(DUMP), false)); \
+ )