From patchwork Mon Sep 23 15:09:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1166097 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 46cSSh1gMDz9sNw for ; Tue, 24 Sep 2019 01:11:00 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 49659D84; Mon, 23 Sep 2019 15:09:22 +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 F1404D4B for ; Mon, 23 Sep 2019 15:09:18 +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 6AA2A108 for ; Mon, 23 Sep 2019 15:09:18 +0000 (UTC) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (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 C15053DE31 for ; Mon, 23 Sep 2019 15:09:17 +0000 (UTC) Received: by mail-wr1-f71.google.com with SMTP id t11so4956064wro.10 for ; Mon, 23 Sep 2019 08:09:17 -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:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FNCuw04ttT65SL/a2BzWXaFfjVfTZ5AJVws/xu3D+lo=; b=tPMsSDkSso0zX3kgTdJK2R/PNg0ZrboIuP3qWkwaoZDNi51HvWOxJEAM7+cDs9iUki sQOa4ilxOF0KZQ1xbCXPAM3cYfJyknoCyoQaped6P1wDApPAK0DKrIMG8ThclyVQMg+v l/bWVkQ4yY01uaz7aN8lHOnZ1NFOJ23+XznEzkCCZgABuk+dzTBa3Xl8SVhhiupOx/Dl pBiD8Xi53DAaMdwv7NoXyz9i0o21+/rVE2bQlfQk3RFnGI9kmtndgVtzUEFujPwykb7i rYZ3mlypk9Z/ROMb2oPA/UJVbNvKshZt+GSCjrSslco7fPfFzRAyo7YsWBZg6UxmRStX 883A== X-Gm-Message-State: APjAAAWOYHU92cVMD8vX0voZs1gvfAyJleDfODedFpvHZbHHGhJC90za IfQhU9PGx7X/mszk4b8yPD2LNHanb/xf2G9Se5JfPoj2iCPsrnzWiYDBzpPbkDaC6piMnOXA67e rWsPr6XFIH5m6UkYXuA== X-Received: by 2002:a1c:1fd3:: with SMTP id f202mr141342wmf.18.1569251356301; Mon, 23 Sep 2019 08:09:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqyAEIaWsjnTSptDoAxsw/ojLJKsrZPQjKwm3/e8DHDzostCzlg3h5v+D98LGocYuD3Y5aUagA== X-Received: by 2002:a1c:1fd3:: with SMTP id f202mr141320wmf.18.1569251356070; Mon, 23 Sep 2019 08:09:16 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id u22sm19648658wru.72.2019.09.23.08.09.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2019 08:09:15 -0700 (PDT) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Mon, 23 Sep 2019 17:09:01 +0200 Message-Id: <70b41a3ef538fa37b940419a7c1e3d076c3b68ef.1569250466.git.lorenzo.bianconi@redhat.com> 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] [PATCH 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 the possibility to define localnet as qos capable port Signed-off-by: Lorenzo Bianconi Acked-by: Dumitru Ceara --- 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; }