From patchwork Wed Apr 3 18:41:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13616596 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CB152CD128A for ; Wed, 3 Apr 2024 18:42:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:CC:To:In-Reply-To:References:Message-ID :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vzvFV4OFpdNZQviYGnRnGloWWGH5lJR5u7OjAkc2PsM=; b=T8BQdNv/a/XJw/ pO80+9eMdWQdu5NyU3NFVNEl5gQzxsoV5D1tDvaX6f5v3a2DzKi/b4pkukVPDXju3FvJr76VPPvg3 ucaQOhXeQLKlaAaycMw4dtQHZs5s3lG2ONU9xw5f3BpyvRns8ZdxG0yu8HqK3S+DHiNgvopRmG39D GjOAANiV0Lf6razjCiImwn7FIrZqlQd6vK1lmYo7YG9S8Va7Oss/R+X4vEpR7YmxNPa9Y+eHbILzK MN1xBa/KrCnEH+KypyWabdL89zDMXPG8Z6rkCpp7A5FdoQX3I2H0VCBjghFFduxboER9BjLhDY0tn /Tm3MkDZRdMMYdDZJvqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs5Z2-0000000HQfp-01cR; Wed, 03 Apr 2024 18:42:24 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs5Yy-0000000HQeH-1bmi for linux-arm-kernel@lists.infradead.org; Wed, 03 Apr 2024 18:42:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1712169740; x=1743705740; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=0BQfTNJh7WCqTooxO5jQh9nq8Nvly6zUvYcfVjQ186M=; b=OrYvNhsG/WF7gk3j4bm7PzhpgS7Tc+dChbgenyRIyy5xQzIeW/1HNj29 vEV7d5JbDyJX6SDmf5i2Hlve3vFLQqtIyGwBF0MgdwFBo6BFoir5G33si IpRndmA1qjMBr0Y7qP/uhdhxzdMAi93r3VuHThEEa7nHnODSelpqB+ESB r5OEmhBGVNkTXznovILXeWABvIaHqGjmwRROE95PLPbAvoOjLHOyphQwB 1DneQtOqYiKh+DebJFsB8iTN6ZXDLQH2OOotYLf+6EJuYGsscvugTnFVD loMO4ZWr8VGW+COe8VDNM7tw0AGqYRkd/+jNy1GztNsxO6ElrVwHzCfyG g==; X-CSE-ConnectionGUID: S7G30frMRjS4zHdERZ8jng== X-CSE-MsgGUID: Gp10ytTDSTaEhG2Ch+jTtQ== X-IronPort-AV: E=Sophos;i="6.07,177,1708412400"; d="scan'208";a="21259577" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 03 Apr 2024 11:42:13 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 3 Apr 2024 11:42:12 -0700 Received: from DEN-DL-M70577.microchip.com (10.10.85.11) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Wed, 3 Apr 2024 11:42:10 -0700 From: Daniel Machon Date: Wed, 3 Apr 2024 20:41:43 +0200 Subject: [PATCH net-next 2/3] net: sparx5: add support for tc flower mirred action. MIME-Version: 1.0 Message-ID: <20240403-mirror-redirect-actions-v1-2-c8e7c8132c89@microchip.com> References: <20240403-mirror-redirect-actions-v1-0-c8e7c8132c89@microchip.com> In-Reply-To: <20240403-mirror-redirect-actions-v1-0-c8e7c8132c89@microchip.com> To: Lars Povlsen , Steen Hegelund , , "David S. Miller" , Eric Dumazet , "Jakub Kicinski" , Paolo Abeni CC: , , , Daniel Machon X-Mailer: b4 0.14-dev X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240403_114220_495763_5B13C879 X-CRM114-Status: GOOD ( 14.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add support for tc flower mirred action. Two VCAP actions are encoded in the rule - one for the port mask, and one for the port mask mode. When the rule is hit, the destination mask is OR'ed with the port mask. Also add helper to set port forwarding mask. Signed-off-by: Daniel Machon --- .../ethernet/microchip/sparx5/sparx5_tc_flower.c | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c index 523e0c470894..a86ce1f8f3e5 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c @@ -1004,6 +1004,44 @@ static int sparx5_tc_action_vlan_push(struct vcap_admin *admin, return err; } +static void sparx5_tc_flower_set_port_mask(struct vcap_u72_action *ports, + struct net_device *ndev) +{ + struct sparx5_port *port = netdev_priv(ndev); + int byidx = port->portno / BITS_PER_BYTE; + int biidx = port->portno % BITS_PER_BYTE; + + ports->value[byidx] |= BIT(biidx); +} + +static int sparx5_tc_action_mirred(struct vcap_admin *admin, + struct vcap_rule *vrule, + struct flow_cls_offload *fco, + struct flow_action_entry *act) +{ + struct vcap_u72_action ports = {0}; + int err; + + if (admin->vtype != VCAP_TYPE_IS0 && admin->vtype != VCAP_TYPE_IS2) { + NL_SET_ERR_MSG_MOD(fco->common.extack, + "Mirror action not supported in this VCAP"); + return -EOPNOTSUPP; + } + + err = vcap_rule_add_action_u32(vrule, VCAP_AF_MASK_MODE, + SPX5_PMM_OR_DSTMASK); + if (err) + return err; + + sparx5_tc_flower_set_port_mask(&ports, act->dev); + + err = vcap_rule_add_action_u72(vrule, VCAP_AF_PORT_MASK, &ports); + if (err) + return err; + + return 0; +} + /* Remove rule keys that may prevent templates from matching a keyset */ static void sparx5_tc_flower_simplify_rule(struct vcap_admin *admin, struct vcap_rule *vrule, @@ -1150,6 +1188,11 @@ static int sparx5_tc_flower_replace(struct net_device *ndev, if (err) goto out; break; + case FLOW_ACTION_MIRRED: + err = sparx5_tc_action_mirred(admin, vrule, fco, act); + if (err) + goto out; + break; case FLOW_ACTION_ACCEPT: err = sparx5_tc_set_actionset(admin, vrule); if (err)