Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3176407rdb; Thu, 16 Nov 2023 02:17:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IF3I8p9gBTIMF7F+Gfxb53srKvQkhxKzyDiAcNXONR1HtL1zgU6JlY8leMfJQyijd2TSqIJ X-Received: by 2002:a05:6a20:86a1:b0:187:3b1f:219c with SMTP id k33-20020a056a2086a100b001873b1f219cmr4462721pze.10.1700129837660; Thu, 16 Nov 2023 02:17:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700129837; cv=none; d=google.com; s=arc-20160816; b=uwnlkQPYFB6CCU3aWq8Db1uzzlSY5HTP/OYOIf4cqA+XggJQkDp3OZLgCmyBUuwvy2 dIHKCNl3sDayjdSps/nzYsYhLgh3fVohkhtXxzUXwmx7A03BT5saOScAlQH6TbsdPTSK aAYH+Zb50htE4ls2s7MANxxIEimwSpVVOiYfG/CcDHUbiUnGfULnyEvHTukgIKKQ85SS 9/91m9EkT/mVESEVZQrpk0Iw40mBHAlgVLOhA7WEQXZbQxoF3AZIQPMPRVjSgqncbcpn IE4l0mwOqCY0r0MIMDJ9Ycz9G0OnRcuBuhp4hkKcmUjyEv1GdKn0xprEslYwxeJYauUW qXoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RAMaouxCNJj4JYxvNqb1B9tHavh8qlbcHk8v8xuzJ+U=; fh=tGH4ID6V9Zp65T7jsV2DSXAcaNqghZ9ng8Ek7yksGVk=; b=WHWS1teZxyPnGNz0P301AkZAHdlT+6MnqORP4ZSTR6UqqczhbotSWt6G9plEg5Iz2Y TG1pRX+DjGcVNj17V60sfIA8l0Le7VDiLm29NPCH7ARya7XHS8v76E7fokdNyv29xpa8 IznRxy+ojtQFRrIv0PQAgmK3MJzoQsR7Us5xMj0EJvt7Ej3RkRZlkzzIOX4oGjCuOStn YJUorWpdXbG824Jcbgqt497hFILrb6PbDRDPbLbLRwQM3mgpFwI77l+TZbItiZU5UMse bJvwsfhg5oxflq3Sksj++H3mPHnwq0zSqqxT++QcgJGFWlEbc3nueDkj5XifAvV5DIwb 3q5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=AOZAeKKL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id ix19-20020a170902f81300b001cae629cf10si11711531plb.544.2023.11.16.02.17.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 02:17:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=AOZAeKKL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 901538025472; Thu, 16 Nov 2023 02:17:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345019AbjKPKQp (ORCPT + 99 others); Thu, 16 Nov 2023 05:16:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345018AbjKPKQi (ORCPT ); Thu, 16 Nov 2023 05:16:38 -0500 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1BBB1B6; Thu, 16 Nov 2023 02:16:34 -0800 (PST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AG9aZot004530; Thu, 16 Nov 2023 02:16:23 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=RAMaouxCNJj4JYxvNqb1B9tHavh8qlbcHk8v8xuzJ+U=; b=AOZAeKKLwlVpg7LG86wDyR3NFZnpNC9CPj/nAXX7ZKJPrItITdtpEqW+zjPnCJwHzAjl emlZ+X3xAU8HMFq4IJBGog/bu9ZEAoYXyhHMy9UuzZ9bTZALGHmM9rQcKEsLE1eha/Eh 6viXJm0GbH/GjIjW7rtTWwDMT86g+pN/iBqJZTpR2KcATZ0+c/zfmqBPQvIk4eOqituz C/5olf75jK9H+3Ninxp7q90Fu34pHjTVNGpcICDFVzT5ILcZuJDPMnMsJqkafs4h3nWT Djodh5o2eX8iLswot4FBQQGB2cI5joExu2Qz3up1Jz8B9kb/PJdgV6YuDo4ZxcmdIoDN 3g== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3udgkag3fp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 16 Nov 2023 02:16:23 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 16 Nov 2023 02:16:21 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 16 Nov 2023 02:16:21 -0800 Received: from localhost.localdomain (unknown [10.28.36.166]) by maili.marvell.com (Postfix) with ESMTP id DCA4B3F7086; Thu, 16 Nov 2023 02:16:17 -0800 (PST) From: Suman Ghosh To: , , , , , , , , , , , CC: Suman Ghosh Subject: [net-next PATCH 2/2] octeontx2-pf: TC flower offload support for mirror Date: Thu, 16 Nov 2023 15:46:01 +0530 Message-ID: <20231116101601.3188711-3-sumang@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231116101601.3188711-1-sumang@marvell.com> References: <20231116101601.3188711-1-sumang@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: NTRhqrKHMJ3-0V4cFw58eDjboIq2uRDy X-Proofpoint-GUID: NTRhqrKHMJ3-0V4cFw58eDjboIq2uRDy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-16_09,2023-11-15_01,2023-05-22_02 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 16 Nov 2023 02:17:14 -0800 (PST) This patch extends TC flower offload support for mirroring ingress/egress traffic to a different PF/VF. Below is an example command, 'tc filter add dev eth1 ingress protocol ip flower src_ip skip_sw action mirred ingress mirror dev eth2' Signed-off-by: Suman Ghosh --- .../ethernet/marvell/octeontx2/nic/otx2_tc.c | 110 +++++++++++++++++- 1 file changed, 108 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c index 8a5e3987a482..cfcf935b1003 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c @@ -29,6 +29,8 @@ #define OTX2_UNSUPP_LSE_DEPTH GENMASK(6, 4) +#define MCAST_INVALID_GRP (-1U) + struct otx2_tc_flow_stats { u64 bytes; u64 pkts; @@ -47,6 +49,7 @@ struct otx2_tc_flow { bool is_act_police; u32 prio; struct npc_install_flow_req req; + u32 mcast_grp_idx; }; static void otx2_get_egress_burst_cfg(struct otx2_nic *nic, u32 burst, @@ -336,22 +339,95 @@ static int otx2_tc_act_set_police(struct otx2_nic *nic, return rc; } +static int otx2_tc_update_mcast(struct otx2_nic *nic, + struct npc_install_flow_req *req, + struct netlink_ext_ack *extack, + struct otx2_tc_flow *node, + struct nix_mcast_grp_update_req *ureq, + u8 num_intf) +{ + struct nix_mcast_grp_update_req *grp_update_req; + struct nix_mcast_grp_create_req *creq; + struct nix_mcast_grp_create_rsp *crsp; + u32 grp_index; + int rc; + + mutex_lock(&nic->mbox.lock); + creq = otx2_mbox_alloc_msg_nix_mcast_grp_create(&nic->mbox); + if (!creq) { + mutex_unlock(&nic->mbox.lock); + return -ENOMEM; + } + + creq->dir = NIX_MCAST_INGRESS; + /* Send message to AF */ + rc = otx2_sync_mbox_msg(&nic->mbox); + if (rc) { + NL_SET_ERR_MSG_MOD(extack, "Failed to create multicast group"); + mutex_unlock(&nic->mbox.lock); + return rc; + } + + crsp = (struct nix_mcast_grp_create_rsp *)otx2_mbox_get_rsp(&nic->mbox.mbox, + 0, + &creq->hdr); + if (IS_ERR(crsp)) { + mutex_unlock(&nic->mbox.lock); + return PTR_ERR(crsp); + } + + grp_index = crsp->mcast_grp_idx; + grp_update_req = otx2_mbox_alloc_msg_nix_mcast_grp_update(&nic->mbox); + if (!grp_update_req) { + NL_SET_ERR_MSG_MOD(extack, "Failed to update multicast group"); + mutex_unlock(&nic->mbox.lock); + return -ENOMEM; + } + + ureq->op = NIX_MCAST_OP_ADD_ENTRY; + ureq->mcast_grp_idx = grp_index; + ureq->num_mce_entry = num_intf; + ureq->pcifunc[0] = nic->pcifunc; + ureq->channel[0] = nic->hw.tx_chan_base; + + ureq->dest_type[0] = NIX_RX_RSS; + ureq->rq_rss_index[0] = 0; + memcpy(&ureq->hdr, &grp_update_req->hdr, sizeof(struct mbox_msghdr)); + memcpy(grp_update_req, ureq, sizeof(struct nix_mcast_grp_update_req)); + + /* Send message to AF */ + rc = otx2_sync_mbox_msg(&nic->mbox); + if (rc) { + NL_SET_ERR_MSG_MOD(extack, "Failed to update multicast group"); + mutex_unlock(&nic->mbox.lock); + return rc; + } + + mutex_unlock(&nic->mbox.lock); + req->op = NIX_RX_ACTIONOP_MCAST; + req->index = grp_index; + node->mcast_grp_idx = grp_index; + return 0; +} + static int otx2_tc_parse_actions(struct otx2_nic *nic, struct flow_action *flow_action, struct npc_install_flow_req *req, struct flow_cls_offload *f, struct otx2_tc_flow *node) { + struct nix_mcast_grp_update_req dummy_grp_update_req = { 0 }; struct netlink_ext_ack *extack = f->common.extack; + bool pps = false, mcast = false; struct flow_action_entry *act; struct net_device *target; struct otx2_nic *priv; u32 burst, mark = 0; u8 nr_police = 0; - bool pps = false; + u8 num_intf = 1; + int rc, i; u64 rate; int err; - int i; if (!flow_action_has_entries(flow_action)) { NL_SET_ERR_MSG_MOD(extack, "no tc actions specified"); @@ -423,11 +499,30 @@ static int otx2_tc_parse_actions(struct otx2_nic *nic, req->index = act->rx_queue; break; + case FLOW_ACTION_MIRRED_INGRESS: + target = act->dev; + priv = netdev_priv(target); + dummy_grp_update_req.pcifunc[num_intf] = priv->pcifunc; + dummy_grp_update_req.channel[num_intf] = priv->hw.tx_chan_base; + dummy_grp_update_req.dest_type[num_intf] = NIX_RX_RSS; + dummy_grp_update_req.rq_rss_index[num_intf] = 0; + mcast = true; + num_intf++; + break; + default: return -EOPNOTSUPP; } } + if (mcast) { + rc = otx2_tc_update_mcast(nic, req, extack, node, + &dummy_grp_update_req, + num_intf); + if (rc) + return rc; + } + if (nr_police > 1) { NL_SET_ERR_MSG_MOD(extack, "rate limit police offload requires a single action"); @@ -1033,6 +1128,7 @@ static int otx2_tc_del_flow(struct otx2_nic *nic, struct flow_cls_offload *tc_flow_cmd) { struct otx2_flow_config *flow_cfg = nic->flow_cfg; + struct nix_mcast_grp_destroy_req *grp_destroy_req; struct otx2_tc_flow *flow_node; int err; @@ -1064,6 +1160,15 @@ static int otx2_tc_del_flow(struct otx2_nic *nic, mutex_unlock(&nic->mbox.lock); } + /* Remove the multicast/mirror related nodes */ + if (flow_node->mcast_grp_idx != MCAST_INVALID_GRP) { + mutex_lock(&nic->mbox.lock); + grp_destroy_req = otx2_mbox_alloc_msg_nix_mcast_grp_destroy(&nic->mbox); + grp_destroy_req->mcast_grp_idx = flow_node->mcast_grp_idx; + otx2_sync_mbox_msg(&nic->mbox); + mutex_unlock(&nic->mbox.lock); + } + otx2_del_mcam_flow_entry(nic, flow_node->entry, NULL); otx2_tc_update_mcam_table(nic, flow_cfg, flow_node, false); kfree_rcu(flow_node, rcu); @@ -1096,6 +1201,7 @@ static int otx2_tc_add_flow(struct otx2_nic *nic, spin_lock_init(&new_node->lock); new_node->cookie = tc_flow_cmd->cookie; new_node->prio = tc_flow_cmd->common.prio; + new_node->mcast_grp_idx = MCAST_INVALID_GRP; memset(&dummy, 0, sizeof(struct npc_install_flow_req)); -- 2.25.1