From patchwork Wed Sep 11 17:19:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1161171 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46T7wn29Phz9s00 for ; Thu, 12 Sep 2019 03:21:29 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 1E428E7B; Wed, 11 Sep 2019 17:20:04 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id E09D0E33 for ; Wed, 11 Sep 2019 17:20:01 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 6C55D81A for ; Wed, 11 Sep 2019 17:20:01 +0000 (UTC) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 84B8A5D66B for ; Wed, 11 Sep 2019 17:20:00 +0000 (UTC) Received: by mail-wm1-f72.google.com with SMTP id m6so1502732wmf.2 for ; Wed, 11 Sep 2019 10:20:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Fao+7EXYSyDke+HfVePE0ANPL1SyBaowqcrjNVdrW+I=; b=f02+uxsqEs78EYib+ourixRs3kPm3Ihm9qDfDEoFwBzS2rvGDwZKyGTGoWxQcIUl8q NtWIXpFEAwMALNEqUGGVoLdAV2v37p2UGsPIrVZCHdtFn1xFUr3ExZb3q1LEKHM0vOY7 BXhxOFt/DnrST+TsfAnLcXuSVDaba7rtJtIX1GD0Ha81zPGvhHWFAdXYj6JXcnAeOYxM 0jwoCZu3zNhC8sH/rTflGdLnygAKTgJAmEcvRoJrak5zAoL2CwEIK1VWKXkwB5kFMyJ+ XFrn88t+95s0Mzy+l3XjlLBd724A0DQfURXbHBcGMPoPbSvwJXhEYHEUw8chvV7OtoKD hTIw== X-Gm-Message-State: APjAAAUO+SxL6A1SS/R888Hgwrvc4apAEIVvZ0MqMokI0gnj56eD57eg fwWIkJPIzeytQNvNS+YSuo6AMJSsHjoupTW1yOMH1ZljEtJIDbFZlzrleXuZBia6aPatnUE3rEg GFt8/p0r23RsUbN7AOw== X-Received: by 2002:a05:600c:251:: with SMTP id 17mr4823120wmj.17.1568222399019; Wed, 11 Sep 2019 10:19:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxe9uAXCFzmyRGbhuejxHu8SuBMMrY8sO72yWuU3sjsFHJqBzWONNgpK1GcX82+EZg/hPaVg== X-Received: by 2002:a05:600c:251:: with SMTP id 17mr4823111wmj.17.1568222398793; Wed, 11 Sep 2019 10:19:58 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id j30sm26903822wrb.66.2019.09.11.10.19.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2019 10:19:58 -0700 (PDT) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Wed, 11 Sep 2019 19:19:47 +0200 Message-Id: X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [RFC ovn 2/3] northd: add the possibility to define localnet as qos capable port X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Refactor allocate_chassis_queueid and free_chassis_queueid in order to get an unused queue_id even for localnet ports and add the possibility to define localnet as qos capable port Signed-off-by: Lorenzo Bianconi --- 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 c24e4d864..889eeb795 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; }