From patchwork Tue Jul 30 13:37:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1138983 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 45yd7y6xwPz9sML for ; Tue, 30 Jul 2019 23:44:14 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id F1EA92CDB; Tue, 30 Jul 2019 13:43:36 +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 E99AB2CAB for ; Tue, 30 Jul 2019 13:37:49 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id DF19EA8 for ; Tue, 30 Jul 2019 13:37:47 +0000 (UTC) Received: by mail-wr1-f50.google.com with SMTP id n4so65901317wrs.3 for ; Tue, 30 Jul 2019 06:37:47 -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=/g1UzqV0SGnmtJ/zPhaKTIwk335XEuV9mt8O+Wb/Y+0=; b=JPKHVNpt6jmLQLZOk8qk3fE843xaR1S9yXFDMfmUaGpKavcNui4+3WfuHqgZFHiYK6 P7CwQkDst1D7FgwIx/UawLHpROLtBtO/T67JRWZgcKp3aL80nMZAKe1t5tJE+Fc26KS2 D1UIs3ZHNZMdZU4GvzrPX7HMbySptWqi+CGo63coQwCjU6rctQ3v3qCxeVsrOi01SaFS 1GhCLhYkdDgt5cI1FV2UbTSPClP502wpWDlLbMyoZ8DF/QVM1FhK+bXus0oLBnGiQt57 EoOf0Br4PM3cj545c6M9eoJgOnLNH7ShWYrYABv7NdOAY5U6fy2MBfWzJkd9UhwvsF85 3mDw== X-Gm-Message-State: APjAAAXOCxD234pbpi3mq8pkAdQdSPXwLcd8f5bU+sEb/LGCeMzNR5DV rQEdMDk24d+TLIKn0AWuzTaSTKHth4k= X-Google-Smtp-Source: APXvYqwK8sGGUzP6jejhgtGfsUV1tfwNEwmuHx9Sj3/hAxq8zJtwz052Cl4WaWdrLb5+N/3mQT5kAQ== X-Received: by 2002:adf:90e7:: with SMTP id i94mr93752432wri.224.1564493866306; Tue, 30 Jul 2019 06:37:46 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id f7sm63928090wrv.38.2019.07.30.06.37.45 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 30 Jul 2019 06:37:45 -0700 (PDT) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Tue, 30 Jul 2019 15:37:36 +0200 Message-Id: <25f5233f9e0b6cfe61074c7e0ae9ef07dc6c6133.1564493246.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=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE 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 1/2] OVN: add meter support to trigger_event action 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 Introduce meter support to trigger_event action in order to not overload pinctrl thread under heavy load Signed-off-by: Lorenzo Bianconi --- include/ovn/actions.h | 1 + ovn/lib/actions.c | 42 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/include/ovn/actions.h b/include/ovn/actions.h index 63d3907d8..1f2ac2eb2 100644 --- a/include/ovn/actions.h +++ b/include/ovn/actions.h @@ -326,6 +326,7 @@ struct ovnact_controller_event { int event_type; /* controller event type */ struct ovnact_gen_option *options; size_t n_options; + char *meter; }; /* Internal use by the helpers below. */ diff --git a/ovn/lib/actions.c b/ovn/lib/actions.c index 4eacc44ed..2e321d82e 100644 --- a/ovn/lib/actions.c +++ b/ovn/lib/actions.c @@ -1273,6 +1273,9 @@ format_TRIGGER_EVENT(const struct ovnact_controller_event *event, { ds_put_format(s, "trigger_event(event = \"%s\"", event_to_string(event->event_type)); + if (event->meter) { + ds_put_format(s, ", meter = \"%s\"", event->meter); + } for (const struct ovnact_gen_option *o = event->options; o < &event->options[event->n_options]; o++) { ds_put_cstr(s, ", "); @@ -1420,10 +1423,21 @@ encode_TRIGGER_EVENT(const struct ovnact_controller_event *event, const struct ovnact_encode_params *ep OVS_UNUSED, struct ofpbuf *ofpacts) { + uint32_t meter_id = NX_CTLR_NO_METER; size_t oc_offset; + if (event->meter) { + meter_id = ovn_extend_table_assign_id(ep->meter_table, event->meter, + ep->lflow_uuid); + if (meter_id == EXT_TABLE_ID_INVALID) { + VLOG_WARN("Unable to assign id for trigger meter: %s", + event->meter); + return; + } + } + oc_offset = encode_start_controller_op(ACTION_OPCODE_EVENT, false, - NX_CTLR_NO_METER, ofpacts); + meter_id, ofpacts); ovs_be32 ofs = htonl(event->event_type); ofpbuf_put(ofpacts, &ofs, sizeof ofs); @@ -1738,11 +1752,27 @@ parse_trigger_event(struct action_context *ctx, sizeof *event->options); } - struct ovnact_gen_option *o = &event->options[event->n_options++]; - memset(o, 0, sizeof *o); - parse_gen_opt(ctx, o, - &ctx->pp->controller_event_opts->event_opts[event_type], - event_to_string(event_type)); + if (lexer_match_id(ctx->lexer, "meter")) { + if (!lexer_force_match(ctx->lexer, LEX_T_EQUALS)) { + return; + } + /* If multiple meters are given, use the most recent. */ + if (ctx->lexer->token.type == LEX_T_STRING && + strlen(ctx->lexer->token.s)) { + free(event->meter); + event->meter = xstrdup(ctx->lexer->token.s); + } else if (ctx->lexer->token.type != LEX_T_STRING) { + lexer_syntax_error(ctx->lexer, "expecting string"); + return; + } + lexer_get(ctx->lexer); + } else { + struct ovnact_gen_option *o = &event->options[event->n_options++]; + memset(o, 0, sizeof *o); + parse_gen_opt(ctx, o, + &ctx->pp->controller_event_opts->event_opts[event_type], + event_to_string(event_type)); + } if (ctx->lexer->error) { return; }