From patchwork Fri Oct 20 06:11:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hariprasad Kelam X-Patchwork-Id: 155820 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp854254vqb; Thu, 19 Oct 2023 23:12:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG8J0WVZsnPZ0sbfGaonePieTEI127X338ezl5LtdNmqyPw7SeLxtbG/ky7FMdRVpMbNRsg X-Received: by 2002:a17:90b:a16:b0:27d:9bef:1454 with SMTP id gg22-20020a17090b0a1600b0027d9bef1454mr939668pjb.22.1697782357408; Thu, 19 Oct 2023 23:12:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697782357; cv=none; d=google.com; s=arc-20160816; b=BZ4CDumTHyNA/0pWyt1VGrF6OO0HlbzNUr0raknvy6lVb1prbvQ1vtJ+Cp2JMNgZBJ oU/cVua8d0fW2RMZXZlxjCx8twPh1sy5uufKSlgv9p291YNjh3E9jx75RBjMMyk0x2Xp O/wZ3Z02ECg6cScJ3YDOgrOT/05G1kAP344ruQ5ofqRUciaS74lCBXsr6RfLhYHIbtfC dEOdKHjiRL+Pgnkd/jbBwAU3R0lF33X/6kiB8BlyE0Y6iv53oMKoCj63A3pPSN+DkQNS ByYsEuJdAeXyLgATefQ4SndoaTnDBK0AVxKDge+igkLDJHBavshZWtwbdQM0D222dX3r ZTgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=EQjAtqEaP066La5weIlGTbOUZJDIZWwln/W4BSKAO5k=; fh=uTdO95Fpsp9lwoxi6yWojY7bRJXLgWL+oekYfBnZbcI=; b=Az7dLqB2Kj629WVr+mVU0fVKRo6ZYlb2kQ9CNWnXmIcftT/xQ7UKOHIZYDfokTh1CH EUA164W9iaRv0/XmHi6uQataozXwZd/LNAAW4jblc2KQaiXkwv+RQy9b6J/heGWZOrDm dqlh0KZyqYLGuJ36ZsduAQqilnuFmtcR0ybc4pgo7s5TcDNuexLyiJGD2OPx+Kn+E5DF KK5SJ9VLIbXqpxImKx9r8ldab38BGvy2nZF6NH3qEvGzm1XZ2KjGikk30KBiNZ+vfoqa UKBtBvgL3Ej8v/xNISrcqOlZkptqHHR+RV3aubEp8304iGiPGjbVm6mndIT5eB/ybkek w+CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=Fa6Ict4D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id x9-20020a17090a970900b0027cf8287c5csi3793827pjo.62.2023.10.19.23.12.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 23:12:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=Fa6Ict4D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 9776E8217EF3; Thu, 19 Oct 2023 23:12:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376275AbjJTGMS (ORCPT + 25 others); Fri, 20 Oct 2023 02:12:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345092AbjJTGMQ (ORCPT ); Fri, 20 Oct 2023 02:12:16 -0400 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09ABBD46; Thu, 19 Oct 2023 23:12:13 -0700 (PDT) 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 39JKtMDt007953; Thu, 19 Oct 2023 23:12:05 -0700 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=EQjAtqEaP066La5weIlGTbOUZJDIZWwln/W4BSKAO5k=; b=Fa6Ict4DSU1EY7tIs6g38ZFi9WN4SCo7mapKARh3OvsEZauC1sm2E7dmx/8PSFUhO9iU YmsaiWMNUncAmfyWkCp9V8364q9EJPqzUh+e2uPlIUpe8jU8MoVRwoZSGHbn8xiOw4WQ hXxIcY58lnWQ0IBAwfq6L5vVpakzDkuAJvRjtWDgr38XlU7qKemVg7ywZcajKbyfWQsg TW20s9huVb/1R4CWSUAEcUlT0fZH3Nd0YI6p7aR71HdJf8IlU7ditoX6K1ZtnrZTmYPg rpRJI1mJ0NieNEq2GWRoWn7KbxHfqCYM8L4Mb+A5LNrelye8y3TLsEWevPmfi/6O3S4J Aw== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3tubwr9d6j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 19 Oct 2023 23:12:04 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 19 Oct 2023 23:12:02 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 19 Oct 2023 23:12:02 -0700 Received: from hyd1soter3.marvell.com (unknown [10.29.37.12]) by maili.marvell.com (Postfix) with ESMTP id 447DD5B6927; Thu, 19 Oct 2023 23:11:59 -0700 (PDT) From: Hariprasad Kelam To: , CC: , , , , , , , Subject: [net-next] net: sched: extend flow action with RSS Date: Fri, 20 Oct 2023 11:41:58 +0530 Message-ID: <20231020061158.6716-1-hkelam@marvell.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Proofpoint-GUID: jc9XbweygQI-dFk6Bq06GP_wGXnU5ISw X-Proofpoint-ORIG-GUID: jc9XbweygQI-dFk6Bq06GP_wGXnU5ISw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-20_04,2023-10-19_01,2023-05-22_02 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Thu, 19 Oct 2023 23:12:26 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780253833089199196 X-GMAIL-MSGID: 1780253833089199196 This patch extends current flow action with RSS, such that the user can install flower offloads with action RSS followed by a group id. Since this is done in hardware skip_sw flag is enforced. Example: In a multi rss group supported NIC, rss group #1 flow hash indirection table populated with rx queues 1 to 4 rss group #2 flow hash indirection table populated with rx queues 5 to 9 $tc filter add dev eth1 ingress protocol ip flower ip_proto tcp dst_port 443 action skbedit rss_group 1 skip_sw Packets destined to tcp port 443 will be distributed among rx queues 1 to 4 $tc filter add dev eth1 ingress protocol ip flower ip_proto udp dst_port 8080 action skbedit rss_group 2 skip_sw Packets destined to udp port 8080 will be distributed among rx queues 5 to 9 Signed-off-by: Hariprasad Kelam --- include/net/flow_offload.h | 2 ++ include/net/tc_act/tc_skbedit.h | 18 ++++++++++++++++++ include/uapi/linux/tc_act/tc_skbedit.h | 2 ++ net/sched/act_skbedit.c | 26 +++++++++++++++++++++++++- 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index 314087a5e181..efa45ed87e69 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -168,6 +168,7 @@ enum flow_action_id { FLOW_ACTION_PTYPE, FLOW_ACTION_PRIORITY, FLOW_ACTION_RX_QUEUE_MAPPING, + FLOW_ACTION_RSS, FLOW_ACTION_WAKE, FLOW_ACTION_QUEUE, FLOW_ACTION_SAMPLE, @@ -264,6 +265,7 @@ struct flow_action_entry { u16 ptype; /* FLOW_ACTION_PTYPE */ u16 rx_queue; /* FLOW_ACTION_RX_QUEUE_MAPPING */ u32 priority; /* FLOW_ACTION_PRIORITY */ + u16 rss_group_id; /* FLOW_ACTION_RSS_GROUP_ID */ struct { /* FLOW_ACTION_QUEUE */ u32 ctx; u32 index; diff --git a/include/net/tc_act/tc_skbedit.h b/include/net/tc_act/tc_skbedit.h index 9649600fb3dc..c4a122b49e94 100644 --- a/include/net/tc_act/tc_skbedit.h +++ b/include/net/tc_act/tc_skbedit.h @@ -19,6 +19,7 @@ struct tcf_skbedit_params { u16 queue_mapping; u16 mapping_mod; u16 ptype; + u16 rss_group_id; struct rcu_head rcu; }; @@ -106,6 +107,17 @@ static inline u16 tcf_skbedit_rx_queue_mapping(const struct tc_action *a) return rx_queue; } +static inline u16 tcf_skbedit_rss_group_id(const struct tc_action *a) +{ + u16 rss_group_id; + + rcu_read_lock(); + rss_group_id = rcu_dereference(to_skbedit(a)->params)->rss_group_id; + rcu_read_unlock(); + + return rss_group_id; +} + /* Return true iff action is queue_mapping */ static inline bool is_tcf_skbedit_queue_mapping(const struct tc_action *a) { @@ -136,4 +148,10 @@ static inline bool is_tcf_skbedit_inheritdsfield(const struct tc_action *a) return is_tcf_skbedit_with_flag(a, SKBEDIT_F_INHERITDSFIELD); } +static inline bool is_tcf_skbedit_rss_group_id(const struct tc_action *a) +{ + return is_tcf_skbedit_ingress(a->tcfa_flags) && + is_tcf_skbedit_with_flag(a, SKBEDIT_F_RSS_GROUP_ID); +} + #endif /* __NET_TC_SKBEDIT_H */ diff --git a/include/uapi/linux/tc_act/tc_skbedit.h b/include/uapi/linux/tc_act/tc_skbedit.h index 64032513cc4c..83f53550bb88 100644 --- a/include/uapi/linux/tc_act/tc_skbedit.h +++ b/include/uapi/linux/tc_act/tc_skbedit.h @@ -17,6 +17,7 @@ #define SKBEDIT_F_MASK 0x10 #define SKBEDIT_F_INHERITDSFIELD 0x20 #define SKBEDIT_F_TXQ_SKBHASH 0x40 +#define SKBEDIT_F_RSS_GROUP_ID 0x80 struct tc_skbedit { tc_gen; @@ -34,6 +35,7 @@ enum { TCA_SKBEDIT_MASK, TCA_SKBEDIT_FLAGS, TCA_SKBEDIT_QUEUE_MAPPING_MAX, + TCA_SKBEDIT_RSS_GROUP_ID, __TCA_SKBEDIT_MAX }; #define TCA_SKBEDIT_MAX (__TCA_SKBEDIT_MAX - 1) diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c index ce7008cf291c..127198239ac7 100644 --- a/net/sched/act_skbedit.c +++ b/net/sched/act_skbedit.c @@ -112,6 +112,7 @@ static const struct nla_policy skbedit_policy[TCA_SKBEDIT_MAX + 1] = { [TCA_SKBEDIT_MASK] = { .len = sizeof(u32) }, [TCA_SKBEDIT_FLAGS] = { .len = sizeof(u64) }, [TCA_SKBEDIT_QUEUE_MAPPING_MAX] = { .len = sizeof(u16) }, + [TCA_SKBEDIT_RSS_GROUP_ID] = { .len = sizeof(u16) }, }; static int tcf_skbedit_init(struct net *net, struct nlattr *nla, @@ -126,8 +127,8 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, struct tcf_chain *goto_ch = NULL; struct tc_skbedit *parm; struct tcf_skbedit *d; + u16 *queue_mapping = NULL, *ptype = NULL, *rss_group_id = NULL; u32 flags = 0, *priority = NULL, *mark = NULL, *mask = NULL; - u16 *queue_mapping = NULL, *ptype = NULL; u16 mapping_mod = 1; bool exists = false; int ret = 0, err; @@ -176,6 +177,17 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, mask = nla_data(tb[TCA_SKBEDIT_MASK]); } + if (tb[TCA_SKBEDIT_RSS_GROUP_ID] != NULL) { + if (!is_tcf_skbedit_ingress(act_flags) || + !(act_flags & TCA_ACT_FLAGS_SKIP_SW)) { + NL_SET_ERR_MSG_MOD(extack, + "\"rss_group_id\" option allowed only on receive side with hardware only, use skip_sw"); + return -EOPNOTSUPP; + } + flags |= SKBEDIT_F_RSS_GROUP_ID; + rss_group_id = nla_data(tb[TCA_SKBEDIT_RSS_GROUP_ID]); + } + if (tb[TCA_SKBEDIT_FLAGS] != NULL) { u64 *pure_flags = nla_data(tb[TCA_SKBEDIT_FLAGS]); @@ -262,6 +274,9 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, if (flags & SKBEDIT_F_MASK) params_new->mask = *mask; + if (flags & SKBEDIT_F_RSS_GROUP_ID) + params_new->rss_group_id = *rss_group_id; + spin_lock_bh(&d->tcf_lock); goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); params_new = rcu_replace_pointer(d->params, params_new, @@ -326,6 +341,9 @@ static int tcf_skbedit_dump(struct sk_buff *skb, struct tc_action *a, pure_flags |= SKBEDIT_F_TXQ_SKBHASH; } + if ((params->flags & SKBEDIT_F_RSS_GROUP_ID) && + nla_put_u16(skb, TCA_SKBEDIT_RSS_GROUP_ID, params->rss_group_id)) + goto nla_put_failure; if (pure_flags != 0 && nla_put(skb, TCA_SKBEDIT_FLAGS, sizeof(pure_flags), &pure_flags)) goto nla_put_failure; @@ -362,6 +380,7 @@ static size_t tcf_skbedit_get_fill_size(const struct tc_action *act) + nla_total_size(sizeof(u32)) /* TCA_SKBEDIT_MARK */ + nla_total_size(sizeof(u16)) /* TCA_SKBEDIT_PTYPE */ + nla_total_size(sizeof(u32)) /* TCA_SKBEDIT_MASK */ + + nla_total_size(sizeof(u16)) /* TCA_SKBEDIT_RSS_GROUP_ID */ + nla_total_size_64bit(sizeof(u64)); /* TCA_SKBEDIT_FLAGS */ } @@ -390,6 +409,9 @@ static int tcf_skbedit_offload_act_setup(struct tc_action *act, void *entry_data } else if (is_tcf_skbedit_inheritdsfield(act)) { NL_SET_ERR_MSG_MOD(extack, "Offload not supported when \"inheritdsfield\" option is used"); return -EOPNOTSUPP; + } else if (is_tcf_skbedit_rss_group_id(act)) { + entry->id = FLOW_ACTION_RSS; + entry->rss_group_id = tcf_skbedit_rss_group_id(act); } else { NL_SET_ERR_MSG_MOD(extack, "Unsupported skbedit option offload"); return -EOPNOTSUPP; @@ -406,6 +428,8 @@ static int tcf_skbedit_offload_act_setup(struct tc_action *act, void *entry_data fl_action->id = FLOW_ACTION_PRIORITY; else if (is_tcf_skbedit_rx_queue_mapping(act)) fl_action->id = FLOW_ACTION_RX_QUEUE_MAPPING; + else if (is_tcf_skbedit_rss_group_id(act)) + fl_action->id = FLOW_ACTION_RSS; else return -EOPNOTSUPP; }