Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp1138956lqb; Thu, 18 Apr 2024 00:50:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXrRwZD0IzYV/P7cce9J6YrkCxQuDOb9rcSqoHWYvZZWS4Ua7e0mjOGvLr2qpvhTjsjS/B0FMnxaaTfMRqvCnwI3P/h8sjKrWnMKQQUKQ== X-Google-Smtp-Source: AGHT+IF4/9OX/Z3XjF0o128q7H3tnlnTIZFU0WU0VN2Q+vhQCIjNquqHqjP4K0KL0KpHtoVrkkml X-Received: by 2002:a17:90a:68c5:b0:2ab:5681:3a7c with SMTP id q5-20020a17090a68c500b002ab56813a7cmr1726665pjj.45.1713426614809; Thu, 18 Apr 2024 00:50:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713426614; cv=pass; d=google.com; s=arc-20160816; b=iyq+Wxa4CxfqHw+jgwGo2JsR19QQ3XWaZRS+OPgP9NzRHs1NIQ0J8BsfdoNo6Hp3OO UplKSahN8/XnUoiVIMDrQHObBjfbYO9qY0bN5VvCVa8urMUKhJ9h6PdVdbL30UmhmOfP tMQyqJDOm6Ho6MVu9Ejpe9M0Sg3zh0cenOcZ/82e6OxALriYTqYN/qJp+jD/I684LRes 4XKtu7AnSpeSkmHGycEu6Gvda+eQ/sLiPWWggHfDjyxcvYde/0I996kCRjlNtTD//T70 svlkdWWKBIFIRvnogYG4KGdvj0cs27DRaJPs295qIRPX2udhiDICrc8piTCVMaAxRncx o6SQ== 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=aNH9/aecQTSqqvfzRgM3NwtTSOIx1USupafPCSm99jw=; fh=UQq7t8uvK2iUNO1MW2Ou8S2LAb+LVP9puPAKMbRd+Ns=; b=IvnNOaGJmENq0iCuPraansJ0+xyXljYPeTJAgW8T/7zB4KJcYqSOTTJj/vkQdvNXYz pHNqx6/m9v5fsame8VLPcP2s7E2nW6FDAEVrHrTtWATH5RAhyR6CzL9c42jfH79fgNUe bqw/oBraf21a7EjEMzEZArKwa1QgEB8rF3ZJK6ENETA8gKxfYrkgXQjedobi8Gmo69me vKBt3Bh/Q0AuIkb3dHO00Nr41j/JlV93Fn5+Stev36PZrSiLXKEm7b1fgZOZVBpcxoZ9 JhnpadjGTcGZpLche459DxJ6otbmeskeCqahPxMrjSgUBoMCST1h8WHANhr/AuS3zvIa R8Zg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=XneAXZUF; 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-149675-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149675-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. [139.178.88.99]) by mx.google.com with ESMTPS id e12-20020a17090a77cc00b002a69b8a87d5si1001535pjs.7.2024.04.18.00.50.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 00:50:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-149675-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=XneAXZUF; 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-149675-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149675-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 734C0283CCB for ; Thu, 18 Apr 2024 07:50:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2B07779B96; Thu, 18 Apr 2024 07:49:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="XneAXZUF" Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (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 8B4E97441A; Thu, 18 Apr 2024 07:49:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.153.233 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713426594; cv=none; b=HWWz83y6b0mtQywyB6naHlxfGZoT/rVTWMbhEtZco4r6fV+aGhTWNgTq9Sxpga9HRubfDCBi7OKCidxiT8qJ8imBBUJmrHcs0NUxKGBdZvQN+VwS7RqZRFkXeLIRoZiYs1gfAkz0xwY+VgT7oXDuTxH3JiW8/JQQaybbZlZjezk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713426594; c=relaxed/simple; bh=FRrlT/aY2FgpGFg9r1Iu9ANqmOPu7yBIf9SqSQmObGA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=jyWyNXKMdRnIke0R8sI0x7PysJCljxU/4AEd+HIioCwYml3NX2JSP1pmUr+vuj9ljUsHv962yCbXyXXrIwr49kq334AJ+v3TdMUQk7vaS+PeJrzXFxAqdx3wbQMLgf67fEmP79QHJPy9lxifPRL2XKqzT/eL43qzM9RjSNpwfyY= 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=XneAXZUF; arc=none smtp.client-ip=68.232.153.233 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=1713426592; x=1744962592; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=FRrlT/aY2FgpGFg9r1Iu9ANqmOPu7yBIf9SqSQmObGA=; b=XneAXZUFY5IfngSsKlOJFwBB1BDAVg3Cb2LS3GlFpHTZcXvIIegX8fDq jXqAbfjTRkrc1Em3qsy7A3EXo+rLAZWgLd+walboPgDm4ffts83xpetXw l2dR5wNZNwcVspiQIDcEEcrbSS4mQfEVWEYJNDNzCR67TNJPO71t5+xOQ pWfd5N80YhiuxrcUW2WSDBty3WT/WTCgmF4+ltiyJmX+2JsIfc43iqVZI vY2Hi1DyYixX/NxpHiGnHc3Yv6jTrEnPHSdVMYgqGcCrggvdxFk1/Y9kR 803d8czrceyJuoKgPXvJTbPdgZaE8yCswWGkWf3LhGXalllXTaEbLvkcd g==; X-CSE-ConnectionGUID: DF5lhuK2QDKj8XIcvI9wEw== X-CSE-MsgGUID: YNN3beuRSCqu/F8ftu1gcQ== X-IronPort-AV: E=Sophos;i="6.07,211,1708412400"; d="scan'208";a="252373487" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Apr 2024 00:49:50 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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; Thu, 18 Apr 2024 00:49:44 -0700 Received: from DEN-DL-M70577.microchip.com (10.10.85.11) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Thu, 18 Apr 2024 00:49:40 -0700 From: Daniel Machon Date: Thu, 18 Apr 2024 09:49:03 +0200 Subject: [PATCH net-next 4/5] net: sparx5: add the tc glue to support port mirroring 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: <20240418-port-mirroring-v1-4-e05c35007c55@microchip.com> References: <20240418-port-mirroring-v1-0-e05c35007c55@microchip.com> In-Reply-To: <20240418-port-mirroring-v1-0-e05c35007c55@microchip.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lars Povlsen , "Steen Hegelund" , , Russell King CC: , , , Horatiu Vultur , "Russell King (Oracle)" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Vladimir Oltean , Yue Haibing , Daniel Machon X-Mailer: b4 0.14-dev Add the necessary tc glue to add and delete mirror rules through tc matchall. Signed-off-by: Daniel Machon Reviewed-by: Steen Hegelund --- .../ethernet/microchip/sparx5/sparx5_tc_matchall.c | 36 +++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c index 2a33b347098f..cfd6fcd3d74e 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c @@ -36,6 +36,13 @@ static void sparx5_tc_matchall_parse_action(struct sparx5_port *port, entry->cookie = cookie; } +static void +sparx5_tc_matchall_parse_mirror_action(struct sparx5_mall_entry *entry, + struct flow_action_entry *action) +{ + entry->mirror.port = netdev_priv(action->dev); +} + static int sparx5_tc_matchall_replace(struct net_device *ndev, struct tc_cls_matchall_offload *tmo, bool ingress) @@ -65,6 +72,31 @@ static int sparx5_tc_matchall_replace(struct net_device *ndev, sparx5 = port->sparx5; switch (action->id) { + case FLOW_ACTION_MIRRED: + sparx5_tc_matchall_parse_mirror_action(mall_entry, action); + err = sparx5_mirror_add(mall_entry); + if (err) { + switch (err) { + case -EEXIST: + NL_SET_ERR_MSG_MOD(tmo->common.extack, + "Mirroring already exists"); + break; + case -EINVAL: + NL_SET_ERR_MSG_MOD(tmo->common.extack, + "Cannot mirror a monitor port"); + break; + case -ENOENT: + NL_SET_ERR_MSG_MOD(tmo->common.extack, + "No more mirror probes available"); + break; + default: + NL_SET_ERR_MSG_MOD(tmo->common.extack, + "Unknown error"); + break; + } + return err; + } + break; case FLOW_ACTION_GOTO: err = vcap_enable_lookups(sparx5->vcap_ctrl, ndev, tmo->common.chain_index, @@ -115,7 +147,9 @@ static int sparx5_tc_matchall_destroy(struct net_device *ndev, if (!entry) return -ENOENT; - if (entry->type == FLOW_ACTION_GOTO) { + if (entry->type == FLOW_ACTION_MIRRED) { + sparx5_mirror_del(entry); + } else if (entry->type == FLOW_ACTION_GOTO) { err = vcap_enable_lookups(sparx5->vcap_ctrl, ndev, 0, 0, tmo->cookie, false); } else { -- 2.34.1