Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp537065lqp; Fri, 5 Apr 2024 00:54:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVatMqsjF6EQq3IUUWxX389eL1/EeQwZrODTkclnDVUNtOedAbrcN+9ytUXEOb3AlxJCHv1hqbu0ohhdKOlpctXiaAQ5Tm0ts/fSL5wsg== X-Google-Smtp-Source: AGHT+IGDVUuHCGVse1ICRNgW31K+c+U2bBKAE//XGC364EHoYBxf69/TUNgIRxhM75Dax3wjIDRC X-Received: by 2002:a05:6a00:2d2a:b0:6ea:9117:bc61 with SMTP id fa42-20020a056a002d2a00b006ea9117bc61mr826218pfb.20.1712303696722; Fri, 05 Apr 2024 00:54:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712303696; cv=pass; d=google.com; s=arc-20160816; b=YgfJuHXGTp2Fu3CFNGLzej3/HJ79WOw7RjX9GKS4310yhlPmgYGKNnnjmcZpWFovcg fF3AgDF1NeCktCu2Xz4MDCKI1hy9/rKTTrEn5vxbZiFClUSD6Q4Px+Jpgzb3AGP+xp6p u1OuQ+5Tn7yew5s1J6ASfLf5bB28ID7Y+UzsNOrQ9OgZObuEQk9cYHuxdf5FaifC++en oDhO9BU1gpKov4xy5zhN9VjGODgQqlZcWNpXW+Bo0QxCew3++/WTLNyRVAMEK7I5YeXw nBm2eRBRAI6HGsIYleXbksVi7SCggB/cWl+/36/wsSVV4aS/yPpE42KE7PrHjg1GvKjp qT0g== 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=CDsjc0JqYzMF/yH+f+ase7VNzdZMITthfBAeisvqL+0=; fh=bY1A21UXyWPKD6+ykc1AVbHouVn5flRfwAjEUy/OkXU=; b=pCnuKOZPSDlEI7pnVlSpjCnCp4kZbaFNaVqm7w64LaYZiaLLLOPnntOoqos0i6Sbl/ SB4aeDTnU+MlfdjRTBLQWSKqC9FXAyhk6BfyROyr4nqImKvBKIpJGDKFd7tm0g7KTKT1 AvDKPhQBi+fkIY4xnoBkcwIPHhSVHZ78xREvRlioiO81d7FpbQgk74QLuwkairVRGpyG SfvCPtdZuGeC6hmDzHSFJNNfX7DJn/7V5HRjebj747+ZyR++ZFuBwm27041QxaTxnHlw mDCeRIXH1N9tcrsC2Ba4NDOFouWHnY4vSyUoxPUxq3pLTLwrWBSR3ZsgSrOgn/96ozA4 YS7Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=KoEFXiK4; 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-132581-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132581-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microchip.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g15-20020aa79dcf000000b006e70670e744si921781pfq.259.2024.04.05.00.54.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 00:54:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132581-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=KoEFXiK4; 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-132581-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132581-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 44F2728649C for ; Fri, 5 Apr 2024 07:45:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5E0CA13DDBE; Fri, 5 Apr 2024 07:45:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="KoEFXiK4" 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 E798113D290; Fri, 5 Apr 2024 07:45:24 +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=1712303127; cv=none; b=RG9WyToNnYzQF/yyzHISGIMHYz1FNscOtFO6GM185gRsYnmQczIBXIQHTrxu3VaHhxUcp+Ic1JPGdgoXCx+xJTixcTXwPqV3BHJaJI5PptTlTUHEDVxwUaxebfV2ImxLkcFHNKZkYiPERdo3AgbI3TltHSZdmHiKjUWiUnc9zGo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712303127; c=relaxed/simple; bh=zxzwPUK588bPOtov+mR5roC3KbeuhPfT1VukrDFUP3s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=pQ7to1nMlYDfpjCCA4qarvxFSnMCqr7Ao86Mm4yExre5miB+CyxCXGa9MdRlJ7Q5U2QzUUrFkFT5QfL6JgpFMexv9cC17H2kpoqIiXEvo3GuQYgaqLO2GWhlMsrMXmELBmfrk0m7Jj2+vx0Ijj8wn0xc3jSxQpdh7NhZ9WebfuY= 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=KoEFXiK4; 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=1712303125; x=1743839125; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=zxzwPUK588bPOtov+mR5roC3KbeuhPfT1VukrDFUP3s=; b=KoEFXiK4uj/Q53yao3jPx9oiBqCEiC1nDHvqCLeYA8AI7Ohv059ohSz9 0eJOS3XayJ+cx+NW2nsVjJmukyxSbKwwhV9+fCz4Z600mibP9lPy5HqkU rt91zaxIvcoUOAPjE/ERKs8yJkJKSXvm8fsKgKT/xnUNHySgIlvD2U6FD 2AcZsTd0JbohY3fPDaKOQxMgqsFtlqpvNLZwzl76RtE//dmdLqxTO1ZLB xjfq11+IXZyUXkaMJcFkAFap8XjTk9/Hr/IVNnTDY4T0/FcF1kYpXcKn4 tbcoqo17PGlLjSw9oqMstAg0qdjA0NuQtLqZJinPgNKq6dhtdHZZsLYRf g==; X-CSE-ConnectionGUID: LnJ8QAI7QrCTf6/TR/LIZQ== X-CSE-MsgGUID: B7RBzzQ/T+KnUHQ14QtQxQ== X-IronPort-AV: E=Sophos;i="6.07,180,1708412400"; d="scan'208";a="19563250" 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:05 -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:03 -0700 From: Daniel Machon Date: Fri, 5 Apr 2024 09:44:49 +0200 Subject: [PATCH net-next v2 1/2] net: sparx5: add support for tc flower mirred 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-1-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 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 new VCAP function for supporting 72-bit wide actions, and a tc helper for setting the port forwarding mask. Signed-off-by: Daniel Machon --- .../ethernet/microchip/sparx5/sparx5_tc_flower.c | 39 ++++++++++++++++++++++ drivers/net/ethernet/microchip/vcap/vcap_api.c | 12 +++++++ .../net/ethernet/microchip/vcap/vcap_api_client.h | 2 ++ 3 files changed, 53 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..fb2e3004183a 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c @@ -1004,6 +1004,40 @@ 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); + + 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, @@ -1150,6 +1184,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) diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api.c b/drivers/net/ethernet/microchip/vcap/vcap_api.c index ef980e4e5bc2..80ae5e1708a6 100644 --- a/drivers/net/ethernet/microchip/vcap/vcap_api.c +++ b/drivers/net/ethernet/microchip/vcap/vcap_api.c @@ -2907,6 +2907,18 @@ int vcap_rule_add_action_u32(struct vcap_rule *rule, } EXPORT_SYMBOL_GPL(vcap_rule_add_action_u32); +/* Add a 72 bit action field with value to the rule */ +int vcap_rule_add_action_u72(struct vcap_rule *rule, + enum vcap_action_field action, + struct vcap_u72_action *fieldval) +{ + struct vcap_client_actionfield_data data; + + memcpy(&data.u72, fieldval, sizeof(data.u72)); + return vcap_rule_add_action(rule, action, VCAP_FIELD_U72, &data); +} +EXPORT_SYMBOL_GPL(vcap_rule_add_action_u72); + static int vcap_read_counter(struct vcap_rule_internal *ri, struct vcap_counter *ctr) { diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api_client.h b/drivers/net/ethernet/microchip/vcap/vcap_api_client.h index 88641508f885..56874f2adbba 100644 --- a/drivers/net/ethernet/microchip/vcap/vcap_api_client.h +++ b/drivers/net/ethernet/microchip/vcap/vcap_api_client.h @@ -200,6 +200,8 @@ int vcap_rule_add_action_bit(struct vcap_rule *rule, enum vcap_action_field action, enum vcap_bit val); int vcap_rule_add_action_u32(struct vcap_rule *rule, enum vcap_action_field action, u32 value); +int vcap_rule_add_action_u72(struct vcap_rule *rule, enum vcap_action_field action, + struct vcap_u72_action *fieldval); /* Get number of rules in a vcap instance lookup chain id range */ int vcap_admin_rule_count(struct vcap_admin *admin, int cid); -- 2.34.1