+ return retval;
+ } else {
+ /* 'netdev' doesn't support QoS, so report that QoS is disabled. */
+ *typep = "";
+ return 0;
+ }
+}
+
+/* Attempts to reconfigure QoS on 'netdev', changing the form of QoS to 'type'
+ * with details of configuration from 'details'. Returns 0 if successful,
+ * otherwise a positive errno value. On error, the previous QoS configuration
+ * is retained.
+ *
+ * When this function changes the type of QoS (not just 'details'), this also
+ * resets all queue configuration for 'netdev' to their defaults (which depend
+ * on the specific type of QoS). Otherwise, the queue configuration for
+ * 'netdev' is unchanged.
+ *
+ * 'type' should be "" (to disable QoS) or one of the types returned by
+ * netdev_get_qos_types() for 'netdev'. The contents of 'details' should be
+ * documented as valid for the given 'type' in the "other_config" column in the
+ * "QoS" table in vswitchd/vswitch.xml (which is built as
+ * ovs-vswitchd.conf.db(8)).
+ *
+ * NULL may be specified for 'details' if there are no configuration
+ * details. */
+int
+netdev_set_qos(struct netdev *netdev,
+ const char *type, const struct smap *details)
+{
+ const struct netdev_class *class = netdev_get_dev(netdev)->netdev_class;
+
+ if (!type) {
+ type = "";
+ }
+
+ if (class->set_qos) {
+ if (!details) {
+ static struct smap empty = SMAP_INITIALIZER(&empty);
+ details = ∅
+ }
+ return class->set_qos(netdev, type, details);
+ } else {
+ return *type ? EOPNOTSUPP : 0;
+ }
+}
+
+/* Queries 'netdev' for information about the queue numbered 'queue_id'. If
+ * successful, adds that information as string key-value pairs to 'details'.
+ * Returns 0 if successful, otherwise a positive errno value.
+ *
+ * 'queue_id' must be less than the number of queues supported by 'netdev' for
+ * the current form of QoS (e.g. as returned by netdev_get_n_queues(netdev)).
+ *
+ * The returned contents of 'details' should be documented as valid for the
+ * given 'type' in the "other_config" column in the "Queue" table in
+ * vswitchd/vswitch.xml (which is built as ovs-vswitchd.conf.db(8)).
+ *
+ * The caller must initialize 'details' (e.g. with smap_init()) before calling
+ * this function. The caller must free 'details' when it is no longer needed
+ * (e.g. with smap_destroy()). */
+int
+netdev_get_queue(const struct netdev *netdev,
+ unsigned int queue_id, struct smap *details)
+{
+ const struct netdev_class *class = netdev_get_dev(netdev)->netdev_class;
+ int retval;
+
+ retval = (class->get_queue
+ ? class->get_queue(netdev, queue_id, details)
+ : EOPNOTSUPP);
+ if (retval) {
+ smap_clear(details);
+ }
+ return retval;
+}
+
+/* Configures the queue numbered 'queue_id' on 'netdev' with the key-value
+ * string pairs in 'details'. The contents of 'details' should be documented
+ * as valid for the given 'type' in the "other_config" column in the "Queue"
+ * table in vswitchd/vswitch.xml (which is built as ovs-vswitchd.conf.db(8)).
+ * Returns 0 if successful, otherwise a positive errno value. On failure, the
+ * given queue's configuration should be unmodified.
+ *
+ * 'queue_id' must be less than the number of queues supported by 'netdev' for
+ * the current form of QoS (e.g. as returned by netdev_get_n_queues(netdev)).
+ *
+ * This function does not modify 'details', and the caller retains ownership of
+ * it. */
+int
+netdev_set_queue(struct netdev *netdev,
+ unsigned int queue_id, const struct smap *details)
+{
+ const struct netdev_class *class = netdev_get_dev(netdev)->netdev_class;
+ return (class->set_queue
+ ? class->set_queue(netdev, queue_id, details)
+ : EOPNOTSUPP);
+}
+
+/* Attempts to delete the queue numbered 'queue_id' from 'netdev'. Some kinds
+ * of QoS may have a fixed set of queues, in which case attempts to delete them
+ * will fail with EOPNOTSUPP.
+ *
+ * Returns 0 if successful, otherwise a positive errno value. On failure, the
+ * given queue will be unmodified.
+ *
+ * 'queue_id' must be less than the number of queues supported by 'netdev' for
+ * the current form of QoS (e.g. as returned by
+ * netdev_get_n_queues(netdev)). */
+int
+netdev_delete_queue(struct netdev *netdev, unsigned int queue_id)
+{
+ const struct netdev_class *class = netdev_get_dev(netdev)->netdev_class;
+ return (class->delete_queue
+ ? class->delete_queue(netdev, queue_id)
+ : EOPNOTSUPP);
+}
+
+/* Obtains statistics about 'queue_id' on 'netdev'. On success, returns 0 and
+ * fills 'stats' with the queue's statistics; individual members of 'stats' may
+ * be set to all-1-bits if the statistic is unavailable. On failure, returns a
+ * positive errno value and fills 'stats' with all-1-bits. */
+int
+netdev_get_queue_stats(const struct netdev *netdev, unsigned int queue_id,
+ struct netdev_queue_stats *stats)
+{
+ const struct netdev_class *class = netdev_get_dev(netdev)->netdev_class;
+ int retval;
+
+ retval = (class->get_queue_stats
+ ? class->get_queue_stats(netdev, queue_id, stats)
+ : EOPNOTSUPP);
+ if (retval) {
+ memset(stats, 0xff, sizeof *stats);