From patchwork Mon Apr 27 15:13:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 220478 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F8CEC5519A for ; Mon, 27 Apr 2020 15:14:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC1E3206BF for ; Mon, 27 Apr 2020 15:14:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="X/Zs57gx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728203AbgD0PNu (ORCPT ); Mon, 27 Apr 2020 11:13:50 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:52485 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728038AbgD0PNo (ORCPT ); Mon, 27 Apr 2020 11:13:44 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 645765C0098; Mon, 27 Apr 2020 11:13:43 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 27 Apr 2020 11:13:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=5IR4joumjEh1RF98nrq9DDJMFQOVlKaPyV0y+HkktxY=; b=X/Zs57gx xevjqy5QGF8npmX6O4SG8fUVx3pmqhEgYscDKlASprYEmpshsuBfINhavkAWlHzY CTZk22VjEnU49KRXR5kA9cIhHvpzVEKcDzb9oqt8pU07rPTdfjAmzw+04iRB6zlw R0PC7BOkpqswHG2EgHd8/NZkexVCBN3v7WPcRq9LVK/bgxwm9gKh7f/W+Yd7vdAi e4fXvPMSnccIztxsnCBEo2z9szDmWjIJSDxpipKZOdy26aovugj4BcvnHX3OIpO0 DMsq22AyKpcYYuDtuk+1iv3omdOIAmGWJF3cmPJj6VaSo5r5E/+mpwiAN6Ga8QYt tqodgRXxG53Iug== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrheelgdekgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpefkughoucfutghhihhmmhgvlhcuoehiughoshgthhesihguohhs tghhrdhorhhgqeenucfkphepjeelrddukedtrdehgedrudduieenucevlhhushhtvghruf hiiigvpeejnecurfgrrhgrmhepmhgrihhlfhhrohhmpehiughoshgthhesihguohhstghh rdhorhhg X-ME-Proxy: Received: from splinter.mtl.com (bzq-79-180-54-116.red.bezeqint.net [79.180.54.116]) by mail.messagingengine.com (Postfix) with ESMTPA id 228C73280059; Mon, 27 Apr 2020 11:13:41 -0400 (EDT) From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, jiri@mellanox.com, mlxsw@mellanox.com, Ido Schimmel Subject: [PATCH net-next 09/13] mlxsw: spectrum_matchall: Push per-port rule add/del into separate functions Date: Mon, 27 Apr 2020 18:13:06 +0300 Message-Id: <20200427151310.3950411-10-idosch@idosch.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200427151310.3950411-1-idosch@idosch.org> References: <20200427151310.3950411-1-idosch@idosch.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jiri Pirko As the replace/destroy is going to be used later on per-block, push the per-port rule addition/deletion into separate functions. Signed-off-by: Jiri Pirko Signed-off-by: Ido Schimmel --- .../mellanox/mlxsw/spectrum_matchall.c | 48 ++++++++++++++----- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_matchall.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_matchall.c index c05e28971d06..41301027a47c 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_matchall.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_matchall.c @@ -123,6 +123,37 @@ mlxsw_sp_mall_port_sample_del(struct mlxsw_sp_port *mlxsw_sp_port) RCU_INIT_POINTER(mlxsw_sp_port->sample->psample_group, NULL); } +static int +mlxsw_sp_mall_port_rule_add(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_mall_entry *mall_entry) +{ + switch (mall_entry->type) { + case MLXSW_SP_MALL_ACTION_TYPE_MIRROR: + return mlxsw_sp_mall_port_mirror_add(mlxsw_sp_port, mall_entry); + case MLXSW_SP_MALL_ACTION_TYPE_SAMPLE: + return mlxsw_sp_mall_port_sample_add(mlxsw_sp_port, mall_entry); + default: + WARN_ON(1); + return -EINVAL; + } +} + +static void +mlxsw_sp_mall_port_rule_del(struct mlxsw_sp_port *mlxsw_sp_port, + struct mlxsw_sp_mall_entry *mall_entry) +{ + switch (mall_entry->type) { + case MLXSW_SP_MALL_ACTION_TYPE_MIRROR: + mlxsw_sp_mall_port_mirror_del(mlxsw_sp_port, mall_entry); + break; + case MLXSW_SP_MALL_ACTION_TYPE_SAMPLE: + mlxsw_sp_mall_port_sample_del(mlxsw_sp_port); + break; + default: + WARN_ON(1); + } +} + int mlxsw_sp_mall_replace(struct mlxsw_sp_port *mlxsw_sp_port, struct tc_cls_matchall_offload *f, bool ingress) { @@ -147,7 +178,6 @@ int mlxsw_sp_mall_replace(struct mlxsw_sp_port *mlxsw_sp_port, if (act->id == FLOW_ACTION_MIRRED && protocol == htons(ETH_P_ALL)) { mall_entry->type = MLXSW_SP_MALL_ACTION_TYPE_MIRROR; mall_entry->mirror.to_dev = act->dev; - err = mlxsw_sp_mall_port_mirror_add(mlxsw_sp_port, mall_entry); } else if (act->id == FLOW_ACTION_SAMPLE && protocol == htons(ETH_P_ALL)) { if (act->sample.rate > MLXSW_REG_MPSC_RATE_MAX) { @@ -160,11 +190,12 @@ int mlxsw_sp_mall_replace(struct mlxsw_sp_port *mlxsw_sp_port, mall_entry->sample.truncate = act->sample.truncate; mall_entry->sample.trunc_size = act->sample.trunc_size; mall_entry->sample.rate = act->sample.rate; - err = mlxsw_sp_mall_port_sample_add(mlxsw_sp_port, mall_entry); } else { err = -EOPNOTSUPP; + goto errout; } + err = mlxsw_sp_mall_port_rule_add(mlxsw_sp_port, mall_entry); if (err) goto errout; @@ -186,18 +217,9 @@ void mlxsw_sp_mall_destroy(struct mlxsw_sp_port *mlxsw_sp_port, netdev_dbg(mlxsw_sp_port->dev, "tc entry not found on port\n"); return; } - list_del(&mall_entry->list); - switch (mall_entry->type) { - case MLXSW_SP_MALL_ACTION_TYPE_MIRROR: - mlxsw_sp_mall_port_mirror_del(mlxsw_sp_port, mall_entry); - break; - case MLXSW_SP_MALL_ACTION_TYPE_SAMPLE: - mlxsw_sp_mall_port_sample_del(mlxsw_sp_port); - break; - default: - WARN_ON(1); - } + mlxsw_sp_mall_port_rule_del(mlxsw_sp_port, mall_entry); + list_del(&mall_entry->list); kfree(mall_entry); }