From patchwork Fri Jan 5 12:02:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geetha sowjanya X-Patchwork-Id: 185375 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6173286dyb; Fri, 5 Jan 2024 04:03:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyifJkDLy1+Vyy7h6fj6/Ra9xkjoqlBhvWWkJw7h/MdomkIwg1zpM2AYjNUDnn0OvVRsDJ X-Received: by 2002:a17:902:e544:b0:1d3:8ed4:dde1 with SMTP id n4-20020a170902e54400b001d38ed4dde1mr1919841plf.3.1704456201557; Fri, 05 Jan 2024 04:03:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704456201; cv=none; d=google.com; s=arc-20160816; b=y+elj5mFhdz0ylu66Ismd0gLLoTEw9AHGdxZr+OJgNsi0qDE5B52ANYwuqlHb2obr5 4H9x2B3IiiDfoW4OCf5HlTg3tMfe/ZUi86XWbf3euWIs+3o/v+UGwMUMDs9Fttm4FAFD QxjmkKBgFDtdW8qYdM0dL3mIhUlzuYo596Yd7iowCUIycDF8qfHQNsuYmbvkYXdOplEc 0UyAUULwZsN3NNZTs/TEpA6u6iLb3WE5ddLaZK9mF6nJlUhGahwbQevdPBaSEzXO7XRd ycYtHFDWw7JQsDZSBJz966hvUhRK0gKgMmXm6P/w6xgmfw2uEiSxD+7+/mmB7DASPKyz o7yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:from:dkim-signature; bh=6sU5GxlK76ndUKi2361U/O6LtYlGS3aaQIWSH2fN1ig=; fh=wPv/fmS7iNNmCH0mdUKjkT6XsNx1nMbXFeqwvq2D6q0=; b=E/2DtLaB0BllhVt005EANjuersXTaQI3XaV68PaXfbFO0wGS1Xd1DSmrF8RlI1nz+7 pf2zpI9+uBogB0sioxwAALnIWTfs4QIPl/DxoVT6gtxthLU2EUfBlICFxWtdw3jxERfs KrtBCHBdA5xU7V0guTmiBwamriC2Yq66FN4UFlpFRg3nbgDDrInVOy1e0ibC1bJWi5g1 iaA29h+Y9EN5I6NtrL9hUqd1lNKQ+slPu2CQthXxfJ61p/jxOJQgYSIXEPoUEBv3nnOX BLU3nSf2emeqtaWya4e7LkkkF1l7EHSaay3axUU79t0mVfwfoISqJ+RkXfbrU/Is2r0U oKrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=TMpxx2RU; spf=pass (google.com: domain of linux-kernel+bounces-17822-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17822-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id cp9-20020a17090afb8900b0028c4b8d56e5si733562pjb.2.2024.01.05.04.03.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 04:03:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17822-ouuuleilei=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=@marvell.com header.s=pfpt0220 header.b=TMpxx2RU; spf=pass (google.com: domain of linux-kernel+bounces-17822-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17822-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.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 2769C285AA0 for ; Fri, 5 Jan 2024 12:03:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 414EB2D610; Fri, 5 Jan 2024 12:03:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="TMpxx2RU" X-Original-To: linux-kernel@vger.kernel.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (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 09A9E2D601; Fri, 5 Jan 2024 12:03:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 4054bI95004588; Fri, 5 Jan 2024 04:02:54 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= from:to:cc:subject:date:message-id:mime-version:content-type; s= pfpt0220; bh=6sU5GxlK76ndUKi2361U/O6LtYlGS3aaQIWSH2fN1ig=; b=TMp xx2RUTpG/hU58asUNkoyajWsG/kYsnkEKwzXwi7d0tUsvV0nNPBiMnjJWHBKqJRz Ucx51DqudNvCQYJbupawk94q2zZxv42t8MtCxCcAy9JKmQaaU/Ft4x5AHdtXEsEy JrBln33aCVzfk6g3+4ii/bss4O2ZoZo8x+cDysyg1E8sfKyRWwPuIvDbob0Z/f1g leidiNZt1pYr5OWRUh/DxyNs9pnUjh/dj1n/rPdkxMsoy83NoBNc6fmMrNQSM8Xm aHBWUKE9MQWJ+dBOig/BOPRF0sW/67fUr8y9GfPVkPUo9Sl/1i/mnO7pYwi1R3Dj L/PgOboyyxbwlJYXvfg== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3veaw014hx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 05 Jan 2024 04:02:53 -0800 (PST) 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; Fri, 5 Jan 2024 04:02:51 -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; Fri, 5 Jan 2024 04:02:51 -0800 Received: from hyd1soter3.marvell.com (unknown [10.29.37.12]) by maili.marvell.com (Postfix) with ESMTP id 861A83F7091; Fri, 5 Jan 2024 04:02:48 -0800 (PST) From: Geetha sowjanya To: , CC: , , , , , , , Subject: [net-next PATCH] octeontx2-pf: Add support for offload tc with skbedit mark action Date: Fri, 5 Jan 2024 17:32:47 +0530 Message-ID: <20240105120247.14975-1-gakula@marvell.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: gXxI_aJTxv4kpC8oPZBqBj0QfnQQsdea X-Proofpoint-ORIG-GUID: gXxI_aJTxv4kpC8oPZBqBj0QfnQQsdea X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_02,2023-12-07_01,2023-05-22_02 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787251866004179348 X-GMAIL-MSGID: 1787251866004179348 Support offloading of skbedit mark action. For example, to mark with 0x0008, with dest ip 60.60.60.2 on eth2 interface: # tc qdisc add dev eth2 ingress # tc filter add dev eth2 ingress protocol ip flower \ dst_ip 60.60.60.2 action skbedit mark 0x0008 skip_sw Signed-off-by: Geetha sowjanya --- .../net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c | 2 ++ .../ethernet/marvell/octeontx2/nic/otx2_common.h | 2 ++ .../net/ethernet/marvell/octeontx2/nic/otx2_tc.c | 13 +++++++++++++ .../net/ethernet/marvell/octeontx2/nic/otx2_txrx.c | 3 +++ .../net/ethernet/marvell/octeontx2/nic/otx2_txrx.h | 3 +++ 5 files changed, 23 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c index c75669c8fde7..6188921e9a20 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c @@ -1183,6 +1183,8 @@ static int npc_update_rx_entry(struct rvu *rvu, struct rvu_pfvf *pfvf, action.pf_func = target; action.op = NIX_RX_ACTIONOP_UCAST; } + if (req->match_id) + action.match_id = req->match_id; } entry->action = *(u64 *)&action; diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h index 06910307085e..815ae13c371c 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h @@ -363,6 +363,7 @@ struct otx2_flow_config { struct list_head flow_list; u32 dmacflt_max_flows; u16 max_flows; + u16 mark_flows; struct list_head flow_list_tc; bool ntuple; }; @@ -465,6 +466,7 @@ struct otx2_nic { #define OTX2_FLAG_DMACFLTR_SUPPORT BIT_ULL(14) #define OTX2_FLAG_PTP_ONESTEP_SYNC BIT_ULL(15) #define OTX2_FLAG_ADPTV_INT_COAL_ENABLED BIT_ULL(16) +#define OTX2_FLAG_TC_MARK_ENABLED BIT_ULL(17) u64 flags; u64 *cq_op_addr; diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c index 4fd44b6eecea..fd1d78601811 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c @@ -511,7 +511,15 @@ static int otx2_tc_parse_actions(struct otx2_nic *nic, nr_police++; break; case FLOW_ACTION_MARK: + if (act->mark & ~OTX2_RX_MATCH_ID_MASK) { + NL_SET_ERR_MSG_MOD(extack, "Bad flow mark, only 16 bit supported"); + return -EOPNOTSUPP; + } mark = act->mark; + req->match_id = mark & 0xFFFFULL; + req->op = NIX_RX_ACTION_DEFAULT; + nic->flags |= OTX2_FLAG_TC_MARK_ENABLED; + nic->flow_cfg->mark_flows++; break; case FLOW_ACTION_RX_QUEUE_MAPPING: @@ -1173,6 +1181,11 @@ static int otx2_tc_del_flow(struct otx2_nic *nic, return -EINVAL; } + /* Disable TC MARK flag if they are no rules with skbedit mark action */ + if (flow_node->req.match_id) + if (!(--flow_cfg->mark_flows)) + nic->flags &= ~OTX2_FLAG_TC_MARK_ENABLED; + if (flow_node->is_act_police) { __clear_bit(flow_node->rq, &nic->rq_bmap); diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c index 4d519ea833b2..d3c9759c9f06 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c @@ -380,6 +380,9 @@ static void otx2_rcv_pkt_handler(struct otx2_nic *pfvf, if (pfvf->netdev->features & NETIF_F_RXCSUM) skb->ip_summed = CHECKSUM_UNNECESSARY; + if (pfvf->flags & OTX2_FLAG_TC_MARK_ENABLED) + skb->mark = parse->match_id; + skb_mark_for_recycle(skb); napi_gro_frags(napi); diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h index a82ffca8ce1b..3f1d2655ff77 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h @@ -62,6 +62,9 @@ #define CQ_OP_STAT_OP_ERR 63 #define CQ_OP_STAT_CQ_ERR 46 +/* Packet mark mask */ +#define OTX2_RX_MATCH_ID_MASK 0x0000ffff + struct queue_stats { u64 bytes; u64 pkts;