From patchwork Wed May 17 09:01:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1782529 X-Patchwork-Delegate: nusiddiq@redhat.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=FoW526dj; dkim-atps=neutral Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QLnDn5vDFz20dg for ; Wed, 17 May 2023 19:02:33 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 4A3D742A72; Wed, 17 May 2023 09:02:31 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 4A3D742A72 Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=FoW526dj X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id F85AZpSEkMFZ; Wed, 17 May 2023 09:02:28 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id 4BECB429FF; Wed, 17 May 2023 09:02:22 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 4BECB429FF Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E6AF4C0037; Wed, 17 May 2023 09:02:21 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 22A4AC0090 for ; Wed, 17 May 2023 09:02:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 5431242700 for ; Wed, 17 May 2023 09:02:15 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 5431242700 Authentication-Results: smtp4.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=FoW526dj X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kGMap7eCJCfi for ; Wed, 17 May 2023 09:02:12 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 81AFF4205E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id 81AFF4205E for ; Wed, 17 May 2023 09:02:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684314131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OJEm+jImbSj7vQ7iAjfKNb2P6wHRjMGK5X1fElmot7M=; b=FoW526djfCaXbO/ZTvgNepAkjldx6iIYQQJICbthGm+MhPxlj6TeQwq1qNhjIejM8b4M3a +HEFb3c/ewFqWmKivCbT/OPFxBaHj8pnGvQVGEHnymxXB7fOwgzgcwk4+TCmFtfOaKYPEg Z3DpBeS+1c3zjTVqCOuZXvimYh26zQQ= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-259-0BDfmQ4CORKk8FM9uIPkyg-1; Wed, 17 May 2023 05:02:10 -0400 X-MC-Unique: 0BDfmQ4CORKk8FM9uIPkyg-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-30641258c9eso179512f8f.2 for ; Wed, 17 May 2023 02:02:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684314129; x=1686906129; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OJEm+jImbSj7vQ7iAjfKNb2P6wHRjMGK5X1fElmot7M=; b=PqNFfd5RX++WVbLa6ty1LebGHRQstczzLX3bOBtkzHXTFkGvIQeBoQUtRxjoglSD1L E7m8zGEr+zZ3Pi5VLSDsOEmdrvlW5xf1qLxKiyg0cfxoHBi2FOfg8yYTnUZZmimNpXjZ XX8E7obN0Mq9EYxZlOXN6zLV9TG0aseATOJHN9O/DFyWIyt9oJGFkwKlctpXgbSB50Bu OPZGdDHjuFp5ukI7om0gFWa+O/mC6ZWluT2JCsOFgcykqUE0SDNGF1kO1tdLCRFX0TEI elpbod1iuhvWRH/SiuJFjSxBhAsHcoAZDQzyly6q+LU/ur8t1aWU9nKrZi5pMHAC2TL1 7vIw== X-Gm-Message-State: AC+VfDwNq3Rr5MUPkU4s+J7jSMsY7YR1ey8l/uPnZmXwQvmfF2HrDTtv xnSutA6mGY2JFY899tEeZg3TYlASfF9J49BXGr1Kdf17EuLgRtMVYTYYibNe7C80Ono/vXwugvt JYr5GU/2ua7P84fe2eUhhPhgvlWjIUP+HV3QUrvP2oZhaKjjv1TfIXeWsmTowOlZeHjGodmFnjm wbOFggpf5has6A X-Received: by 2002:a05:6000:1184:b0:306:28f4:963c with SMTP id g4-20020a056000118400b0030628f4963cmr55851wrx.23.1684314128720; Wed, 17 May 2023 02:02:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4LHNEDUKzpr8cRxglo1OBvFibgCVIyaa7RzdTjatuYYnYiYeN5B6Eem4w8WsuEZHd7ihs3qw== X-Received: by 2002:a05:6000:1184:b0:306:28f4:963c with SMTP id g4-20020a056000118400b0030628f4963cmr55809wrx.23.1684314127885; Wed, 17 May 2023 02:02:07 -0700 (PDT) Received: from localhost (net-130-25-106-149.cust.vodafonedsl.it. [130.25.106.149]) by smtp.gmail.com with ESMTPSA id u14-20020adfdd4e000000b003063938bf7bsm2092953wrm.86.2023.05.17.02.02.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 02:02:07 -0700 (PDT) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Wed, 17 May 2023 11:01:31 +0200 Message-Id: <727f88482affa8f5e0f93da0ac3d32d98c025156.1684312052.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: dceara@redhat.com, simon.horman@corigine.com, i.maximets@ovn.org, ralonsoh@redhat.com Subject: [ovs-dev] [PATCH v8 ovn 05/10] controller: improve ovs port lookup by qos X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Introduce ovsport_lookup_by_qos routine in order to speed-up ovs port lookup based on port qos. Acked-By: Ihar Hrachyshka Tested-by: Rodolfo Alonso Signed-off-by: Lorenzo Bianconi --- controller/binding.c | 37 ++++++++++++++----------------------- controller/binding.h | 2 +- controller/ovn-controller.c | 13 +++++++++---- controller/ovsport.c | 16 ++++++++++++++++ controller/ovsport.h | 3 +++ 5 files changed, 43 insertions(+), 28 deletions(-) diff --git a/controller/binding.c b/controller/binding.c index e18488c7e..6cd3c6c1d 100644 --- a/controller/binding.c +++ b/controller/binding.c @@ -36,6 +36,7 @@ #include "lport.h" #include "ovn-controller.h" #include "patch.h" +#include "ovsport.h" VLOG_DEFINE_THIS_MODULE(binding); @@ -281,7 +282,7 @@ add_ovs_qos_table_entry(struct ovsdb_idl_txn *ovs_idl_txn, static void remove_stale_qos_entry(struct ovsdb_idl_txn *ovs_idl_txn, const struct sbrec_port_binding *pb, - const struct ovsrec_port_table *port_table, + struct ovsdb_idl_index *ovsrec_port_by_qos, const struct ovsrec_qos_table *qos_table, struct hmap *queue_map) { @@ -314,13 +315,8 @@ remove_stale_qos_entry(struct ovsdb_idl_txn *ovs_idl_txn, ovsrec_queue_delete(queue); if (qos->n_queues == 1) { - const struct ovsrec_port *port = NULL, *iter; - OVSREC_PORT_TABLE_FOR_EACH (iter, port_table) { - if (iter->qos == qos) { - port = iter; - break; - } - } + const struct ovsrec_port *port = + ovsport_lookup_by_qos(ovsrec_port_by_qos, qos); if (port) { ovsrec_port_set_qos(port, NULL); } @@ -349,9 +345,8 @@ configure_qos(const struct sbrec_port_binding *pb, if ((!min_rate && !max_rate && !burst) || !queue_id) { /* Qos is not configured for this port. */ remove_stale_qos_entry(b_ctx_in->ovs_idl_txn, pb, - b_ctx_in->port_table, - b_ctx_in->qos_table, - b_ctx_out->qos_map); + b_ctx_in->ovsrec_port_by_qos, + b_ctx_in->qos_table, b_ctx_out->qos_map); return; } @@ -398,7 +393,7 @@ configure_qos(const struct sbrec_port_binding *pb, static void ovs_qos_entries_gc(struct ovsdb_idl_txn *ovs_idl_txn, - const struct ovsrec_port_table *port_table, + struct ovsdb_idl_index *ovsrec_port_by_qos, const struct ovsrec_qos_table *qos_table, struct hmap *queue_map) { @@ -430,13 +425,8 @@ ovs_qos_entries_gc(struct ovsdb_idl_txn *ovs_idl_txn, } if (n_queue_deleted && n_queue_deleted == n_queues) { - const struct ovsrec_port *port = NULL, *iter; - OVSREC_PORT_TABLE_FOR_EACH (iter, port_table) { - if (iter->qos == qos) { - port = iter; - break; - } - } + const struct ovsrec_port *port = + ovsport_lookup_by_qos(ovsrec_port_by_qos, qos); if (port) { ovsrec_port_set_qos(port, NULL); } @@ -2160,7 +2150,7 @@ binding_run(struct binding_ctx_in *b_ctx_in, struct binding_ctx_out *b_ctx_out) shash_destroy(&bridge_mappings); /* Remove stale QoS entries. */ - ovs_qos_entries_gc(b_ctx_in->ovs_idl_txn, b_ctx_in->port_table, + ovs_qos_entries_gc(b_ctx_in->ovs_idl_txn, b_ctx_in->ovsrec_port_by_qos, b_ctx_in->qos_table, b_ctx_out->qos_map); cleanup_claimed_port_timestamps(); @@ -2380,8 +2370,8 @@ consider_iface_release(const struct ovsrec_interface *iface_rec, if (b_ctx_in->ovs_idl_txn) { remove_stale_qos_entry(b_ctx_in->ovs_idl_txn, b_lport->pb, - b_ctx_in->port_table, b_ctx_in->qos_table, - b_ctx_out->qos_map); + b_ctx_in->ovsrec_port_by_qos, + b_ctx_in->qos_table, b_ctx_out->qos_map); } /* Release the primary binding lport and other children lports if @@ -3020,7 +3010,8 @@ binding_handle_port_binding_changes(struct binding_ctx_in *b_ctx_in, shash_add(&deleted_other_pbs, pb->logical_port, pb); } - remove_stale_qos_entry(b_ctx_in->ovs_idl_txn, pb, b_ctx_in->port_table, + remove_stale_qos_entry(b_ctx_in->ovs_idl_txn, pb, + b_ctx_in->ovsrec_port_by_qos, b_ctx_in->qos_table, b_ctx_out->qos_map); } diff --git a/controller/binding.h b/controller/binding.h index 87ee7b540..6b97bcff0 100644 --- a/controller/binding.h +++ b/controller/binding.h @@ -46,7 +46,7 @@ struct binding_ctx_in { struct ovsdb_idl_index *sbrec_datapath_binding_by_key; struct ovsdb_idl_index *sbrec_port_binding_by_datapath; struct ovsdb_idl_index *sbrec_port_binding_by_name; - const struct ovsrec_port_table *port_table; + struct ovsdb_idl_index *ovsrec_port_by_qos; const struct ovsrec_qos_table *qos_table; const struct sbrec_port_binding_table *port_binding_table; const struct ovsrec_bridge *br_int; diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 3ddf4795e..1dd1099a4 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -1498,9 +1498,6 @@ init_binding_ctx(struct engine_node *node, = chassis_lookup_by_name(sbrec_chassis_by_name, chassis_id); ovs_assert(chassis); - const struct ovsrec_port_table *port_table = - EN_OVSDB_GET(engine_get_input("OVS_port", node)); - struct ed_type_ovs_interface_shadow *iface_shadow = engine_get_input_data("ovs_interface_shadow", node); @@ -1525,6 +1522,10 @@ init_binding_ctx(struct engine_node *node, engine_get_input("SB_port_binding", node), "datapath"); + struct ovsdb_idl_index *ovsrec_port_by_qos = + engine_ovsdb_node_get_index( + engine_get_input("OVS_port", node), "qos"); + struct controller_engine_ctx *ctrl_ctx = engine_get_context()->client_ctx; b_ctx_in->ovnsb_idl_txn = engine_get_context()->ovnsb_idl_txn; @@ -1532,7 +1533,7 @@ init_binding_ctx(struct engine_node *node, b_ctx_in->sbrec_datapath_binding_by_key = sbrec_datapath_binding_by_key; b_ctx_in->sbrec_port_binding_by_datapath = sbrec_port_binding_by_datapath; b_ctx_in->sbrec_port_binding_by_name = sbrec_port_binding_by_name; - b_ctx_in->port_table = port_table; + b_ctx_in->ovsrec_port_by_qos = ovsrec_port_by_qos; b_ctx_in->iface_table = iface_shadow->iface_table; b_ctx_in->iface_table_external_ids_old = &iface_shadow->iface_table_external_ids_old; @@ -4478,6 +4479,9 @@ main(int argc, char *argv[]) struct ovsdb_idl_index *ovsrec_port_by_name = ovsdb_idl_index_create1(ovs_idl_loop.idl, &ovsrec_port_col_name); + struct ovsdb_idl_index *ovsrec_port_by_qos + = ovsdb_idl_index_create1(ovs_idl_loop.idl, + &ovsrec_port_col_qos); struct ovsdb_idl_index *ovsrec_flow_sample_collector_set_by_id = ovsdb_idl_index_create2(ovs_idl_loop.idl, &ovsrec_flow_sample_collector_set_col_bridge, @@ -4832,6 +4836,7 @@ main(int argc, char *argv[]) sbrec_chassis_template_var_index_by_chassis); engine_ovsdb_node_add_index(&en_ovs_flow_sample_collector_set, "id", ovsrec_flow_sample_collector_set_by_id); + engine_ovsdb_node_add_index(&en_ovs_port, "qos", ovsrec_port_by_qos); struct ed_type_lflow_output *lflow_output_data = engine_get_internal_data(&en_lflow_output); diff --git a/controller/ovsport.c b/controller/ovsport.c index ec38c3fca..0503241ac 100644 --- a/controller/ovsport.c +++ b/controller/ovsport.c @@ -216,6 +216,22 @@ ovsrec_port * ovsport_lookup_by_interface( interfaces, 1); } +const struct ovsrec_port * +ovsport_lookup_by_qos(struct ovsdb_idl_index *ovsrec_port_by_qos, + const struct ovsrec_qos *qos) +{ + const struct ovsrec_port *port = + ovsrec_port_index_init_row(ovsrec_port_by_qos); + ovsrec_port_index_set_qos(port, qos); + + const struct ovsrec_port *retval = + ovsrec_port_index_find(ovsrec_port_by_qos, port); + + ovsrec_port_index_destroy_row(port); + + return retval; +} + /* Update an interface map column with the key/value pairs present in the * provided smap, only applying changes when necessary. */ static void diff --git a/controller/ovsport.h b/controller/ovsport.h index e355ff7ff..ef1ff50b8 100644 --- a/controller/ovsport.h +++ b/controller/ovsport.h @@ -33,6 +33,7 @@ struct ovsrec_bridge; struct ovsrec_port; struct ovsrec_interface; struct ovsdb_idl_index; +struct ovsrec_qos; void ovsport_create(struct ovsdb_idl_txn *ovs_idl_txn, const struct ovsrec_bridge *bridge, @@ -56,5 +57,7 @@ const struct ovsrec_port * ovsport_lookup_by_interfaces( const size_t n_interfaces); const struct ovsrec_port * ovsport_lookup_by_interface( struct ovsdb_idl_index *, struct ovsrec_interface *); +const struct ovsrec_port * ovsport_lookup_by_qos( + struct ovsdb_idl_index *, const struct ovsrec_qos *); #endif /* lib/ovsport.h */