On Mon, Sep 23, 2019 at 5:09 PM Lorenzo Bianconi <[email protected]> wrote: > > Refactor allocate_chassis_queueid and free_chassis_queueid in order > to get an unused queue_id even for localnet ports and add the > the possibility to define localnet as qos capable port > > Signed-off-by: Lorenzo Bianconi <[email protected]>
Looks good to me. Acked-by: Dumitru Ceara <[email protected]> > --- > northd/ovn-northd.c | 45 ++++++++++++++++++++++++++++++--------------- > 1 file changed, 30 insertions(+), 15 deletions(-) > > diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c > index f393cebb8..633fb502b 100644 > --- a/northd/ovn-northd.c > +++ b/northd/ovn-northd.c > @@ -357,7 +357,7 @@ destroy_chassis_queues(struct hmap *set) > } > > static void > -add_chassis_queue(struct hmap *set, struct uuid *chassis_uuid, > +add_chassis_queue(struct hmap *set, const struct uuid *chassis_uuid, > uint32_t queue_id) > { > struct ovn_chassis_qdisc_queues *node = xmalloc(sizeof *node); > @@ -368,7 +368,7 @@ add_chassis_queue(struct hmap *set, struct uuid > *chassis_uuid, > } > > static bool > -chassis_queueid_in_use(const struct hmap *set, struct uuid *chassis_uuid, > +chassis_queueid_in_use(const struct hmap *set, const struct uuid > *chassis_uuid, > uint32_t queue_id) > { > const struct ovn_chassis_qdisc_queues *node; > @@ -383,31 +383,38 @@ chassis_queueid_in_use(const struct hmap *set, struct > uuid *chassis_uuid, > } > > static uint32_t > -allocate_chassis_queueid(struct hmap *set, struct sbrec_chassis *chassis) > +allocate_chassis_queueid(struct hmap *set, const struct uuid *uuid, char > *name) > { > + if (!uuid) { > + return 0; > + } > + > for (uint32_t queue_id = QDISC_MIN_QUEUE_ID + 1; > queue_id <= QDISC_MAX_QUEUE_ID; > queue_id++) { > - if (!chassis_queueid_in_use(set, &chassis->header_.uuid, queue_id)) { > - add_chassis_queue(set, &chassis->header_.uuid, queue_id); > + if (!chassis_queueid_in_use(set, uuid, queue_id)) { > + add_chassis_queue(set, uuid, queue_id); > return queue_id; > } > } > > static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); > - VLOG_WARN_RL(&rl, "all %s queue ids exhausted", chassis->name); > + VLOG_WARN_RL(&rl, "all %s queue ids exhausted", name); > return 0; > } > > static void > -free_chassis_queueid(struct hmap *set, struct sbrec_chassis *chassis, > +free_chassis_queueid(struct hmap *set, const struct uuid *uuid, > uint32_t queue_id) > { > - const struct uuid *chassis_uuid = &chassis->header_.uuid; > + if (!uuid) { > + return; > + } > + > struct ovn_chassis_qdisc_queues *node; > HMAP_FOR_EACH_WITH_HASH (node, key_node, > - hash_chassis_queue(chassis_uuid, queue_id), > set) { > - if (uuid_equals(chassis_uuid, &node->chassis_uuid) > + hash_chassis_queue(uuid, queue_id), set) { > + if (uuid_equals(uuid, &node->chassis_uuid) > && node->queue_id == queue_id) { > hmap_remove(set, &node->key_node); > free(node); > @@ -2650,15 +2657,23 @@ ovn_port_update_sbrec(struct northd_context *ctx, > uint32_t queue_id = smap_get_int( > &op->sb->options, "qdisc_queue_id", 0); > bool has_qos = port_has_qos_params(&op->nbsp->options); > + const struct uuid *uuid = NULL; > struct smap options; > + char *name = ""; > + > + if (!strcmp(op->nbsp->type, "localnet")) { > + uuid = &op->sb->header_.uuid; > + name = "localnet"; > + } else if (op->sb->chassis) { > + uuid = &op->sb->chassis->header_.uuid; > + name = op->sb->chassis->name; > + } > > - if (op->sb->chassis && has_qos && !queue_id) { > + if (has_qos && !queue_id) { > queue_id = allocate_chassis_queueid(chassis_qdisc_queues, > - op->sb->chassis); > + uuid, name); > } else if (!has_qos && queue_id) { > - free_chassis_queueid(chassis_qdisc_queues, > - op->sb->chassis, > - queue_id); > + free_chassis_queueid(chassis_qdisc_queues, uuid, queue_id); > queue_id = 0; > } > > -- > 2.21.0 > _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
