From patchwork Tue Aug 6 09:44:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1969408 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=Q7mEgmS4; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WdT3j0ZL5z1ydt for ; Tue, 6 Aug 2024 19:46:57 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 28B154046D; Tue, 6 Aug 2024 09:46:54 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 85QiNXP78P1p; Tue, 6 Aug 2024 09:46:49 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org E249A40448 Authentication-Results: smtp4.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=Q7mEgmS4 Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id E249A40448; Tue, 6 Aug 2024 09:46:48 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B82B2C002B; Tue, 6 Aug 2024 09:46:48 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 178C0C002A for ; Tue, 6 Aug 2024 09:46:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 2B63B81184 for ; Tue, 6 Aug 2024 09:46:12 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 0lt6EXd-47Xe for ; Tue, 6 Aug 2024 09:46:11 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=dceara@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org 2C9E2811B6 Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 2C9E2811B6 Authentication-Results: smtp1.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Q7mEgmS4 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 2C9E2811B6 for ; Tue, 6 Aug 2024 09:46:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722937570; 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=zEQ1wUUiCt7AB61XLfe5/ineEgSQsnUBCSTBGMLecSk=; b=Q7mEgmS4J0QAawah3PoSRmiZxSb1GZ7+javYNPy4bnvXdC+ZV9RpNvSdtuk1BgGZuFFipN kkfPlOkyfiFN4LNmS+7/oPRam8Q76A5700vPLjhrr5oj5HZHg8geek2VnyE37pOT+8WWEc UXKqmIDx1/qgYXvIIfzuLOVBARvFncY= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-453-ZipVpm09M36O6OHoluDY5g-1; Tue, 06 Aug 2024 05:46:06 -0400 X-MC-Unique: ZipVpm09M36O6OHoluDY5g-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B4F581955D4A; Tue, 6 Aug 2024 09:46:05 +0000 (UTC) Received: from cecil-rh.redhat.com (unknown [10.39.193.207]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7E0AA1955F6B; Tue, 6 Aug 2024 09:46:03 +0000 (UTC) From: Dumitru Ceara To: ovs-dev@openvswitch.org Date: Tue, 6 Aug 2024 11:44:49 +0200 Message-ID: <20240806094451.730622-8-dceara@redhat.com> In-Reply-To: <20240806094451.730622-1-dceara@redhat.com> References: <20240806094451.730622-1-dceara@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn v6 7/9] features: Add detection for sample with registers. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: i.maximets@ovn.org Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Ales Musil Add detection for sample action that allows to configure obs_domain_id and obs_point_id via registers. This feature is available only from OvS version 3.4. Signed-off-by: Ales Musil --- V5: - Addressed Ilya's comments: - Fixed SB chassis reconciliation. - Rename OVS_DP_SAMPLE_REG_SUPPORT to OVS_SAMPLE_REG_SUPPORT --- controller/chassis.c | 15 +++++++ include/ovn/features.h | 3 ++ lib/features.c | 91 +++++++++++++++++++++++++++++++++++++++ northd/en-global-config.c | 10 +++++ northd/en-global-config.h | 1 + 5 files changed, 120 insertions(+) diff --git a/controller/chassis.c b/controller/chassis.c index 4942ba281d..42a2894dce 100644 --- a/controller/chassis.c +++ b/controller/chassis.c @@ -67,6 +67,8 @@ struct ovs_chassis_cfg { struct ds iface_types; /* Is this chassis an interconnection gateway. */ bool is_interconn; + /* Does OVS support sampling with ids taken from registers? */ + bool sample_with_regs; }; static void @@ -338,6 +340,8 @@ chassis_parse_ovs_config(const struct ovsrec_open_vswitch_table *ovs_table, &ovs_cfg->iface_types); ovs_cfg->is_interconn = get_is_interconn(&cfg->external_ids, chassis_id); + ovs_cfg->sample_with_regs = + ovs_feature_is_supported(OVS_SAMPLE_REG_SUPPORT); return true; } @@ -372,6 +376,8 @@ chassis_build_other_config(const struct ovs_chassis_cfg *ovs_cfg, smap_replace(config, OVN_FEATURE_LS_DPG_COLUMN, "true"); smap_replace(config, OVN_FEATURE_CT_COMMIT_NAT_V2, "true"); smap_replace(config, OVN_FEATURE_CT_COMMIT_TO_ZONE, "true"); + smap_replace(config, OVN_FEATURE_SAMPLE_WITH_REGISTERS, + ovs_cfg->sample_with_regs ? "true" : "false"); } /* @@ -523,6 +529,14 @@ chassis_other_config_changed(const struct ovs_chassis_cfg *ovs_cfg, return true; } + bool chassis_sample_with_regs = + smap_get_bool(&chassis_rec->other_config, + OVN_FEATURE_SAMPLE_WITH_REGISTERS, + false); + if (chassis_sample_with_regs != ovs_cfg->sample_with_regs) { + return true; + } + return false; } @@ -656,6 +670,7 @@ update_supported_sset(struct sset *supported) sset_add(supported, OVN_FEATURE_LS_DPG_COLUMN); sset_add(supported, OVN_FEATURE_CT_COMMIT_NAT_V2); sset_add(supported, OVN_FEATURE_CT_COMMIT_TO_ZONE); + sset_add(supported, OVN_FEATURE_SAMPLE_WITH_REGISTERS); } static void diff --git a/include/ovn/features.h b/include/ovn/features.h index 97669410af..4275f75269 100644 --- a/include/ovn/features.h +++ b/include/ovn/features.h @@ -29,6 +29,7 @@ #define OVN_FEATURE_LS_DPG_COLUMN "ls-dpg-column" #define OVN_FEATURE_CT_COMMIT_NAT_V2 "ct-commit-nat-v2" #define OVN_FEATURE_CT_COMMIT_TO_ZONE "ct-commit-to-zone" +#define OVN_FEATURE_SAMPLE_WITH_REGISTERS "ovn-sample-with-registers" /* OVS datapath supported features. Based on availability OVN might generate * different types of openflows. @@ -39,6 +40,7 @@ enum ovs_feature_support_bits { OVS_CT_TUPLE_FLUSH_BIT, OVS_DP_HASH_L4_SYM_BIT, OVS_OF_GROUP_SUPPORT_BIT, + OVS_SAMPLE_REG_SUPPORT_BIT, }; enum ovs_feature_value { @@ -47,6 +49,7 @@ enum ovs_feature_value { OVS_CT_TUPLE_FLUSH_SUPPORT = (1 << OVS_CT_TUPLE_FLUSH_BIT), OVS_DP_HASH_L4_SYM_SUPPORT = (1 << OVS_DP_HASH_L4_SYM_BIT), OVS_OF_GROUP_SUPPORT = (1 << OVS_OF_GROUP_SUPPORT_BIT), + OVS_SAMPLE_REG_SUPPORT = (1 << OVS_SAMPLE_REG_SUPPORT_BIT), }; void ovs_feature_support_destroy(void); diff --git a/lib/features.c b/lib/features.c index d3591d6410..ab0327d516 100644 --- a/lib/features.c +++ b/lib/features.c @@ -25,6 +25,8 @@ #include "openvswitch/vlog.h" #include "openvswitch/ofpbuf.h" #include "openvswitch/rconn.h" +#include "openvswitch/ofp-actions.h" +#include "openvswitch/ofp-bundle.h" #include "openvswitch/ofp-msgs.h" #include "openvswitch/ofp-meter.h" #include "openvswitch/ofp-group.h" @@ -185,6 +187,87 @@ group_features_handle_response(struct ovs_openflow_feature *feature, return supported_ovs_features & feature->value; } +static void +sample_with_reg_send_request(struct ovs_openflow_feature *feature) +{ + struct ofputil_bundle_ctrl_msg ctrl = { + .bundle_id = 0, + .flags = OFPBF_ORDERED | OFPBF_ATOMIC, + .type = OFPBCT_OPEN_REQUEST, + }; + rconn_send(swconn, + ofputil_encode_bundle_ctrl_request(OFP15_VERSION, &ctrl), NULL); + + uint8_t actions_stub[64]; + struct ofpbuf actions; + ofpbuf_use_stub(&actions, actions_stub, sizeof(actions_stub)); + + struct mf_subfield subfield = { + .field = mf_from_id(MFF_REG0), + .n_bits = 32, + .ofs = 0 + }; + + struct ofpact_sample *sample = ofpact_put_SAMPLE(&actions); + sample->probability = UINT16_MAX; + sample->collector_set_id = 0; + sample->obs_domain_src = subfield; + sample->obs_point_src = subfield; + sample->sampling_port = OFPP_NONE; + + struct ofputil_flow_mod fm = { + .priority = 0, + .table_id = 0, + .ofpacts = actions.data, + .ofpacts_len = actions.size, + .command = OFPFC_ADD, + .new_cookie = htonll(0), + .buffer_id = UINT32_MAX, + .out_port = OFPP_ANY, + .out_group = OFPG_ANY, + }; + + struct match match; + match_init_catchall(&match); + minimatch_init(&fm.match, &match); + + struct ofpbuf *fm_msg = ofputil_encode_flow_mod(&fm, OFPUTIL_P_OF15_OXM); + + struct ofputil_bundle_add_msg bam = { + .bundle_id = ctrl.bundle_id, + .flags = ctrl.flags, + .msg = fm_msg->data, + }; + struct ofpbuf *msg = ofputil_encode_bundle_add(OFP15_VERSION, &bam); + + feature->xid = ((struct ofp_header *) msg->data)->xid; + rconn_send(swconn, msg, NULL); + + ctrl.type = OFPBCT_DISCARD_REQUEST; + rconn_send(swconn, + ofputil_encode_bundle_ctrl_request(OFP15_VERSION, &ctrl), NULL); + + minimatch_destroy(&fm.match); + ofpbuf_delete(fm_msg); +} + +static bool +sample_with_reg_handle_response(struct ovs_openflow_feature *feature, + enum ofptype type, const struct ofp_header *oh) +{ + if (type != OFPTYPE_ERROR) { + log_unexpected_reply(feature, oh); + } + + return false; +} + +static bool +sample_with_reg_handle_barrier(struct ovs_openflow_feature *feature OVS_UNUSED) +{ + return true; +} + static struct ovs_openflow_feature all_openflow_features[] = { { .value = OVS_DP_METER_SUPPORT, @@ -199,6 +282,13 @@ static struct ovs_openflow_feature all_openflow_features[] = { .send_request = group_features_send_request, .handle_response = group_features_handle_response, .handle_barrier = default_barrier_response_handle, + }, + { + .value = OVS_SAMPLE_REG_SUPPORT, + .name = "sample_action_with_registers", + .send_request = sample_with_reg_send_request, + .handle_response = sample_with_reg_handle_response, + .handle_barrier = sample_with_reg_handle_barrier, } }; @@ -271,6 +361,7 @@ ovs_feature_is_valid(enum ovs_feature_value feature) case OVS_CT_TUPLE_FLUSH_SUPPORT: case OVS_DP_HASH_L4_SYM_SUPPORT: case OVS_OF_GROUP_SUPPORT: + case OVS_SAMPLE_REG_SUPPORT: return true; default: return false; diff --git a/northd/en-global-config.c b/northd/en-global-config.c index d7607aa074..0ce7f83083 100644 --- a/northd/en-global-config.c +++ b/northd/en-global-config.c @@ -381,6 +381,7 @@ northd_enable_all_features(struct ed_type_global_config *data) .ls_dpg_column = true, .ct_commit_nat_v2 = true, .ct_commit_to_zone = true, + .sample_with_reg = true, }; } @@ -442,6 +443,15 @@ build_chassis_features(const struct sbrec_chassis_table *sbrec_chassis_table, chassis_features->ct_commit_to_zone) { chassis_features->ct_commit_to_zone = false; } + + bool sample_with_reg = + smap_get_bool(&chassis->other_config, + OVN_FEATURE_SAMPLE_WITH_REGISTERS, + false); + if (!sample_with_reg && + chassis_features->sample_with_reg) { + chassis_features->sample_with_reg = false; + } } } diff --git a/northd/en-global-config.h b/northd/en-global-config.h index 8a1c35fc8f..0cf34482af 100644 --- a/northd/en-global-config.h +++ b/northd/en-global-config.h @@ -19,6 +19,7 @@ struct chassis_features { bool ls_dpg_column; bool ct_commit_nat_v2; bool ct_commit_to_zone; + bool sample_with_reg; }; struct global_config_tracked_data {