Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp534013lqp; Fri, 5 Apr 2024 00:46:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXa5Mke81P+/mZCjzR22PGDsE3lnDtDuAlqGHqR5eA8SY+hs7hfmV6S4DffwX7xomuq4cUL7Ke8Szv+fMKF2Er1cnoSRNa3fXsUS1kT4A== X-Google-Smtp-Source: AGHT+IHgFkLUlmexKShGpR4/3ufvfM+M5pgZjkQUsEbqL4swMWMfX+gVrbHPBes/hC2pSqzoCp18 X-Received: by 2002:a05:622a:44f:b0:432:d0b9:f257 with SMTP id o15-20020a05622a044f00b00432d0b9f257mr755867qtx.22.1712303169694; Fri, 05 Apr 2024 00:46:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712303169; cv=pass; d=google.com; s=arc-20160816; b=CZZLWP1xyHU4aqgRvNONJ15+oTzKA3t+s1kE+r7ylGYgvOv+BnZcc39dgrYVwG54bF 4KU05UUg5EYt885fEew6RWZdL3kT336nnnA9HDs9jl2zGckH/gNTZ5WtrJF1ldKrv7dN 4jrxEs4LrO8nSoWTuy7bxmupDLGfi55tjOSJtcT4yjhWEsV9BtQ8BbyR47RqzxoB7GEB dm/dn3yyP90I4EObZHFjR2F2eFNYN+tJkCVvk0UqF7ON/A1FhUeOrHP3I557WgIExMRZ 02nImi02p6W5YcOFv9UIAsULBTOCNvM3fRdzCORzBVWlY/0dUguxRGXhQhZKJR6Eoij7 3fEw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=oKrbLN1CC96KJTF71vr2fL2FR3QQJNTY5gn+okydJac=; fh=bY1A21UXyWPKD6+ykc1AVbHouVn5flRfwAjEUy/OkXU=; b=P6ZlTPbMKeATOcgH6hzF8CsxqJJ5PBJLxmGGddW6cauLqHpG93zr4XkbhLX9aXKd8e DRbBI6TlLBML/JqFTJO/dbZrYi5NwP1/JRMX5V1xpoRgDRVPKx0R1bTFKIa4Qdy2IMst X6SYqXcviBQ55s8o6mNgSdpspy7Zv/dN/kC1sx+uQie+lZij02kCaEg/al728ri7sgdV 8IqcGWp/iblpA9qflMAB7fwNN4T706MCdnHGOUKVTdut7+e/z5evxGn12hnKFv+Gj/B2 kPHybn3785SEs/kn5w8nTjK+XI6/tiBOdvCi3diNxky61GLhjtluTbvezIRvthg/AVDW z6RQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=CfAs1bOw; arc=pass (i=1 spf=pass spfdomain=microchip.com dkim=pass dkdomain=microchip.com dmarc=pass fromdomain=microchip.com); spf=pass (google.com: domain of linux-kernel+bounces-132582-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132582-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microchip.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c11-20020ac87dcb000000b0043461c89793si335117qte.116.2024.04.05.00.46.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 00:46:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132582-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=CfAs1bOw; arc=pass (i=1 spf=pass spfdomain=microchip.com dkim=pass dkdomain=microchip.com dmarc=pass fromdomain=microchip.com); spf=pass (google.com: domain of linux-kernel+bounces-132582-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132582-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microchip.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6D2621C21607 for ; Fri, 5 Apr 2024 07:46:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5CED013E3E7; Fri, 5 Apr 2024 07:45:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="CfAs1bOw" Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82E1913D53E; Fri, 5 Apr 2024 07:45:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.154.123 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712303129; cv=none; b=bdzO4ioqH+kZG3SHkjqIAUnpvjJzsZw8qTIY5+4BWZnzy3ldGNO1LRA+aHAfJxJbW0rDl/BXC4YAI20Tgdxot8avCcrzpoGEKnVC8WOmdj2rs3zzCmkWZkVEth9n791MxpKRfbeFt7uJje9yQKXy6ZLmvKfVvQFX2nEcV/PMngI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712303129; c=relaxed/simple; bh=hG/7WXbVHwPtjqKBcDc2XwtEgfdfo2i1v9NTvMXhAsY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=fRj0KIyz4EsEQIsusuZSWzTZ0xDNvHSUM8Msv5rCBn8aQ1X0/JR5rFC9sJjTwLGNfaawYrYQ69WhbnFGpqSTuDlULJP38U43Yb16TcLdIT21YrPNWwwC/Fo1TNZt9ZSF79uSQiozeNYY5d83t+wanGKtFsrvfTNMTGY8thSCU+U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b=CfAs1bOw; arc=none smtp.client-ip=68.232.154.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1712303127; x=1743839127; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=hG/7WXbVHwPtjqKBcDc2XwtEgfdfo2i1v9NTvMXhAsY=; b=CfAs1bOwTvtWL6AhDM1wS947iswdOUYniVJ6Gap59lTvdAkP+ALKJaaJ wD/RsfKB30Jvmglr+3VCBzZqzERKlfSXaDbLGMSYaKvHZSUpDgCjL6LFT cc/gSbaaN/CNHrMBIK1LY4aWBbTDBs91Wd3sEW9cvA7JxS4TsVN05+N4O Bksk147FakfRU5zXLZkVlSujgIiw0r8jT7xavelgm5XLLs/4FB2lf/VR+ D+YtGOABkD3VF2YYAmKh9uw/fRSknzZdYM8CZRAxq/X25B+pnv7nx1rq3 3VHYh7xz7xC/m/WKVJmMmKF4S3gt3Xq9UMEH4loH5J8PZWxMIzedfGC6F A==; X-CSE-ConnectionGUID: LnJ8QAI7QrCTf6/TR/LIZQ== X-CSE-MsgGUID: zx1E/0f7Tt+Tn7q5T9/slQ== X-IronPort-AV: E=Sophos;i="6.07,180,1708412400"; d="scan'208";a="19563251" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 05 Apr 2024 00:45:23 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 5 Apr 2024 00:45:08 -0700 Received: from DEN-DL-M70577.microchip.com (10.10.85.11) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Fri, 5 Apr 2024 00:45:06 -0700 From: Daniel Machon Date: Fri, 5 Apr 2024 09:44:50 +0200 Subject: [PATCH net-next v2 2/2] net: sparx5: add support for tc flower redirect action Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20240405-mirror-redirect-actions-v2-2-875d4c1927c8@microchip.com> References: <20240405-mirror-redirect-actions-v2-0-875d4c1927c8@microchip.com> In-Reply-To: <20240405-mirror-redirect-actions-v2-0-875d4c1927c8@microchip.com> To: Lars Povlsen , Steen Hegelund , , "David S. Miller" , Eric Dumazet , "Jakub Kicinski" , Paolo Abeni CC: Ratheesh Kannoth , , , , Daniel Machon X-Mailer: b4 0.14-dev Add support for the flower redirect 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 port mask is used as the final destination set, replacing all other port masks. Signed-off-by: Daniel Machon --- .../ethernet/microchip/sparx5/sparx5_tc_flower.c | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c index fb2e3004183a..82dd270adae6 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c @@ -1038,6 +1038,30 @@ static int sparx5_tc_action_mirred(struct vcap_admin *admin, return vcap_rule_add_action_u72(vrule, VCAP_AF_PORT_MASK, &ports); } +static int sparx5_tc_action_redirect(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, + "Redirect action not supported in this VCAP"); + return -EOPNOTSUPP; + } + + err = vcap_rule_add_action_u32(vrule, VCAP_AF_MASK_MODE, + SPX5_PMM_REPLACE_ALL); + if (err) + return err; + + sparx5_tc_flower_set_port_mask(&ports, act->dev); + + return vcap_rule_add_action_u72(vrule, VCAP_AF_PORT_MASK, &ports); +} + /* 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, @@ -1189,6 +1213,11 @@ static int sparx5_tc_flower_replace(struct net_device *ndev, if (err) goto out; break; + case FLOW_ACTION_REDIRECT: + err = sparx5_tc_action_redirect(admin, vrule, fco, act); + if (err) + goto out; + break; case FLOW_ACTION_ACCEPT: err = sparx5_tc_set_actionset(admin, vrule); if (err) -- 2.34.1