From: Jiri Pirko <jiri@resnulli.us>
To: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: netdev@vger.kernel.org, deb.chatterjee@intel.com,
anjali.singhai@intel.com, namrata.limaye@intel.com,
tom@sipanda.io, mleitner@redhat.com, Mahesh.Shirshyad@amd.com,
tomasz.osinski@intel.com, xiyou.wangcong@gmail.com,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, vladbu@nvidia.com, horms@kernel.org,
daniel@iogearbox.net, bpf@vger.kernel.org, khalidm@nvidia.com,
toke@redhat.com, mattyk@nvidia.com
Subject: Re: [PATCH net-next v8 10/15] p4tc: add action template create, update, delete, get, flush and dump
Date: Thu, 16 Nov 2023 17:28:15 +0100 [thread overview]
Message-ID: <ZVZDH9OzqFvc3VSS@nanopsycho> (raw)
In-Reply-To: <20231116145948.203001-11-jhs@mojatatu.com>
Thu, Nov 16, 2023 at 03:59:43PM CET, jhs@mojatatu.com wrote:
[...]
>diff --git a/include/net/act_api.h b/include/net/act_api.h
>index cd5a8e86f..b95a9bc29 100644
>--- a/include/net/act_api.h
>+++ b/include/net/act_api.h
>@@ -70,6 +70,7 @@ struct tc_action {
> #define TCA_ACT_FLAGS_AT_INGRESS (1U << (TCA_ACT_FLAGS_USER_BITS + 4))
> #define TCA_ACT_FLAGS_PREALLOC (1U << (TCA_ACT_FLAGS_USER_BITS + 5))
> #define TCA_ACT_FLAGS_UNREFERENCED (1U << (TCA_ACT_FLAGS_USER_BITS + 6))
>+#define TCA_ACT_FLAGS_FROM_P4TC (1U << (TCA_ACT_FLAGS_USER_BITS + 7))
>
> /* Update lastuse only if needed, to avoid dirtying a cache line.
> * We use a temp variable to avoid fetching jiffies twice.
>diff --git a/include/net/p4tc.h b/include/net/p4tc.h
>index ccb54d842..68b00fa72 100644
>--- a/include/net/p4tc.h
>+++ b/include/net/p4tc.h
>@@ -9,17 +9,23 @@
> #include <linux/refcount.h>
> #include <linux/rhashtable.h>
> #include <linux/rhashtable-types.h>
>+#include <net/tc_act/p4tc.h>
>+#include <net/p4tc_types.h>
>
> #define P4TC_DEFAULT_NUM_TABLES P4TC_MINTABLES_COUNT
> #define P4TC_DEFAULT_MAX_RULES 1
> #define P4TC_PATH_MAX 3
>+#define P4TC_MAX_TENTRIES 33554432
Seeing define like this one always makes me happier. Where does it come
from? Why not 0x2000000 at least?
>
> #define P4TC_KERNEL_PIPEID 0
>
> #define P4TC_PID_IDX 0
>+#define P4TC_AID_IDX 1
>+#define P4TC_PARSEID_IDX 1
>
> struct p4tc_dump_ctx {
> u32 ids[P4TC_PATH_MAX];
>+ struct rhashtable_iter *iter;
> };
>
> struct p4tc_template_common;
>@@ -63,8 +69,10 @@ extern const struct p4tc_template_ops p4tc_pipeline_ops;
>
> struct p4tc_pipeline {
> struct p4tc_template_common common;
>+ struct idr p_act_idr;
> struct rcu_head rcu;
> struct net *net;
>+ u32 num_created_acts;
> /* Accounts for how many entities are referencing this pipeline.
> * As for now only P4 filters can refer to pipelines.
> */
>@@ -109,18 +117,157 @@ p4tc_pipeline_find_byany_unsealed(struct net *net, const char *p_name,
> const u32 pipeid,
> struct netlink_ext_ack *extack);
>
>+struct p4tc_act *tcf_p4_find_act(struct net *net,
>+ const struct tc_action_ops *a_o,
>+ struct netlink_ext_ack *extack);
>+void
>+tcf_p4_put_prealloc_act(struct p4tc_act *act, struct tcf_p4act *p4_act);
>+
> static inline int p4tc_action_destroy(struct tc_action **acts)
> {
>+ struct tc_action *acts_non_prealloc[TCA_ACT_MAX_PRIO] = {NULL};
> int ret = 0;
>
> if (acts) {
>- ret = tcf_action_destroy(acts, TCA_ACT_UNBIND);
>+ int j = 0;
>+ int i;
Move declarations to the beginning of the if body.
[...]
>diff --git a/include/uapi/linux/p4tc.h b/include/uapi/linux/p4tc.h
>index 4d33f44c1..7b89229a7 100644
>--- a/include/uapi/linux/p4tc.h
>+++ b/include/uapi/linux/p4tc.h
>@@ -4,6 +4,7 @@
>
> #include <linux/types.h>
> #include <linux/pkt_sched.h>
>+#include <linux/pkt_cls.h>
>
> /* pipeline header */
> struct p4tcmsg {
>@@ -17,9 +18,12 @@ struct p4tcmsg {
> #define P4TC_MSGBATCH_SIZE 16
>
> #define P4TC_MAX_KEYSZ 512
>+#define P4TC_DEFAULT_NUM_PREALLOC 16
>
> #define TEMPLATENAMSZ 32
> #define PIPELINENAMSIZ TEMPLATENAMSZ
>+#define ACTTMPLNAMSIZ TEMPLATENAMSZ
>+#define ACTPARAMNAMSIZ TEMPLATENAMSZ
Prefix? This is uapi. Could you please be more careful with naming at
least in the uapi area?
[...]
>diff --git a/net/sched/p4tc/p4tc_action.c b/net/sched/p4tc/p4tc_action.c
>new file mode 100644
>index 000000000..19db0772c
>--- /dev/null
>+++ b/net/sched/p4tc/p4tc_action.c
>@@ -0,0 +1,2242 @@
>+// SPDX-License-Identifier: GPL-2.0-or-later
>+/*
>+ * net/sched/p4tc_action.c P4 TC ACTION TEMPLATES
>+ *
>+ * Copyright (c) 2022-2023, Mojatatu Networks
>+ * Copyright (c) 2022-2023, Intel Corporation.
>+ * Authors: Jamal Hadi Salim <jhs@mojatatu.com>
>+ * Victor Nogueira <victor@mojatatu.com>
>+ * Pedro Tammela <pctammela@mojatatu.com>
>+ */
>+
>+#include <linux/err.h>
>+#include <linux/errno.h>
>+#include <linux/init.h>
>+#include <linux/kernel.h>
>+#include <linux/kmod.h>
>+#include <linux/list.h>
>+#include <linux/module.h>
>+#include <linux/netdevice.h>
>+#include <linux/skbuff.h>
>+#include <linux/slab.h>
>+#include <linux/string.h>
>+#include <linux/types.h>
>+#include <net/flow_offload.h>
>+#include <net/net_namespace.h>
>+#include <net/netlink.h>
>+#include <net/pkt_cls.h>
>+#include <net/p4tc.h>
>+#include <net/sch_generic.h>
>+#include <net/sock.h>
>+#include <net/tc_act/p4tc.h>
>+
>+static LIST_HEAD(dynact_list);
>+
>+#define SEPARATOR "/"
Prefix? Btw, why exactly do you need this. It is used only once.
To quote a few function names in this file:
>+static void set_param_indices(struct idr *params_idr)
>+static void generic_free_param_value(struct p4tc_act_param *param)
>+static int dev_init_param_value(struct net *net, struct p4tc_act_param_ops *op,
>+static void dev_free_param_value(struct p4tc_act_param *param)
>+static void tcf_p4_act_params_destroy_rcu(struct rcu_head *head)
>+static int __tcf_p4_dyna_init_set(struct p4tc_act *act, struct tc_action **a,
>+static int tcf_p4_dyna_template_init(struct net *net, struct tc_action **a,
>+init_prealloc_param(struct p4tc_act *act, struct idr *params_idr,
>+static void p4tc_param_put(struct p4tc_act_param *param)
>+static void free_intermediate_param(struct p4tc_act_param *param)
>+static void free_intermediate_params_list(struct list_head *params_list)
>+static int init_prealloc_params(struct p4tc_act *act,
>+struct p4tc_act *p4tc_action_find_byid(struct p4tc_pipeline *pipeline,
>+static void tcf_p4_prealloc_list_add(struct p4tc_act *act_tmpl,
>+static int tcf_p4_prealloc_acts(struct net *net, struct p4tc_act *act,
>+tcf_p4_get_next_prealloc_act(struct p4tc_act *act)
>+void tcf_p4_set_init_flags(struct tcf_p4act *p4act)
>+static void __tcf_p4_put_prealloc_act(struct p4tc_act *act,
>+tcf_p4_put_prealloc_act(struct p4tc_act *act, struct tcf_p4act *p4act)
>+static int generic_dump_param_value(struct sk_buff *skb, struct p4tc_type *type,
>+static int generic_init_param_value(struct p4tc_act_param *nparam,
>+static struct p4tc_act_param *param_find_byname(struct idr *params_idr,
>+tcf_param_find_byany(struct p4tc_act *act,
>+tcf_param_find_byanyattr(struct p4tc_act *act, struct nlattr *name_attr,
>+static int __p4_init_param_type(struct p4tc_act_param *param,
>+static int tcf_p4_act_init_params(struct net *net,
>+static struct p4tc_act *p4tc_action_find_byname(const char *act_name,
>+static int tcf_p4_dyna_init(struct net *net, struct nlattr *nla,
>+static int tcf_act_fill_param_type(struct sk_buff *skb,
>+static void tcf_p4_dyna_cleanup(struct tc_action *a)
>+struct p4tc_act *p4tc_action_find_get(struct p4tc_pipeline *pipeline,
>+p4tc_action_find_byanyattr(struct nlattr *act_name_attr, const u32 a_id,
>+static void p4_put_many_params(struct idr *params_idr)
>+static int p4_init_param_type(struct p4tc_act_param *param,
>+static struct p4tc_act_param *p4_create_param(struct p4tc_act *act,
>+static struct p4tc_act_param *p4_update_param(struct p4tc_act *act,
>+static struct p4tc_act_param *p4_act_init_param(struct p4tc_act *act,
>+static void p4tc_action_net_exit(struct tc_action_net *tn)
>+static void p4_act_params_put(struct p4tc_act *act)
>+static int __tcf_act_put(struct net *net, struct p4tc_pipeline *pipeline,
>+static int _tcf_act_fill_nlmsg(struct net *net, struct sk_buff *skb,
>+static int tcf_act_fill_nlmsg(struct net *net, struct sk_buff *skb,
>+static int tcf_act_flush(struct sk_buff *skb, struct net *net,
>+static void p4tc_params_replace_many(struct p4tc_act *act,
>+ struct idr *params_idr)
>+static struct p4tc_act *tcf_act_create(struct net *net, struct nlattr **tb,
>+tcf_act_cu(struct net *net, struct nlmsghdr *n, struct nlattr *nla,
Is there some secret key how you name the functions? To me, this looks
completely inconsistent :/
next prev parent reply other threads:[~2023-11-16 16:28 UTC|newest]
Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-16 14:59 [PATCH net-next v8 00/15] Introducing P4TC Jamal Hadi Salim
2023-11-16 14:59 ` [PATCH net-next v8 01/15] net: sched: act_api: Introduce dynamic actions list Jamal Hadi Salim
2023-11-16 14:59 ` [PATCH net-next v8 02/15] net/sched: act_api: increase action kind string length Jamal Hadi Salim
2023-11-16 14:59 ` [PATCH net-next v8 03/15] net/sched: act_api: Update tc_action_ops to account for dynamic actions Jamal Hadi Salim
2023-11-16 14:59 ` [PATCH net-next v8 04/15] net/sched: act_api: add struct p4tc_action_ops as a parameter to lookup callback Jamal Hadi Salim
2023-11-16 14:59 ` [PATCH net-next v8 05/15] net: sched: act_api: Add support for preallocated dynamic action instances Jamal Hadi Salim
2023-11-16 14:59 ` [PATCH net-next v8 06/15] net: introduce rcu_replace_pointer_rtnl Jamal Hadi Salim
2023-11-16 14:59 ` [PATCH net-next v8 07/15] rtnl: add helper to check if group has listeners Jamal Hadi Salim
2023-11-16 14:59 ` [PATCH net-next v8 08/15] p4tc: add P4 data types Jamal Hadi Salim
2023-11-16 16:03 ` Jiri Pirko
2023-11-17 12:01 ` Jamal Hadi Salim
2023-11-16 14:59 ` [PATCH net-next v8 09/15] p4tc: add template pipeline create, get, update, delete Jamal Hadi Salim
2023-11-16 16:11 ` Jiri Pirko
2023-11-17 12:09 ` Jamal Hadi Salim
2023-11-20 8:18 ` Jiri Pirko
2023-11-20 12:48 ` Jamal Hadi Salim
2023-11-20 13:16 ` Jiri Pirko
2023-11-20 15:30 ` Jamal Hadi Salim
2023-11-20 16:25 ` Jiri Pirko
2023-11-20 18:20 ` David Ahern
2023-11-20 20:12 ` Jamal Hadi Salim
2023-11-16 14:59 ` [PATCH net-next v8 10/15] p4tc: add action template create, update, delete, get, flush and dump Jamal Hadi Salim
2023-11-16 16:28 ` Jiri Pirko [this message]
2023-11-17 15:11 ` Jamal Hadi Salim
2023-11-20 8:19 ` Jiri Pirko
2023-11-20 13:45 ` Jamal Hadi Salim
2023-11-20 16:25 ` Jiri Pirko
2023-11-17 6:51 ` John Fastabend
2023-11-16 14:59 ` [PATCH net-next v8 11/15] p4tc: add template table " Jamal Hadi Salim
2023-11-16 14:59 ` [PATCH net-next v8 12/15] p4tc: add runtime table entry create, update, get, delete, " Jamal Hadi Salim
2023-11-16 14:59 ` [PATCH net-next v8 13/15] p4tc: add set of P4TC table kfuncs Jamal Hadi Salim
2023-11-17 7:09 ` John Fastabend
2023-11-19 9:14 ` kernel test robot
2023-11-20 22:28 ` kernel test robot
2023-11-16 14:59 ` [PATCH net-next v8 14/15] p4tc: add P4 classifier Jamal Hadi Salim
2023-11-17 7:17 ` John Fastabend
2023-11-16 14:59 ` [PATCH net-next v8 15/15] p4tc: Add P4 extern interface Jamal Hadi Salim
2023-11-16 16:42 ` Jiri Pirko
2023-11-17 12:14 ` Jamal Hadi Salim
2023-11-20 8:22 ` Jiri Pirko
2023-11-20 14:02 ` Jamal Hadi Salim
2023-11-20 16:27 ` Jiri Pirko
2023-11-20 19:00 ` Jamal Hadi Salim
2023-11-17 6:27 ` [PATCH net-next v8 00/15] Introducing P4TC John Fastabend
2023-11-17 12:49 ` Jamal Hadi Salim
2023-11-17 18:37 ` John Fastabend
2023-11-17 20:46 ` Jamal Hadi Salim
2023-11-20 9:39 ` Jiri Pirko
2023-11-20 14:23 ` Jamal Hadi Salim
2023-11-20 18:10 ` Jiri Pirko
2023-11-20 19:56 ` Jamal Hadi Salim
2023-11-20 20:41 ` John Fastabend
2023-11-20 22:13 ` Jamal Hadi Salim
2023-11-20 21:48 ` Daniel Borkmann
2023-11-20 22:56 ` Jamal Hadi Salim
2023-11-21 13:06 ` Jiri Pirko
2023-11-21 13:47 ` Jamal Hadi Salim
2023-11-21 14:19 ` Jiri Pirko
2023-11-21 15:21 ` Jamal Hadi Salim
2023-11-22 9:25 ` Jiri Pirko
2023-11-22 15:14 ` Jamal Hadi Salim
2023-11-22 18:31 ` Jiri Pirko
2023-11-22 18:50 ` John Fastabend
2023-11-22 19:35 ` Jamal Hadi Salim
2023-11-23 6:36 ` Jiri Pirko
2023-11-23 13:22 ` Jamal Hadi Salim
2023-11-23 13:34 ` Jiri Pirko
2023-11-23 13:45 ` Jamal Hadi Salim
2023-11-23 14:07 ` Jiri Pirko
2023-11-23 14:28 ` Jamal Hadi Salim
2023-11-23 15:27 ` Jiri Pirko
2023-11-23 16:30 ` Jamal Hadi Salim
2023-11-23 17:53 ` Edward Cree
2023-11-23 18:09 ` Jiri Pirko
2023-11-23 18:58 ` Jamal Hadi Salim
2023-11-23 18:53 ` Jakub Kicinski
2023-11-23 19:42 ` Tom Herbert
2023-11-24 10:39 ` Jiri Pirko
2023-11-23 18:04 ` Jiri Pirko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZVZDH9OzqFvc3VSS@nanopsycho \
--to=jiri@resnulli.us \
--cc=Mahesh.Shirshyad@amd.com \
--cc=anjali.singhai@intel.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=deb.chatterjee@intel.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jhs@mojatatu.com \
--cc=khalidm@nvidia.com \
--cc=kuba@kernel.org \
--cc=mattyk@nvidia.com \
--cc=mleitner@redhat.com \
--cc=namrata.limaye@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=toke@redhat.com \
--cc=tom@sipanda.io \
--cc=tomasz.osinski@intel.com \
--cc=vladbu@nvidia.com \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox