Introducing P4TC
Subsystems (6)
Jamal Hadi Salim
maintainerv8 cover Introducing P4TC
We are seeking community feedback on P4TC patches.
We have reduced the number of commits in this patchset including leaving out all the testcases and secondary patches in order to ease review.
We feel we have completed the migration from the V1 scriptable version to eBPF and now is a good time to remove the RFC tag.
Changes In RFC Version 2
-------------------------
Version 2 is the initial integration of the eBPF datapath.
We took into consideration suggestions provided to use eBPF and put effort into analyzing eBPF as datapath which involved extensive testing.
We implemented 6 approaches with eBPF and ran performance analysis and presented our results at the P4 2023 workshop in Santa Clara[see: 1, 3] on each of the 6 vs the scriptable P4TC and concluded that 2 of the approaches are sensible (4 if you account for XDP or TC separately).
Conclusions from the exercise: We lose the simple operational model we had prior to integrating eBPF. We do gain performance in most cases when the datapath is less compute-bound.
For more discussion on our requirements vs journeying the eBPF path please scroll down to "Restating Our Requirements" and "Challenges".
This patch set presented two modes.
mode1: the parser is entirely based on eBPF - whereas the rest of the SW datapath stays as _scriptable_ as in Version 1.
mode2: All of the kernel s/w datapath (including parser) is in eBPF.
The key ingredient for eBPF, that we did not have access to in the past, is kfunc (it made a big difference for us to reconsider eBPF).
In V2 the two modes are mutually exclusive (IOW, you get to choose one or the other via Kconfig).
Changes In RFC Version 3
-------------------------
These patches are still in a little bit of flux as we adjust to integrating eBPF. So there are small constructs that are used in V1 and 2 but no longer used in this version. We will make a V4 which will remove those. The changes from V2 are as follows:
1) Feedback we got in V2 is to try stick to one of the two modes. In this version we are taking one more step and going the path of mode2 vs v2 where we had 2 modes.
2) The P4 Register extern is no longer standalone. Instead, as part of integrating into eBPF we introduce another kfunc which encapsulates Register as part of the extern interface.
3) We have improved our CICD to include tools pointed to us by Simon. See "Testing" further below. Thanks to Simon for that and other issues he caught. Simon, we discussed on issue [7] but decided to keep that log since we think it is useful.
4) A lot of small cleanups. Thanks Marcelo. There are two things we need to re-discuss though; see: [5], [6].
5) We removed the need for a range of IDs for dynamic actions. Thanks Jakub.
6) Clarify ambiguity caused by smatch in an if(A) else if(B) condition. We are guaranteed that either A or B must exist; however, lets make smatch happy. Thanks to Simon and Dan Carpenter.
Changes In RFC Version 4
-------------------------
1) More integration from scriptable to eBPF. Small bug fixes.
2) More streamlining support of externs via kfunc (one additional kfunc).
3) Removed per-cpu scratchpad per Toke's suggestion and instead use XDP metadata.
There is more eBPF integration coming. One thing we looked at but is not in this patchset but should be in the next is use of eBPF link in our loading (see "challenge #1" further below).
Changes In RFC Version 5
-------------------------
1) More integration from scriptable view to eBPF. Small bug fixes from last integration.
2) More streamlining support of externs via kfunc (create-on-miss, etc)
3) eBPF linking for XDP.
There is more eBPF integration/streamlining coming (we are getting close to conversion from scriptable domain).
Changes In RFC Version 6
-------------------------
1) Completed integration from scriptable view to eBPF. Completed integration of externs integration.
2) Small bug fixes from v5 based on testing.
Changes In Version 7
-------------------------
0) First time removing the RFC tag!
1) Removed XDP cookie. It turns out as was pointed out by Toke(Thanks!) - that using bpf links was sufficient to protect us from someone replacing or deleting a eBPF program after it has been bound to a netdev.
2) Add some reviewed-bys from Vlad.
3) Small bug fixes from v6 based on testing for ebpf.
4) Added the counter extern as a sample extern. Illustrating this example because it is slightly complex since it is possible to invoke it directly from the P4TC domain (in case of direct counters) or from eBPF (indirect counters). It is not exactly the most efficient implementation (a reasonable counter impl should be per-cpu).
Changes In Version 8
---------------------
1) Fix all the patchwork warnings and improve our ci to catch them in the future
2) Reduce the number of patches to basic max(15) to ease review.
What is P4?
-----------
The Programming Protocol-independent Packet Processors (P4) is an open source, domain-specific programming language for specifying data plane behavior.
The P4 ecosystem includes an extensive range of deployments, products, projects and services, etc[9][10][11][12].
__What is P4TC?__
P4TC is a net-namespace aware implementation, meaning multiple P4 programs can run independently in different namespaces alongside their appropriate state. The implementation builds on top of many years of Linux TC experiences. On why P4 - see small treatise here:[4].
There have been many discussions and meetings since about 2015 in regards to P4 over TC[2] and we are finally proving the naysayers that we do get stuff done!
A lot more of the P4TC motivation is captured at:
https://github.com/p4tc-dev/docs/blob/main/why-p4tc.md
**In this patch series we focus on s/w datapath only**.
__P4TC Workflow__
These patches enable kernel and user space code change _independence_ for any new P4 program that describes a new datapath. The workflow is as follows:
1) A developer writes a P4 program, "myprog"
2) Compiles it using the P4C compiler[8]. The compiler generates 3 outputs:
a) shell script(s) which form template definitions for the different P4 objects "myprog" utilizes (tables, externs, actions etc).
b) the parser and the rest of the datapath are generated
in eBPF and need to be compiled into binaries.
c) A json introspection file used for the control plane (by iproute2/tc).
3) The developer (or operator) executes the shell script(s) to manifest the functional "myprog" into the kernel.
4) The developer (or operator) instantiates "myprog" via the tc P4 filter to ingress/egress (depending on P4 arch) of one or more netdevs/ports.
Example1: parser is an action:
"tc filter add block 22 ingress protocol all prio 10 p4 pname myprog \
action bpf obj $PARSER.o section parser/tc-ingress \
action bpf obj $PROGNAME.o section p4prog/tc"
Example2: parser explicitly bound and rest of dpath as an action:
"tc filter add block 22 ingress protocol all prio 10 p4 pname myprog \
prog tc obj $PARSER.o section parser/tc-ingress \
action bpf obj $PROGNAME.o section p4prog/tc"
Example3: parser is at XDP, rest of dpath as an action:
"tc filter add block 22 ingress protocol all prio 10 p4 pname myprog \
prog type xdp obj $PARSER.o section parser/xdp-ingress \
pinned_link /path/to/xdp-prog-link \
action bpf obj $PROGNAME.o section p4prog/tc"
Example4: parser+prog at XDP:
"tc filter add block 22 ingress protocol all prio 10 p4 pname myprog \
prog type xdp obj $PROGNAME.o section p4prog/xdp \
pinned_link /path/to/xdp-prog-link"
see individual patches for more examples tc vs xdp etc. Also see section on "challenges" (on this cover letter).
Once "myprog" P4 program is instantiated one can start updating table entries that are associated with myprog's table named "mytable". Example:
tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \
action send_to_port param port eno1A packet arriving on ingress of any of the ports on block 22 will first be exercised via the (eBPF) parser to find the headers pointing to the ip destination address.
The remainder eBPF datapath uses the result dstAddr as a key to do a lookup in myprog's mytable which returns the action params which are then used to execute the action in the eBPF datapath (eventually sending out packets to eno1). On a table miss, mytable's default miss action is executed.
__Description of Patches__
P4TC is designed to have no impact on the core code for other users of TC. IOW, you can compile it out but even if it compiled in and you dont use it there should be no impact on your performance.
We do make core kernel changes. Patch #1 adds infrastructure for "dynamic" actions that can be created on "the fly" based on the P4 program requirement. This patch makes a small incision into act_api which shouldn't affect the performance (or functionality) of the existing actions. Patches 2-4,6-7 are minimalist enablers for P4TC and have no effect the classical tc action. Patch 5 adds infrastructure support for preallocation of dynamic actions.
The core P4TC code implements several P4 objects.
1) Patch #8 introduces P4 data types which are consumed by the rest of the code
2) Patch #9 introduces the concept of templating Pipelines. i.e CRUD commands for P4 pipelines.
3) Patch #10 introduces the concept of action templates and associated CRUD commands.
4) Patch #11 introduces the concept of P4 table templates and associated CRUD commands for tables
5) Patch #12 introduces table entries and associated CRUD commands.
6) Patch #13 introduces interaction of eBPF to P4TC tables via kfunc.
7) Patch #14 introduces the TC classifier P4 used at runtime.
8) Patch #15 introduces extern interfacing (both template and runtime).
__Testing__
Speaking of testing - we have ~300 tdc test cases. This number is growing as we are adjusting to accommodate for eBPF.
These tests are run on our CICD system on pull requests and after commits are approved. The CICD does a lot of other tests (more since v2, thanks to Simon's input)including:
checkpatch, sparse, smatch, coccinelle, 32 bit and 64 bit builds tested on both X86, ARM 64 and emulated BE via qemu s390. We trigger performance testing in the CICD to catch performance regressions (currently only on the control path, but in the future for the datapath).
Syzkaller runs 24/7 on dedicated hardware, originally we focussed only on memory sanitizer but recently added support for concurrency sanitizer. Before main releases we ensure each patch will compile on its own to help in git bisect and run the xmas tree tool. We eventually put the code via coverity.
In addition we are working on a tool that will take a P4 program, run it through the compiler, and generate permutations of traffic patterns via symbolic execution that will test both positive and negative datapath code paths. The test generator tool is still work in progress and will be generated by the P4 compiler.
Note: We have other code that test parallelization etc which we are trying to find a fit for in the kernel tree's testing infra.
__Restating Our Requirements__
The initial release made in January/2023 had a "scriptable" datapath (think u32 classifier and pedit action). In this section we review the scriptable version against the current implementation we are pushing upstream which uses eBPF.
Our intention is to target the TC crowd.
Essentially developers and ops people deploying TC based infra.
More importantly the original intent for P4TC was to enable _ops folks_ more than devs (given code is being generated and doesn't need humans to write it).
With TC, we get whole "familiar" package of match-action pipeline abstraction++, meaning from the control plane all the way to the tooling infra, i.e iproute2/tc cli, netlink infra(request/resp, event subscribe/multicast-publish, congestion control etc), s/w and h/w symbiosis, the autonomous kernel control, etc.
The main advantage is that we have a singular vendor-neutral interface via the kernel using well understood mechanisms based on deployment experience (and at least this part doesnt need retraining).
1) Supporting expressibility of the universe set of P4 progs
It is a must to support 100% of all possible P4 programs. In the past the eBPF verifier had to be worked around and even then there are cases where we couldnt avoid path explosion when branching is involved. Kfunc-ing solves these issues for us. Note, there are still challenges running all potential P4 programs at the XDP level - the solution to that is to have the compiler generate XDP based code only if it possible to map it to that layer.
2) Support for P4 HW and SW equivalence.
This feature continues to work even in the presence of eBPF as the s/w datapath. There are cases of square-hole-round-peg scenarios but those are implementation issues we can live with.
3) Operational usability
By maintaining the TC control plane (even in presence of eBPF datapath) runtime aspects remain unchanged. So for our target audience of folks who have deployed tc including offloads - the comfort zone is unchanged. There is also the comfort zone of continuing to use the true-and-tried netlink interfacing.
There is some loss in operational usability because we now have more knobs:
the extra compilation, loading and syncing of ebpf binaries, etc. IOW, I can no longer just ship someone a shell script in an email to say go run this and "myprog" will just work.
4) Operational and development Debuggability
If something goes wrong, the tc craftsperson is now required to have additional knowledge of eBPF code and process. This applies to both the operational person as well as someone who wrote a driver. We dont believe this is solvable.
5) Opportunity for rapid prototyping of new ideas
During the P4TC development phase something that came naturally was to often handcode the template scripts because the compiler backend (which is P4 arch specific) wasnt ready to generate certain things. Then you would read back the template and diff to ensure the kernel didn't get something wrong. So this started as a debug feature. During development, we wrote scripts that covered a range of P4 architectures(PSA, V1, etc) which required no kernel code changes.
Over time the debug feature morphed into: a) start by handcoding scripts then
b) read it back and then c) generate the P4 code.
It means one could start with the template scripts outside of the constraints of a P4 architecture spec(PNA/PSA) or even within a P4 architecture then test some ideas and eventually feed back the concepts to the compiler authors or modify or create a new P4 architecture and share with the P4 standards folks.
To summarize in presence of eBPF: The debugging idea is probably still alive. One could dump, with proper tooling(bpftool for example), the loaded eBPF code and be able to check for differences. But this is not the interesting part. The concept of going back from whats in the kernel to P4 is a lot more difficult to implement mostly due to scoping of DSL vs general purpose. It may be lost. We have been thinking of ways to use BTF and embedding annotations in the eBPF code and binary but more thought is required and we welcome suggestions.
6) Supporting per namespace program
This requirement is still met (by virtue of keeping P4 control objects within the TC domain).
__Challenges__
1) Concept of tc block in XDP is _very tedious_ to implement. It would be nice if we can use concept there as well, since we expect P4 to work with many ports. It will likely require some core patches to fix this.
2) Right now we are using "packed" construct to enforce alignment in kfunc data exchange; but we're wondering if there is potential to use BTF to understand parameters and their offsets and encode this information at the compiler level.
3) At the moment we are creating a static buffer of 128B to retrieve the action parameters. If you have a lot of table entries and individual(non-shared) action instances with actions that require very little (or no) param space a lot of memory is wasted. There may also be cases where 128B may not be enough; (likely this is something we can teach the P4C compiler). If we can have dynamic pointers instead for kfunc fixed length parameterization then this issue is resolvable.
4) See "Restating Our Requirements" #5.
We would really appreciate ideas/suggestions, etc.
__References__
[1]https://github.com/p4tc-dev/docs/blob/main/p4-conference-2023/2023P4WorkshopP4TC.pdf [2]https://github.com/p4tc-dev/docs/blob/main/why-p4tc.md#historical-perspective-for-p4tc [3]https://2023p4workshop.sched.com/event/1KsAe/p4tc-linux-kernel-p4-implementation-approaches-and-evaluation [4]https://github.com/p4tc-dev/docs/blob/main/why-p4tc.md#so-why-p4-and-how-does-p4-help-here [5]https://lore.kernel.org/netdev/[email protected]/T/#mf59be7abc5df3473cff3879c8cc3e2369c0640a6 [6]https://lore.kernel.org/netdev/[email protected]/T/#m783cfd79e9d755cf0e7afc1a7d5404635a5b1919 [7]https://lore.kernel.org/netdev/[email protected]/T/#ma8c84df0f7043d17b98f3d67aab0f4904c600469 [8]https://github.com/p4lang/p4c/tree/main/backends/tc
[9]https://p4.org/ [10]https://www.intel.com/content/www/us/en/products/details/network-io/ipu/e2000-asic.html [11]https://www.amd.com/en/accelerators/pensando
[12]https://github.com/sonic-net/DASH/tree/main
Jamal Hadi Salim (15):
net: sched: act_api: Introduce dynamic actions list net/sched: act_api: increase action kind string length net/sched: act_api: Update tc_action_ops to account for dynamic
actions
net/sched: act_api: add struct p4tc_action_ops as a parameter to
lookup callback
net: sched: act_api: Add support for preallocated dynamic action
instances
net: introduce rcu_replace_pointer_rtnl
rtnl: add helper to check if group has listeners
p4tc: add P4 data types
p4tc: add template pipeline create, get, update, delete
p4tc: add action template create, update, delete, get, flush and dump
p4tc: add template table create, update, delete, get, flush and dump
p4tc: add runtime table entry create, update, get, delete, flush and
dump
p4tc: add set of P4TC table kfuncs
p4tc: add P4 classifier
p4tc: Add P4 extern interface
include/linux/bitops.h | 1 + include/linux/rtnetlink.h | 19 + include/net/act_api.h | 22 +- include/net/p4tc.h | 744 ++++++++ include/net/p4tc_ext_api.h | 199 ++ include/net/p4tc_types.h | 88 + include/net/tc_act/p4tc.h | 52 + include/uapi/linux/p4tc.h | 406 ++++ include/uapi/linux/p4tc_ext.h | 36 + include/uapi/linux/pkt_cls.h | 19 + include/uapi/linux/rtnetlink.h | 18 + net/sched/Kconfig | 23 + net/sched/Makefile | 3 + net/sched/act_api.c | 195 +- net/sched/cls_api.c | 2 +- net/sched/cls_p4.c | 447 +++++ net/sched/p4tc/Makefile | 8 + net/sched/p4tc/p4tc_action.c | 2308 +++++++++++++++++++++++ net/sched/p4tc/p4tc_bpf.c | 414 +++++ net/sched/p4tc/p4tc_ext.c | 2204 ++++++++++++++++++++++ net/sched/p4tc/p4tc_pipeline.c | 707 +++++++ net/sched/p4tc/p4tc_runtime_api.c | 153 ++ net/sched/p4tc/p4tc_table.c | 1634 ++++++++++++++++ net/sched/p4tc/p4tc_tbl_entry.c | 2870 +++++++++++++++++++++++++++++ net/sched/p4tc/p4tc_tmpl_api.c | 611 ++++++ net/sched/p4tc/p4tc_tmpl_ext.c | 2221 ++++++++++++++++++++++ net/sched/p4tc/p4tc_types.c | 1247 +++++++++++++ net/sched/p4tc/trace.c | 10 + net/sched/p4tc/trace.h | 44 + security/selinux/nlmsgtab.c | 10 +- 30 files changed, 16676 insertions(+), 39 deletions(-) create mode 100644 include/net/p4tc.h create mode 100644 include/net/p4tc_ext_api.h create mode 100644 include/net/p4tc_types.h create mode 100644 include/net/tc_act/p4tc.h create mode 100644 include/uapi/linux/p4tc.h create mode 100644 include/uapi/linux/p4tc_ext.h create mode 100644 net/sched/cls_p4.c create mode 100644 net/sched/p4tc/Makefile create mode 100644 net/sched/p4tc/p4tc_action.c create mode 100644 net/sched/p4tc/p4tc_bpf.c create mode 100644 net/sched/p4tc/p4tc_ext.c create mode 100644 net/sched/p4tc/p4tc_pipeline.c create mode 100644 net/sched/p4tc/p4tc_runtime_api.c create mode 100644 net/sched/p4tc/p4tc_table.c create mode 100644 net/sched/p4tc/p4tc_tbl_entry.c create mode 100644 net/sched/p4tc/p4tc_tmpl_api.c create mode 100644 net/sched/p4tc/p4tc_tmpl_ext.c create mode 100644 net/sched/p4tc/p4tc_types.c create mode 100644 net/sched/p4tc/trace.c create mode 100644 net/sched/p4tc/trace.h
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerPATCH v8 1/15 net: sched: act_api: Introduce dynamic actions list
In P4 we require to generate new actions "on the fly" based on the specified P4 action definition. Dynamic action kinds, like the pipeline they are attached to, must be per net namespace, as opposed to native action kinds which are global. For that reason, we chose to create a separate structure to store dynamic actions.
--- include/net/act_api.h | 7 ++- net/sched/act_api.c | 123 +++++++++++++++++++++++++++++++++++++----- net/sched/cls_api.c | 2 +- 3 files changed, 115 insertions(+), 17 deletions(-)
include/net/act_api.h +5 -2
@@ -105,6 +105,7 @@ typedef void (*tc_action_priv_destructor)(void *priv);struct tc_action_ops {struct list_head head; +struct list_head dyn_head;char kind[IFNAMSIZ ];enum tca_id id;/* identifier should match kind */ unsigned int net_id;
@@ -198,8 +199,10 @@ int tcf_idr_check_alloc(struct tc_action_net *tn, u32 *index,int tcf_idr_release (struct tc_action *a,bool bind);int tcf_register_action (struct tc_action_ops *a,struct pernet_operations *ops); +int tcf_register_dyn_action (struct net *net,struct tc_action_ops *act);int tcf_unregister_action (struct tc_action_ops *a,struct pernet_operations *ops); +void tcf_unregister_dyn_action (struct net *net,struct tc_action_ops *act);int tcf_action_destroy (struct tc_action *actions[],int bind);int tcf_action_exec (struct sk_buff *skb,struct tc_action **actions,int nr_actions,struct tcf_result *res);
@@ -207,8 +210,8 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla,struct nlattr *est, struct tc_action *actions[], int init_res[], size_t *attr_size, u32 flags, u32 fl_flags, struct netlink_ext_ack *extack); -struct tc_action_ops *tc_action_load_ops (struct nlattr *nla,bool police, -bool rtnl_held, +struct tc_action_ops *tc_action_load_ops (struct net *net,struct nlattr *nla, +bool police,bool rtnl_held,struct netlink_ext_ack *extack); struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, struct nlattr *nla, struct nlattr *est,
net/sched/act_api.c +109 -14
215 lines not on this page · raw message
net/sched/cls_api.c +1 -1
@@ -3293,7 +3293,7 @@ int tcf_exts_validate_ex(struct net *net, struct tcf_proto *tp, struct nlattr **if (exts->police && tb[exts->police]) {struct tc_action_ops *a_o; - a_o =tc_action_load_ops (tb[exts->police], true, + a_o =tc_action_load_ops (net, tb[exts->police], true, !(flags &TCA_ACT_FLAGS_NO_RTNL ), extack);if (IS_ERR (a_o))
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerPATCH v8 2/15 net/sched: act_api: increase action kind string length
In reply to Jamal Hadi SalimIncrease action kind string length from IFNAMSIZ to 64
The new P4TC dynamic actions, created via templates, will have longer names of format: "pipeline_name/act_name". IFNAMSIZ is currently 16 and is most of the times undersized for the above format.
So, to conform to this new format, we increase the maximum name length to account for this extra string (pipeline name) and the '/' character.
--- include/net/act_api.h | 2 +- include/uapi/linux/pkt_cls.h | 1 + net/sched/act_api.c | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-)
include/net/act_api.h +1 -1
@@ -106,7 +106,7 @@ typedef void (*tc_action_priv_destructor)(void *priv);struct tc_action_ops {struct list_head head;struct list_head dyn_head; -char kind[IFNAMSIZ ]; +char kind[ACTNAMSIZ ];enum tca_id id;/* identifier should match kind */ unsigned int net_id;size_t size;
include/uapi/linux/pkt_cls.h +1 -0
@@ -6,6 +6,7 @@#include <linux/pkt_sched.h> #define TC_COOKIE_MAX_SIZE 16 +#define ACTNAMSIZ 64/* Action attributes */ enum {
net/sched/act_api.c +3 -3
@@ -476,7 +476,7 @@ static size_t tcf_action_shared_attrs_size(const struct tc_action *act)rcu_read_unlock ();return nla_total_size (0 )/* action number nested */ - +nla_total_size (IFNAMSIZ )/* TCA_ACT_KIND */ + +nla_total_size (ACTNAMSIZ )/* TCA_ACT_KIND */ + cookie_len/* TCA_ACT_COOKIE */ +nla_total_size (sizeof (struct nla_bitfield32 ))/* TCA_ACT_HW_STATS */ +nla_total_size (0 )/* TCA_ACT_STATS nested */
@@ -1393,7 +1393,7 @@ struct tc_action_ops *tc_action_load_ops(struct net *net, struct nlattr *nla, {struct nlattr *tb[TCA_ACT_MAX +1 ];struct tc_action_ops *a_o; -char act_name[IFNAMSIZ ]; +char act_name[ACTNAMSIZ ];struct nlattr *kind;int err;
@@ -1408,7 +1408,7 @@ struct tc_action_ops *tc_action_load_ops(struct net *net, struct nlattr *nla,NL_SET_ERR_MSG (extack,"TC action kind must be specified" );return ERR_PTR (err); } -if (nla_strscpy (act_name, kind,IFNAMSIZ ) <0 ) { +if (nla_strscpy (act_name, kind,ACTNAMSIZ ) <0 ) {NL_SET_ERR_MSG (extack,"TC action name too long" );return ERR_PTR (err); }
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerPATCH v8 3/15 net/sched: act_api: Update tc_action_ops to account for dynamic actions
In reply to Jamal Hadi SalimThe initialisation of P4TC action instances require access to a struct p4tc_act (which appears in later patches) to help us to retrieve information like the dynamic action parameters etc. In order to retrieve struct p4tc_act we need the pipeline name or id and the action name or id. Also recall that P4TC action IDs are dynamic and are net namespace specific. The init callback from tc_action_ops parameters had no way of supplying us that information. To solve this issue, we decided to create a new tc_action_ops callback (init_ops), that provies us with the tc_action_ops struct which then provides us with the pipeline and action name. In addition we add a new refcount to struct tc_action_ops called dyn_ref, which accounts for how many action instances we have of a specific action.
--- include/net/act_api.h | 6 ++++++ net/sched/act_api.c | 14 +++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-)
include/net/act_api.h +6 -0
@@ -109,6 +109,7 @@ struct tc_action_ops {char kind[ACTNAMSIZ ];enum tca_id id;/* identifier should match kind */ unsigned int net_id; +refcount_t dyn_ref;size_t size;struct module *owner; int (*act)(struct sk_buff *, const struct tc_action *,
@@ -120,6 +121,11 @@ struct tc_action_ops { struct nlattr *est, struct tc_action **act, struct tcf_proto *tp, u32 flags, struct netlink_ext_ack *extack); +/* This should be merged with the original init action */ +int (*init_ops)(struct net *net,struct nlattr *nla, +struct nlattr *est,struct tc_action **act, +struct tcf_proto *tp,struct tc_action_ops *ops, +u32 flags,struct netlink_ext_ack *extack); int (*walk)(struct net *, struct sk_buff *, struct netlink_callback *, int, const struct tc_action_ops *,
net/sched/act_api.c +11 -3
@@ -1023,7 +1023,7 @@ int tcf_register_action(struct tc_action_ops *act,struct tc_action_ops *a;int ret; -if (!act->act || !act->dump || !act->init) +if (!act->act || !act->dump || (!act->init && !act->init_ops))return -EINVAL ;/* We have to register pernet ops before making the action ops visible,
@@ -1484,8 +1484,16 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, } } - err = a_o->init (net, tb[TCA_ACT_OPTIONS ], est, &a, tp, - userflags.value | flags, extack); +/* When we arrive here we guarantee that a_o->init or +* a_o->init_ops exist. +*/ +if (a_o->init) + err = a_o->init (net, tb[TCA_ACT_OPTIONS ], est, &a, tp, + userflags.value | flags, extack); +else + err = a_o->init_ops (net, tb[TCA_ACT_OPTIONS ], est, &a, + tp, a_o, userflags.value | flags, + extack); }else { err = a_o->init (net, nla, est, &a, tp, userflags.value | flags, extack);
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerPATCH v8 4/15 net/sched: act_api: add struct p4tc_action_ops as a parameter to lookup callback
In reply to Jamal Hadi SalimFor P4TC dynamic actions, we require information from struct tc_action_ops, specifically the action kind, to find and locate the dynamic action information for the lookup operation.
--- include/net/act_api.h | 3 ++- net/sched/act_api.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
include/net/act_api.h +2 -1
@@ -116,7 +116,8 @@ struct tc_action_ops { struct tcf_result *); /* called under RCU BH lock*/int (*dump)(struct sk_buff *,struct tc_action *,int ,int );void (*cleanup)(struct tc_action *); -int (*lookup)(struct net *net,struct tc_action **a,u32 index); +int (*lookup)(struct net *net,const struct tc_action_ops *ops, +struct tc_action **a,u32 index); int (*init)(struct net *net, struct nlattr *nla, struct nlattr *est, struct tc_action **act, struct tcf_proto *tp,
net/sched/act_api.c +1 -1
@@ -726,7 +726,7 @@ static int __tcf_idr_search(struct net *net,struct tc_action_net *tn =net_generic (net, ops->net_id);if (unlikely (ops->lookup)) -return ops->lookup (net, a, index); +return ops->lookup (net, ops, a, index);return tcf_idr_search (tn, a, index); }
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerPATCH v8 5/15 net: sched: act_api: Add support for preallocated dynamic action instances
In reply to Jamal Hadi SalimIn P4, actions are assumed to pre exist and have an upper bound number of instances. Typically if you have 1M table entries you want to allocate enough action instances to cover the 1M entries. However, this is a big waste of memory if the action instances are not in use. So for our case, we allow the user to specify a minimal amount of actions in the template and then if more dynamic action instances are needed then they will be added on demand as in the current approach with tc filter-action relationship.
Add the necessary code to preallocate actions instances for dynamic actions.
We add 2 new actions flags:
- TCA_ACT_FLAGS_PREALLOC: Indicates the action instance is a dynamic action and was preallocated for future use the templating phase of P4TC
- TCA_ACT_FLAGS_UNREFERENCED: Indicates the action instance was preallocated and is currently not being referenced by any other object. Which means it won't show up in an action instance dump.
Once an action instance is created we don't free it when the last table entry referring to it is deleted.
Instead we add it to the pool/cache of action instances for that specific action i.e it counts as if it is preallocated. Preallocated actions can't be deleted by the tc actions runtime commands and a dump or a get will only show preallocated actions instances which are being used (TCA_ACT_FLAGS_UNREFERENCED == false).
The preallocated actions will be deleted once the pipeline is deleted (which will purge the dynamic action kind and its instances).
For example, if we were to create a dynamic action that preallocates 128 elements and dumped:
$ tc -j p4template get action/myprog/send_nh | jq .
We'd see the following:
[
{
"obj": "action template",
"pname": "myprog",
"pipeid": 1
},
{
"templates": [
{
"aname": "myprog/send_nh",
"actid": 1,
"params": [
{
"name": "port",
"type": "dev",
"id": 1
}
],
"prealloc": 128
}
] }
]
If we try to dump the dynamic action instances, we won't see any:
$ tc -j actions ls action myprog/send_nh | jq .
[]
However, if we create a table entry which references this action kind:
$ tc p4ctrl create myprog/table/cb/FDB \ dstAddr d2:96:91:5d:02:86 action myprog/send_nh \ param port type dev dummy0
Dumping the action instance will now show this one instance which is associated with the table entry:
$ tc -j actions ls action myprog/send_nh | jq .
[
{
"total acts": 1
},
{
"actions": [
{
"order": 0,
"kind": "myprog/send_nh",
"index": 1,
"ref": 1,
"bind": 1,
"params": [
{
"name": "port",
"type": "dev",
"value": "dummy0",
"id": 1
}
],
"not_in_hw": true
}
] }
]
--- include/net/act_api.h | 3 +++ net/sched/act_api.c | 50 ++++++++++++++++++++++++++++++++----------- 2 files changed, 41 insertions(+), 12 deletions(-)
include/net/act_api.h +3 -0
@@ -68,6 +68,8 @@ struct tc_action {#define TCA_ACT_FLAGS_REPLACE (1U << (TCA_ACT_FLAGS_USER_BITS + 2))#define TCA_ACT_FLAGS_NO_RTNL (1U << (TCA_ACT_FLAGS_USER_BITS + 3))#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))/* Update lastuse only if needed, to avoid dirtying a cache line. * We use a temp variable to avoid fetching jiffies twice.
@@ -200,6 +202,7 @@ int tcf_idr_create_from_flags(struct tc_action_net *tn, u32 index, const struct tc_action_ops *ops, int bind, u32 flags);void tcf_idr_insert_many (struct tc_action *actions[]); +void tcf_idr_insert_n (struct tc_action *actions[],const u32 n);void tcf_idr_cleanup (struct tc_action_net *tn,u32 index);int tcf_idr_check_alloc (struct tc_action_net *tn,u32 *index,struct tc_action **a,int bind);
net/sched/act_api.c +38 -12
84 lines not on this page · raw message
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerPATCH v8 6/15 net: introduce rcu_replace_pointer_rtnl
In reply to Jamal Hadi SalimWe use rcu_replace_pointer(rcu_ptr, ptr, lockdep_rtnl_is_held()) throughout the P4TC infrastructure code.
It may be useful for other use cases, so we create a helper.
--- include/linux/rtnetlink.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
include/linux/rtnetlink.h +12 -0
@@ -62,6 +62,18 @@ static inline bool lockdep_rtnl_is_held(void)#define rcu_dereference_rtnl (p) \ rcu_dereference_check(p, lockdep_rtnl_is_held()) +/** +* rcu_replace_pointer_rtnl - replace an RCU pointer under rtnl_lock, returning +* its old value +* @rcu_ptr: RCU pointer, whose old value is returned +* @ptr: regular pointer +* +* Perform a replacement under rtnl_lock, where @rcu_ptr is an RCU-annotated +* pointer. The old value of @rcu_ptr is returned, and @rcu_ptr is set to @ptr +*/ +#define rcu_replace_pointer_rtnl (rcu_ptr, ptr) \ + rcu_replace_pointer(rcu_ptr, ptr, lockdep_rtnl_is_held()) +/** * rtnl_dereference - fetch RCU pointer when updates are prevented by RTNL * @p: The pointer to read, prior to dereferencing
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerPATCH v8 7/15 rtnl: add helper to check if group has listeners
In reply to Jamal Hadi SalimAs of today, rtnl code creates a new skb and unconditionally fills and broadcasts it to the relevant group. For most operations this is okay and doesn't waste resources in general.
For P4TC, it's interesting to know if the TC group has any listeners when adding/updating/deleting table entries as we can optimize for the most likely case it contains none. This not only improves our processing speed, it also reduces pressure on the system memory as we completely avoid the broadcast skb allocation.
--- include/linux/rtnetlink.h | 7 +++++++ 1 file changed, 7 insertions(+)
include/linux/rtnetlink.h +7 -0
@@ -142,4 +142,11 @@ extern int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,extern void rtnl_offload_xstats_notify (struct net_device *dev); +static inline int rtnl_has_listeners (const struct net *net,u32 group) +{ +struct sock *rtnl = net->rtnl; + +return netlink_has_listeners (rtnl, group); +} +#endif /* __LINUX_RTNETLINK_H */
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerPATCH v8 8/15 p4tc: add P4 data types
In reply to Jamal Hadi SalimIntroduce abstraction that represents P4 data types.
This also introduces the Kconfig and Makefile which later patches use. Types could be little, host or big endian definitions. The abstraction also supports defining:
a) bitstrings using P4 annotations that look like "bit<X>" where X is the number of bits defined in a type
b) bitslices such that one can define in P4 as bit<8>[0-3] and bit<16>[4-9]. A 4-bit slice from bits 0-3 and a 6-bit slice from bits 4-9 respectively.
Each type has a bitsize, a name (for debugging purposes), an ID and methods/ops. The P4 types will be used by externs, dynamic actions, packet headers and other parts of P4TC.
Each type has four ops:
- validate_p4t: Which validates if a given value of a specific type meets valid boundary conditions.
- create_bitops: Which, given a bitsize, bitstart and bitend allocates and returns a mask and a shift value. For example, if we have type bit<8>[3-3] meaning bitstart = 3 and bitend = 3, we'll create a mask which would only give us the fourth bit of a bit8 value, that is, 0x08. Since we are interested in the fourth bit, the bit shift value will be 3. This is also useful if an "irregular" bitsize is used, for example, bit24. In that case bitstart = 0 and bitend = 23. Shift will be 0 and the mask will be 0xFFFFFF00 if the machine is big endian.
- host_read : Which reads the value of a given type and transforms it to host order (if needed)
- host_write : Which writes a provided host order value and transforms it to the type's native order (if needed)
--- include/net/p4tc_types.h | 88 +++ include/uapi/linux/p4tc.h | 33 + net/sched/Kconfig | 11 + net/sched/Makefile | 2 + net/sched/p4tc/Makefile | 3 + net/sched/p4tc/p4tc_types.c | 1247 +++++++++++++++++++++++++++++++++++ 6 files changed, 1384 insertions(+) create mode 100644 include/net/p4tc_types.h create mode 100644 include/uapi/linux/p4tc.h create mode 100644 net/sched/p4tc/Makefile create mode 100644 net/sched/p4tc/p4tc_types.c
include/net/p4tc_types.h new file +88 -0
@@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __NET_P4TYPES_H +#define __NET_P4TYPES_H + +#include <linux/netlink.h> +#include <linux/pkt_cls.h> +#include <linux/types.h> + +#include <uapi/linux/p4tc.h> + +#define P4T_MAX_BITSZ 128 + +struct p4tc_type_mask_shift { +void *mask; +u8 shift; +}; + +struct p4tc_type ; +struct p4tc_type_ops { +int (*validate_p4t)(struct p4tc_type *container,void *value,u16 startbit, +u16 endbit,struct netlink_ext_ack *extack); +struct p4tc_type_mask_shift *(*create_bitops)(u16 bitsz, +u16 bitstart, +u16 bitend, +struct netlink_ext_ack *extack); +void (*host_read)(struct p4tc_type *container, +struct p4tc_type_mask_shift *mask_shift,void *sval, +void *dval); +void (*host_write)(struct p4tc_type *container, +struct p4tc_type_mask_shift *mask_shift,void *sval, +void *dval); +void (*print)(struct net *net,struct p4tc_type *container, +const char *prefix,void *val); +}; + +#define P4T_MAX_STR_SZ 32 +struct p4tc_type { +char name[P4T_MAX_STR_SZ ]; +const struct p4tc_type_ops *ops; +size_t container_bitsz; +size_t bitsz; +int typeid; +}; + +struct p4tc_type *p4type_find_byid (int id); +bool p4tc_is_type_unsigned (int typeid); + +void p4t_copy (struct p4tc_type_mask_shift *dst_mask_shift, +struct p4tc_type *dst_t,void *dstv, +struct p4tc_type_mask_shift *src_mask_shift, +struct p4tc_type *src_t,void *srcv); +int p4t_cmp (struct p4tc_type_mask_shift *dst_mask_shift, +struct p4tc_type *dst_t,void *dstv, +struct p4tc_type_mask_shift *src_mask_shift, +struct p4tc_type *src_t,void *srcv); +void p4t_release (struct p4tc_type_mask_shift *mask_shift); + +int p4tc_register_types (void ); +void p4tc_unregister_types (void ); + +#ifdef CONFIG_RETPOLINE +void __p4tc_type_host_read (const struct p4tc_type_ops *ops, +struct p4tc_type *container, +struct p4tc_type_mask_shift *mask_shift,void *sval, +void *dval); +void __p4tc_type_host_write (const struct p4tc_type_ops *ops, +struct p4tc_type *container, +struct p4tc_type_mask_shift *mask_shift,void *sval, +void *dval); +#else +static inline void __p4tc_type_host_read (const struct p4tc_type_ops *ops, +struct p4tc_type *container, +struct p4tc_type_mask_shift *mask_shift, +void *sval,void *dval) +{ +return ops->host_read (container, mask_shift, sval, dval); +} + +static inline void __p4tc_type_host_write (const struct p4tc_type_ops *ops, +struct p4tc_type *container, +struct p4tc_type_mask_shift *mask_shift, +void *sval,void *dval) +{ +return ops->host_write (container, mask_shift, sval, dval); +} +#endif + +#endif
include/uapi/linux/p4tc.h new file +33 -0
@@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __LINUX_P4TC_H +#define __LINUX_P4TC_H + +#define P4TC_MAX_KEYSZ 512 + +enum { +P4T_UNSPEC , +P4T_U8 , +P4T_U16 , +P4T_U32 , +P4T_U64 , +P4T_STRING , +P4T_S8 , +P4T_S16 , +P4T_S32 , +P4T_S64 , +P4T_MACADDR , +P4T_IPV4ADDR , +P4T_BE16 , +P4T_BE32 , +P4T_BE64 , +P4T_U128 , +P4T_S128 , +P4T_BOOL , +P4T_DEV , +P4T_KEY , + __P4T_MAX, +}; + +#define P4T_MAX (__P4T_MAX - 1) + +#endif
net/sched/Kconfig +11 -0
@@ -675,6 +675,17 @@ config NET_EMATCH_IPT To compile this code as a module, choose M here: the module will be called em_ipt. +config NET_P4_TC + bool "P4 TC support" + select NET_CLS_ACT + help + Say Y here if you want to use P4 features on top of TC. + P4 is an open source, domain-specific programming language for + specifying data plane behavior. By enabling P4TC you will be able to + write a P4 program, use a P4 compiler that supports P4TC backend to + generate all needed artificats, which when loaded allow you to + introduce a new kernel datapath that can be controlled via TC. + config NET_CLS_ACT bool "Actions" select NET_CLS
net/sched/Makefile +2 -0
@@ -82,3 +82,5 @@ obj-$(CONFIG_NET_EMATCH_TEXT) += em_text.o obj-$(CONFIG_NET_EMATCH_CANID) += em_canid.o obj-$(CONFIG_NET_EMATCH_IPSET) += em_ipset.o obj-$(CONFIG_NET_EMATCH_IPT) += em_ipt.o + +obj-$(CONFIG_NET_P4_TC) += p4tc/
net/sched/p4tc/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-y := p4tc_types.o
net/sched/p4tc/p4tc_types.c new file +1247 -0
1,247 lines not on this page · raw message
Signature · 1 line
2.34.1
Jiri Pirko
maintainerRe: [PATCH net-next v8 08/15] p4tc: add P4 data types
Thu, Nov 16, 2023 at 03:59:41PM CET, [email protected] wrote:
[...]
Quoted 3 lines
include/net/p4tc_types.h new file +0
-0
[...]
Quoted 1 line
+#define
P4T_MAX_BITSZ128
[...]
Quoted 1 line
+#define
P4T_MAX_STR_SZ32
[...]
Quoted 6 lines
include/uapi/linux/p4tc.h new file +0
-0
include/uapi/linux/p4tc.h line 8
Quoted 8 lines
include/uapi/linux/p4tc.h new file +8
-0@@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __LINUX_P4TC_H +#define __LINUX_P4TC_H + +#define P4TC_MAX_KEYSZ 512 + +enum { + P4T_UNSPEC,
I wonder, what it the reason for "P4T"/"P4TC" prefix inconsistency. In the kernel header, that could be fixes, but in uapi header this is forever. Is this just to be aligned with other TC uapi inconsitencies? :D
Quoted 25 lines
include/uapi/linux/p4tc.h new file +25
-0+P4T_U8 , +P4T_U16 , +P4T_U32 , +P4T_U64 , +P4T_STRING , +P4T_S8 , +P4T_S16 , +P4T_S32 , +P4T_S64 , +P4T_MACADDR , +P4T_IPV4ADDR , +P4T_BE16 , +P4T_BE32 , +P4T_BE64 , +P4T_U128 , +P4T_S128 , +P4T_BOOL , +P4T_DEV , +P4T_KEY , + __P4T_MAX, +}; + +#define P4T_MAX (__P4T_MAX - 1) + +#endif
[...]
Jamal Hadi Salim
maintainerRe: [PATCH net-next v8 08/15] p4tc: add P4 data types
Quoted 31 lines · Jiri Pirko
Thu, Nov 16, 2023 at 03:59:41PM CET, [email protected] wrote:
[...]
Quoted 3 lines
include/net/p4tc_types.h new file +0
-0[...]
Quoted 1 line
+#define
P4T_MAX_BITSZ128[...]
Quoted 1 line
+#define
P4T_MAX_STR_SZ32[...]
Quoted 11 lines
include/uapi/linux/p4tc.h new file +5
-0@@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __LINUX_P4TC_H +#define __LINUX_P4TC_H + +#define P4TC_MAX_KEYSZ 512
Quoted 9 lines
include/uapi/linux/p4tc.h line 8
Quoted 3 lines
include/uapi/linux/p4tc.h new file +3
-0+ +enum { +P4T_UNSPEC ,I wonder, what it the reason for "P4T"/"P4TC" prefix inconsistency. In the kernel header, that could be fixes, but in uapi header this is forever. Is this just to be aligned with other TC uapi inconsitencies? :D
P4T is for "types" - but ok, we can change it to P4TC_XXX for consistency.
cheers,
jamal
Jamal Hadi Salim
maintainerPATCH v8 9/15 p4tc: add template pipeline create, get, update, delete
In reply to Jamal Hadi Salim__Introducing P4 TC Pipeline__
This commit introduces P4 TC pipelines, which emulate the semantics of a P4 program/pipeline using the TC infrastructure.
One can refer to P4 programs/pipelines using their names or their specific pipeline ids (pipeid)
P4 template CRUD (Create, Read/get, Update and Delete) commands apply on a pipeline.
As an example, to create a P4 program/pipeline named aP4proggie with a single table in its pipeline, one would use the following command from user space tc (as generated by the compiler):
tc p4template create pipeline/aP4proggie numtables 1 pipeid 1
Note that, in the above command, the numtables is set as 1; the default is 0 because it is feasible to have a P4 program with no tables at all.
The P4 compiler will generate the pipeid, however if none is specified, the kernel will issue one. Like the following example:
tc p4template create pipeline/aP4proggie numtables 1
To Read pipeline aP4proggie attributes, one would retrieve those details as follows:
tc p4template get pipeline/[aP4proggie] [pipeid 1]
Note that in the above command one may specify pipeline ID, name or both.
To Update aP4proggie pipeline from 1 to 10 tables, one would use the following command:
tc p4template update pipeline/[aP4proggie] [pipeid 1] numtables 10
Note that, in the above command, one could use the P4 program/pipeline name, id or both to specify which P4 program/pipeline to update.
To Delete a P4 program/pipeline named aP4proggie with a pipeid of 1, one would use the following command:
tc p4template del pipeline/[aP4proggie] [pipeid 1]
Note that, in the above command, one could use the P4 program/pipeline name, id or both to specify which P4 program/pipeline to delete
If one wished to dump all the created P4 programs/pipelines, one would use the following command:
tc p4template get pipeline/
__Pipeline Lifetime__
After Create is issued, one can Read/get, Update and Delete; however the pipeline can only be put to use after it is "sealed". To seal a pipeline, one would issue the following command:
tc p4template update pipeline/aP4proggie state ready
After a pipeline is sealed it can be put to use via the TC P4 classifier. For example:
tc filter add dev $DEV ingress protocol any prio 6 p4 pname aP4proggie \
action bpf obj $PARSER.o section prog/tc-parser
action bpf obj $PROGNAME.o section prog/tc-ingress
Instantiates aP4proggie in the ingress of $DEV. One could also attach it to a block of ports (example tc block 22) as such:
tc filter add block 22 ingress protocol all prio 6 p4 pname aP4proggie \
action bpf obj $PARSER.o section prog/tc-parser
action bpf obj $PROGNAME.o section prog/tc-ingress
We can, after that, add a table entry.
Like, for example:
tc p4ctrl create aP4proggie/table/cb/aP4table \
dstAddr 10.10.10.0/24 srcAddr 192.168.0.0/16 prio 16 \
action dropOnce the pipeline is attached to a device or block it cannot be deleted. It becomes Read-only from the control plane/user space.
The pipeline can be deleted when there are no longer any users left.
--- include/net/p4tc.h | 126 +++++++ include/uapi/linux/p4tc.h | 66 ++++ include/uapi/linux/rtnetlink.h | 9 + net/sched/p4tc/Makefile | 2 +- net/sched/p4tc/p4tc_pipeline.c | 611 +++++++++++++++++++++++++++++++++ net/sched/p4tc/p4tc_tmpl_api.c | 585 +++++++++++++++++++++++++++++++ security/selinux/nlmsgtab.c | 6 +- 7 files changed, 1403 insertions(+), 2 deletions(-) create mode 100644 include/net/p4tc.h create mode 100644 net/sched/p4tc/p4tc_pipeline.c create mode 100644 net/sched/p4tc/p4tc_tmpl_api.c
include/net/p4tc.h new file +126 -0
@@ -0,0 +1,126 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __NET_P4TC_H +#define __NET_P4TC_H + +#include <uapi/linux/p4tc.h> +#include <linux/workqueue.h> +#include <net/sch_generic.h> +#include <net/net_namespace.h> +#include <linux/refcount.h> +#include <linux/rhashtable.h> +#include <linux/rhashtable-types.h> + +#define P4TC_DEFAULT_NUM_TABLES P4TC_MINTABLES_COUNT +#define P4TC_DEFAULT_MAX_RULES 1 +#define P4TC_PATH_MAX 3 + +#define P4TC_KERNEL_PIPEID 0 + +#define P4TC_PID_IDX 0 + +struct p4tc_dump_ctx { +u32 ids[P4TC_PATH_MAX ]; +}; + +struct p4tc_template_common ; + +struct p4tc_path_nlattrs { +char *pname; +u32 *ids; +bool pname_passed; +}; + +struct p4tc_pipeline ; +struct p4tc_template_ops { +void (*init)(void ); +struct p4tc_template_common *(*cu)(struct net *net,struct nlmsghdr *n, +struct nlattr *nla, +struct p4tc_path_nlattrs *nl_pname, +struct netlink_ext_ack *extack); +int (*put)(struct p4tc_pipeline *pipeline, +struct p4tc_template_common *tmpl, +struct netlink_ext_ack *extack); +int (*gd)(struct net *net,struct sk_buff *skb,struct nlmsghdr *n, +struct nlattr *nla,struct p4tc_path_nlattrs *nl_pname, +struct netlink_ext_ack *extack); +int (*fill_nlmsg)(struct net *net,struct sk_buff *skb, +struct p4tc_template_common *tmpl, +struct netlink_ext_ack *extack); +int (*dump)(struct sk_buff *skb,struct p4tc_dump_ctx *ctx, +struct nlattr *nla,char **p_name,u32 *ids, +struct netlink_ext_ack *extack); +int (*dump_1)(struct sk_buff *skb,struct p4tc_template_common *common); +}; + +struct p4tc_template_common { +char name[TEMPLATENAMSZ ]; +struct p4tc_template_ops *ops; +u32 p_id; +u32 PAD0; +}; + +extern const struct p4tc_template_ops p4tc_pipeline_ops; + +struct p4tc_pipeline { +struct p4tc_template_common common; +struct rcu_head rcu; +struct net *net; +/* Accounts for how many entities are referencing this pipeline. +* As for now only P4 filters can refer to pipelines. +*/ +refcount_t p_ctrl_ref; +u16 num_tables; +u16 curr_tables; +u8 p_state; +}; + +struct p4tc_pipeline_net { +struct idr pipeline_idr; +}; + +static inline bool p4tc_tmpl_msg_is_update (struct nlmsghdr *n) +{ +return n->nlmsg_type ==RTM_UPDATEP4TEMPLATE ; +} + +int p4tc_tmpl_generic_dump (struct sk_buff *skb,struct p4tc_dump_ctx *ctx, +struct idr *idr,int idx, +struct netlink_ext_ack *extack); + +struct p4tc_pipeline *p4tc_pipeline_find_byany (struct net *net, +const char *p_name, +const u32 pipeid, +struct netlink_ext_ack *extack); +struct p4tc_pipeline *p4tc_pipeline_find_byid (struct net *net, +const u32 pipeid); +struct p4tc_pipeline *p4tc_pipeline_find_get (struct net *net, +const char *p_name, +const u32 pipeid, +struct netlink_ext_ack *extack); + +static inline bool p4tc_pipeline_get (struct p4tc_pipeline *pipeline) +{ +return refcount_inc_not_zero (&pipeline->p_ctrl_ref); +} + +void p4tc_pipeline_put (struct p4tc_pipeline *pipeline); +struct p4tc_pipeline * +p4tc_pipeline_find_byany_unsealed (struct net *net,const char *p_name, +const u32 pipeid, +struct netlink_ext_ack *extack); + +static inline int p4tc_action_destroy (struct tc_action **acts) +{ +int ret =0 ; + +if (acts) { + ret =tcf_action_destroy (acts,TCA_ACT_UNBIND ); +kfree (acts); + } + +return ret; +} + +#define to_pipeline (t) ((struct p4tc_pipeline *)t) + +#endif
include/uapi/linux/p4tc.h +66 -0
78 lines not on this page · raw message
include/uapi/linux/rtnetlink.h +9 -0
@@ -194,6 +194,15 @@ enum { RTM_GETTUNNEL,#define RTM_GETTUNNEL RTM_GETTUNNEL + RTM_CREATEP4TEMPLATE = 124, +#define RTM_CREATEP4TEMPLATE RTM_CREATEP4TEMPLATE + RTM_DELP4TEMPLATE, +#define RTM_DELP4TEMPLATE RTM_DELP4TEMPLATE + RTM_GETP4TEMPLATE, +#define RTM_GETP4TEMPLATE RTM_GETP4TEMPLATE + RTM_UPDATEP4TEMPLATE, +#define RTM_UPDATEP4TEMPLATE RTM_UPDATEP4TEMPLATE + __RTM_MAX,#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1) };
net/sched/p4tc/Makefile +1 -1
@@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 -obj-y := p4tc_types.o +obj-y := p4tc_types.o p4tc_tmpl_api.o p4tc_pipeline.o
net/sched/p4tc/p4tc_pipeline.c new file +611 -0
611 lines not on this page · raw message
net/sched/p4tc/p4tc_tmpl_api.c new file +585 -0
585 lines not on this page · raw message
security/selinux/nlmsgtab.c +5 -1
@@ -94,6 +94,10 @@ static const struct nlmsg_perm nlmsg_route_perms[] = { { RTM_NEWTUNNEL, NETLINK_ROUTE_SOCKET__NLMSG_WRITE }, { RTM_DELTUNNEL, NETLINK_ROUTE_SOCKET__NLMSG_WRITE }, { RTM_GETTUNNEL, NETLINK_ROUTE_SOCKET__NLMSG_READ }, + { RTM_CREATEP4TEMPLATE, NETLINK_ROUTE_SOCKET__NLMSG_WRITE }, + { RTM_DELP4TEMPLATE, NETLINK_ROUTE_SOCKET__NLMSG_WRITE }, + { RTM_GETP4TEMPLATE, NETLINK_ROUTE_SOCKET__NLMSG_READ }, + { RTM_UPDATEP4TEMPLATE, NETLINK_ROUTE_SOCKET__NLMSG_WRITE }, }; static const struct nlmsg_perm nlmsg_tcpdiag_perms[] = {
@@ -177,7 +181,7 @@ int selinux_nlmsg_lookup(u16 sclass, u16 nlmsg_type, u32 *perm)* structures at the top of this file with the new mappings * before updating the BUILD_BUG_ON() macro! */ -BUILD_BUG_ON (RTM_MAX != (RTM_NEWTUNNEL +3 )); +BUILD_BUG_ON (RTM_MAX != (RTM_CREATEP4TEMPLATE +3 )); err =nlmsg_perm (nlmsg_type, perm, nlmsg_route_perms,sizeof (nlmsg_route_perms));break ;
Signature · 1 line
2.34.1
Jiri Pirko
maintainerRe: [PATCH net-next v8 09/15] p4tc: add template pipeline create, get, update, delete
Thu, Nov 16, 2023 at 03:59:42PM CET, [email protected] wrote:
[...]
Quoted 6 lines
include/uapi/linux/p4tc.h +0
-0@@ -2,8 +2,71 @@#ifndef __LINUX_P4TC_H
include/uapi/linux/p4tc.h line 12
Quoted 10 lines
include/uapi/linux/p4tc.h +8
-0#define __LINUX_P4TC_H +#include <linux/types.h> +#include <linux/pkt_sched.h> + +/* pipeline header */ +struct p4tcmsg { +__u32 pipeid; +__u32 obj; +};
I don't follow. Is there any sane reason to use header instead of normal netlink attribute? Moveover, you extend the existing RT netlink with a huge amout of p4 things. Isn't this the good time to finally introduce generic netlink TC family with proper yaml spec with all the benefits it brings and implement p4 tc uapi there? Please?
include/uapi/linux/p4tc.h line 22
Quoted 10 lines
include/uapi/linux/p4tc.h +8
-0+ +#define P4TC_MAXPIPELINE_COUNT 32 +#define P4TC_MAXTABLES_COUNT 32 +#define P4TC_MINTABLES_COUNT 0 +#define P4TC_MSGBATCH_SIZE 16 +#define P4TC_MAX_KEYSZ 512 +#define TEMPLATENAMSZ 32 +#define PIPELINENAMSIZ TEMPLATENAMSZ
ugh. A prefix please?
pw-bot: cr
[...]
Jamal Hadi Salim
maintainerRe: [PATCH net-next v8 09/15] p4tc: add template pipeline create, get, update, delete
Quoted 14 lines · Jiri Pirko
Thu, Nov 16, 2023 at 03:59:42PM CET, [email protected] wrote:
[...]
Quoted 8 lines
include/uapi/linux/p4tc.h +0
-0@@ -2,8 +2,71 @@#ifndef __LINUX_P4TC_H#define __LINUX_P4TC_H
Quoted 15 lines
include/uapi/linux/p4tc.h line 12
Quoted 8 lines
include/uapi/linux/p4tc.h +8
-0+#include <linux/types.h> +#include <linux/pkt_sched.h> + +/* pipeline header */ +struct p4tcmsg { +__u32 pipeid; +__u32 obj; +};I don't follow. Is there any sane reason to use header instead of normal netlink attribute? Moveover, you extend the existing RT netlink with a huge amout of p4 things. Isn't this the good time to finally introduce generic netlink TC family with proper yaml spec with all the benefits it brings and implement p4 tc uapi there? Please?
Several reasons:
a) We are similar to current tc messaging with the subheader being there for multiplexing.
b) Where does this leave iproute2? +Cc David and Stephen. Do other generic netlink conversions get contributed back to iproute2?
c) note: Our API is CRUD-ish instead of RPC(per generic netlink) based. i.e you have:
COMMAND <PATH/TO/OBJECT> [optional data] so we can support arbitrary
P4 programs from the control plane.
d) we have spent many hours optimizing the control to the kernel so i am not sure what it would buy us to switch to generic netlink..
cheers,
jamal
Quoted 17 lines
include/uapi/linux/p4tc.h line 22
Quoted 11 lines
include/uapi/linux/p4tc.h +8
-0+ +#define P4TC_MAXPIPELINE_COUNT 32 +#define P4TC_MAXTABLES_COUNT 32 +#define P4TC_MINTABLES_COUNT 0 +#define P4TC_MSGBATCH_SIZE 16 +#define P4TC_MAX_KEYSZ 512 +#define TEMPLATENAMSZ 32 +#define PIPELINENAMSIZ TEMPLATENAMSZugh. A prefix please?
pw-bot: cr
[...]
Jiri Pirko
maintainerRe: [PATCH net-next v8 09/15] p4tc: add template pipeline create, get, update, delete
Quoted 31 lines · Fri, Nov 17, 2023 at 01:09:45PM CET, [email protected] wrote:
Quoted 14 lines · Jiri Pirko
Thu, Nov 16, 2023 at 03:59:42PM CET, [email protected] wrote:
[...]
Quoted 8 lines
include/uapi/linux/p4tc.h +0
-0@@ -2,8 +2,71 @@#ifndef __LINUX_P4TC_H#define __LINUX_P4TC_HQuoted 15 lines
include/uapi/linux/p4tc.h line 12
Quoted 8 lines
include/uapi/linux/p4tc.h +8
-0+#include <linux/types.h> +#include <linux/pkt_sched.h> + +/* pipeline header */ +struct p4tcmsg { +__u32 pipeid; +__u32 obj; +};I don't follow. Is there any sane reason to use header instead of normal netlink attribute? Moveover, you extend the existing RT netlink with a huge amout of p4 things. Isn't this the good time to finally introduce generic netlink TC family with proper yaml spec with all the benefits it brings and implement p4 tc uapi there? Please?
Quoted 3 lines
Several reasons:
a) We are similar to current tc messaging with the subheader being there for multiplexing.
Yeah, you don't need to carry 20year old burden in newly introduced interface. That's my point.
Quoted 2 lines
b) Where does this leave iproute2? +Cc David and Stephen. Do other generic netlink conversions get contributed back to iproute2?
There is no conversion afaik, only extensions. And they has to be, otherwise the user would not be able to use the newly introduced features.
Quoted 4 lines
c) note: Our API is CRUD-ish instead of RPC(per generic netlink) based. i.e you have:
COMMAND <PATH/TO/OBJECT> [optional data] so we can support arbitrary P4 programs from the control plane.
I'm pretty sure you can achieve the same over genetlink.
Quoted 2 lines
d) we have spent many hours optimizing the control to the kernel so i am not sure what it would buy us to switch to generic netlink..
All the benefits of ynl yaml tooling, at least.
Quoted 21 lines
cheers,
jamalQuoted 17 lines
include/uapi/linux/p4tc.h line 22
Quoted 11 lines
include/uapi/linux/p4tc.h +8
-0+ +#define P4TC_MAXPIPELINE_COUNT 32 +#define P4TC_MAXTABLES_COUNT 32 +#define P4TC_MINTABLES_COUNT 0 +#define P4TC_MSGBATCH_SIZE 16 +#define P4TC_MAX_KEYSZ 512 +#define TEMPLATENAMSZ 32 +#define PIPELINENAMSIZ TEMPLATENAMSZugh. A prefix please?
pw-bot: cr
[...]
Jamal Hadi Salim
maintainerRe: [PATCH net-next v8 09/15] p4tc: add template pipeline create, get, update, delete
Quoted 33 lines · Jiri Pirko
Quoted 31 lines · Fri, Nov 17, 2023 at 01:09:45PM CET, [email protected] wrote:
Quoted 29 lines · Jiri Pirko
Thu, Nov 16, 2023 at 03:59:42PM CET, [email protected] wrote:
[...]
Quoted 6 lines
include/uapi/linux/p4tc.h +0
-0@@ -2,8 +2,71 @@#ifndef __LINUX_P4TC_Hinclude/uapi/linux/p4tc.h line 12
Quoted 10 lines
include/uapi/linux/p4tc.h +8
-0#define __LINUX_P4TC_H +#include <linux/types.h> +#include <linux/pkt_sched.h> + +/* pipeline header */ +struct p4tcmsg { +__u32 pipeid; +__u32 obj; +};I don't follow. Is there any sane reason to use header instead of normal netlink attribute? Moveover, you extend the existing RT netlink with a huge amout of p4 things. Isn't this the good time to finally introduce generic netlink TC family with proper yaml spec with all the benefits it brings and implement p4 tc uapi there? Please?
Quoted 6 lines
Quoted 3 lines
Several reasons:
a) We are similar to current tc messaging with the subheader being there for multiplexing.Yeah, you don't need to carry 20year old burden in newly introduced interface. That's my point.
Having a demux sub header is 20 year old burden? I didnt follow.
Quoted 7 lines
Quoted 3 lines
b) Where does this leave iproute2? +Cc David and Stephen. Do other generic netlink conversions get contributed back to iproute2?
There is no conversion afaik, only extensions. And they has to be, otherwise the user would not be able to use the newly introduced features.
The big question is does the collective who use iproute2 still get to use the same tooling or now they have to go and learn some new tooling. I understand the value of the new approach but is it a revolution or an evolution? We opted to put thing in iproute2 instead for example because that is widely available (and used).
Quoted 8 lines
Quoted 5 lines
c) note: Our API is CRUD-ish instead of RPC(per generic netlink) based. i.e you have:
COMMAND <PATH/TO/OBJECT> [optional data] so we can support arbitrary P4 programs from the control plane.I'm pretty sure you can achieve the same over genetlink.
I think you are right.
Quoted 6 lines
Quoted 3 lines
d) we have spent many hours optimizing the control to the kernel so i am not sure what it would buy us to switch to generic netlink..
All the benefits of ynl yaml tooling, at least.
Did you pay close attention to what we have? The user space code is written once into iproute2 and subsequent to that there is no recompilation of any iproute2 code. The compiler generates a json file specific to a P4 program which is then introspected by the iproute2 code.
cheers,
jamal
Quoted 22 lines
Quoted 22 lines
cheers,
jamalQuoted 17 lines
include/uapi/linux/p4tc.h line 22
Quoted 11 lines
include/uapi/linux/p4tc.h +8
-0+ +#define P4TC_MAXPIPELINE_COUNT 32 +#define P4TC_MAXTABLES_COUNT 32 +#define P4TC_MINTABLES_COUNT 0 +#define P4TC_MSGBATCH_SIZE 16 +#define P4TC_MAX_KEYSZ 512 +#define TEMPLATENAMSZ 32 +#define PIPELINENAMSIZ TEMPLATENAMSZugh. A prefix please?
pw-bot: cr
[...]
Jiri Pirko
maintainerRe: [PATCH net-next v8 09/15] p4tc: add template pipeline create, get, update, delete
Quoted 34 lines · Mon, Nov 20, 2023 at 01:48:14PM CET, [email protected] wrote:
Quoted 33 lines · Jiri Pirko
Quoted 31 lines · Fri, Nov 17, 2023 at 01:09:45PM CET, [email protected] wrote:
Quoted 29 lines · Jiri Pirko
Thu, Nov 16, 2023 at 03:59:42PM CET, [email protected] wrote:
[...]
Quoted 6 lines
include/uapi/linux/p4tc.h +0
-0@@ -2,8 +2,71 @@#ifndef __LINUX_P4TC_Hinclude/uapi/linux/p4tc.h line 12
Quoted 10 lines
include/uapi/linux/p4tc.h +8
-0#define __LINUX_P4TC_H +#include <linux/types.h> +#include <linux/pkt_sched.h> + +/* pipeline header */ +struct p4tcmsg { +__u32 pipeid; +__u32 obj; +};I don't follow. Is there any sane reason to use header instead of normal netlink attribute? Moveover, you extend the existing RT netlink with a huge amout of p4 things. Isn't this the good time to finally introduce generic netlink TC family with proper yaml spec with all the benefits it brings and implement p4 tc uapi there? Please?
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Several reasons:
a) We are similar to current tc messaging with the subheader being there for multiplexing.Yeah, you don't need to carry 20year old burden in newly introduced interface. That's my point.
Having a demux sub header is 20 year old burden? I didnt follow.
You don't need the header, that's my point.
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
b) Where does this leave iproute2? +Cc David and Stephen. Do other generic netlink conversions get contributed back to iproute2?
There is no conversion afaik, only extensions. And they has to be, otherwise the user would not be able to use the newly introduced features.
Quoted 5 lines
The big question is does the collective who use iproute2 still get to use the same tooling or now they have to go and learn some new tooling. I understand the value of the new approach but is it a revolution or an evolution? We opted to put thing in iproute2 instead for example because that is widely available (and used).
I don't see why iproute2 user facing interface would be any different depending on if you user RTnetlink or genetlink as backend channel...
Quoted 16 lines
Quoted 9 lines
Quoted 6 lines
c) note: Our API is CRUD-ish instead of RPC(per generic netlink) based. i.e you have:
COMMAND <PATH/TO/OBJECT> [optional data] so we can support arbitrary P4 programs from the control plane.I'm pretty sure you can achieve the same over genetlink.
I think you are right.
Quoted 4 lines
Quoted 3 lines
d) we have spent many hours optimizing the control to the kernel so i am not sure what it would buy us to switch to generic netlink..
Quoted 8 lines
Quoted 2 lines
All the benefits of ynl yaml tooling, at least.
Did you pay close attention to what we have? The user space code is written once into iproute2 and subsequent to that there is no recompilation of any iproute2 code. The compiler generates a json file specific to a P4 program which is then introspected by the iproute2 code.
Right, but in real life, netlink is used directly by many apps. I don't see why this is any different.
Plus, the very best part of yaml from user perpective I see is, you just need the kernel-git yaml file and you can submit all commands. No userspace implementation needed.
Quoted 27 lines
cheers,
jamalQuoted 22 lines
Quoted 22 lines
cheers,
jamalQuoted 17 lines
include/uapi/linux/p4tc.h line 22
Quoted 11 lines
include/uapi/linux/p4tc.h +8
-0+ +#define P4TC_MAXPIPELINE_COUNT 32 +#define P4TC_MAXTABLES_COUNT 32 +#define P4TC_MINTABLES_COUNT 0 +#define P4TC_MSGBATCH_SIZE 16 +#define P4TC_MAX_KEYSZ 512 +#define TEMPLATENAMSZ 32 +#define PIPELINENAMSIZ TEMPLATENAMSZugh. A prefix please?
pw-bot: cr
[...]
Jamal Hadi Salim
maintainerRe: [PATCH net-next v8 09/15] p4tc: add template pipeline create, get, update, delete
Quoted 40 lines · Jiri Pirko
Quoted 38 lines · Mon, Nov 20, 2023 at 01:48:14PM CET, [email protected] wrote:
Quoted 37 lines · Jiri Pirko
Quoted 34 lines · Fri, Nov 17, 2023 at 01:09:45PM CET, [email protected] wrote:
Quoted 14 lines · Jiri Pirko
Thu, Nov 16, 2023 at 03:59:42PM CET, [email protected] wrote:
[...]
Quoted 8 lines
include/uapi/linux/p4tc.h +0
-0@@ -2,8 +2,71 @@#ifndef __LINUX_P4TC_H#define __LINUX_P4TC_HQuoted 15 lines
include/uapi/linux/p4tc.h line 12
Quoted 8 lines
include/uapi/linux/p4tc.h +8
-0+#include <linux/types.h> +#include <linux/pkt_sched.h> + +/* pipeline header */ +struct p4tcmsg { +__u32 pipeid; +__u32 obj; +};I don't follow. Is there any sane reason to use header instead of normal netlink attribute? Moveover, you extend the existing RT netlink with a huge amout of p4 things. Isn't this the good time to finally introduce generic netlink TC family with proper yaml spec with all the benefits it brings and implement p4 tc uapi there? Please?
Several reasons:
a) We are similar to current tc messaging with the subheader being there for multiplexing.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Yeah, you don't need to carry 20year old burden in newly introduced interface. That's my point.
Having a demux sub header is 20 year old burden? I didnt follow.
You don't need the header, that's my point.
Let me see if i understand you:
We have multiple object types per pipeline - this info is _omni present and it is never going to change_.
Your view is, have a hierarchy of attributes and put this subheader in probably one attribute at the root.
You parse the root, you find the obj and pipeid and then you use that to parse the rest of the per-object specific
attributes?
I dont know if a hierarchical attribute layout gives you any advantage over the subheader approach - unless we figure a way to annotate attributes as "optional" vs "must be present". I agree that getting the validation for free is a bonus ..
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
b) Where does this leave iproute2? +Cc David and Stephen. Do other generic netlink conversions get contributed back to iproute2?
There is no conversion afaik, only extensions. And they has to be, otherwise the user would not be able to use the newly introduced features.
Quoted 9 lines
Quoted 5 lines
The big question is does the collective who use iproute2 still get to use the same tooling or now they have to go and learn some new tooling. I understand the value of the new approach but is it a revolution or an evolution? We opted to put thing in iproute2 instead for example because that is widely available (and used).
I don't see why iproute2 user facing interface would be any different depending on if you user RTnetlink or genetlink as backend channel...
iproute2 supports plenty of genetlink already. We need to find a way to have the best of both worlds.
Quoted 20 lines
Quoted 20 lines
Quoted 10 lines
Quoted 7 lines
c) note: Our API is CRUD-ish instead of RPC(per generic netlink) based. i.e you have:
COMMAND <PATH/TO/OBJECT> [optional data] so we can support arbitrary P4 programs from the control plane.I'm pretty sure you can achieve the same over genetlink.
I think you are right.
Quoted 6 lines
Quoted 3 lines
d) we have spent many hours optimizing the control to the kernel so i am not sure what it would buy us to switch to generic netlink..
All the benefits of ynl yaml tooling, at least.
Quoted 9 lines
Quoted 5 lines
Did you pay close attention to what we have? The user space code is written once into iproute2 and subsequent to that there is no recompilation of any iproute2 code. The compiler generates a json file specific to a P4 program which is then introspected by the iproute2 code.
Right, but in real life, netlink is used directly by many apps. I don't see why this is any different.
Not sure if you were referring to what i said about the json file or something else. The main value is not just kernel independence but also iproute2 independence i.e not need to compile any code.
Quoted 3 lines
Plus, the very best part of yaml from user perpective I see is, you just need the kernel-git yaml file and you can submit all commands. No userspace implementation needed.
Two different tacts: i can see this as being developer friendly (and we are more trying to be operator friendly).
I need to take a closer look. Sounds like it should be polyglot friendly as well. If i am not mistaken you still have to compile code as a result of generation from the yaml?
cheers,
jamal
Quoted 28 lines
Quoted 28 lines
cheers,
jamalQuoted 22 lines
Quoted 22 lines
cheers,
jamalQuoted 17 lines
include/uapi/linux/p4tc.h line 22
Quoted 11 lines
include/uapi/linux/p4tc.h +8
-0+ +#define P4TC_MAXPIPELINE_COUNT 32 +#define P4TC_MAXTABLES_COUNT 32 +#define P4TC_MINTABLES_COUNT 0 +#define P4TC_MSGBATCH_SIZE 16 +#define P4TC_MAX_KEYSZ 512 +#define TEMPLATENAMSZ 32 +#define PIPELINENAMSIZ TEMPLATENAMSZugh. A prefix please?
pw-bot: cr
[...]
Jiri Pirko
maintainerRe: [PATCH net-next v8 09/15] p4tc: add template pipeline create, get, update, delete
Quoted 46 lines · Mon, Nov 20, 2023 at 04:30:11PM CET, [email protected] wrote:
Quoted 45 lines · Jiri Pirko
Quoted 42 lines · Mon, Nov 20, 2023 at 01:48:14PM CET, [email protected] wrote:
Quoted 33 lines · Jiri Pirko
Quoted 31 lines · Fri, Nov 17, 2023 at 01:09:45PM CET, [email protected] wrote:
Quoted 29 lines · Jiri Pirko
Thu, Nov 16, 2023 at 03:59:42PM CET, [email protected] wrote:
[...]
Quoted 6 lines
include/uapi/linux/p4tc.h +0
-0@@ -2,8 +2,71 @@#ifndef __LINUX_P4TC_Hinclude/uapi/linux/p4tc.h line 12
Quoted 10 lines
include/uapi/linux/p4tc.h +8
-0#define __LINUX_P4TC_H +#include <linux/types.h> +#include <linux/pkt_sched.h> + +/* pipeline header */ +struct p4tcmsg { +__u32 pipeid; +__u32 obj; +};I don't follow. Is there any sane reason to use header instead of normal netlink attribute? Moveover, you extend the existing RT netlink with a huge amout of p4 things. Isn't this the good time to finally introduce generic netlink TC family with proper yaml spec with all the benefits it brings and implement p4 tc uapi there? Please?
Quoted 6 lines
Quoted 3 lines
Several reasons:
a) We are similar to current tc messaging with the subheader being there for multiplexing.Yeah, you don't need to carry 20year old burden in newly introduced interface. That's my point.
Having a demux sub header is 20 year old burden? I didnt follow.
Quoted 8 lines
Quoted 2 lines
You don't need the header, that's my point.
Let me see if i understand you:
We have multiple object types per pipeline - this info is_omnipresent and it is never going tochange_.
Your view is, have a hierarchy of attributes and put this subheader in probably one attribute at the root.
That or use genetlink to have per-cmd attributes.
Quoted 70 lines
You parse the root, you find the obj and pipeid and then you use that to parse the rest of the per-object specific
attributes?I dont know if a hierarchical attribute layout gives you any advantage over the subheader approach - unless we figure a way to annotate attributes as "optional" vs "must be present". I agree that getting the validation for free is a bonus ..
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
b) Where does this leave iproute2? +Cc David and Stephen. Do other generic netlink conversions get contributed back to iproute2?
There is no conversion afaik, only extensions. And they has to be, otherwise the user would not be able to use the newly introduced features.
Quoted 9 lines
Quoted 5 lines
The big question is does the collective who use iproute2 still get to use the same tooling or now they have to go and learn some new tooling. I understand the value of the new approach but is it a revolution or an evolution? We opted to put thing in iproute2 instead for example because that is widely available (and used).
I don't see why iproute2 user facing interface would be any different depending on if you user RTnetlink or genetlink as backend channel...
iproute2 supports plenty of genetlink already. We need to find a way to have the best of both worlds.
Quoted 20 lines
Quoted 20 lines
Quoted 10 lines
Quoted 7 lines
c) note: Our API is CRUD-ish instead of RPC(per generic netlink) based. i.e you have:
COMMAND <PATH/TO/OBJECT> [optional data] so we can support arbitrary P4 programs from the control plane.I'm pretty sure you can achieve the same over genetlink.
I think you are right.
Quoted 6 lines
Quoted 3 lines
d) we have spent many hours optimizing the control to the kernel so i am not sure what it would buy us to switch to generic netlink..
All the benefits of ynl yaml tooling, at least.
Quoted 9 lines
Quoted 5 lines
Did you pay close attention to what we have? The user space code is written once into iproute2 and subsequent to that there is no recompilation of any iproute2 code. The compiler generates a json file specific to a P4 program which is then introspected by the iproute2 code.
Right, but in real life, netlink is used directly by many apps. I don't see why this is any different.
Not sure if you were referring to what i said about the json file or something else. The main value is not just kernel independence but also iproute2 independence i.e not need to compile any code.
Quoted 3 lines
Plus, the very best part of yaml from user perpective I see is, you just need the kernel-git yaml file and you can submit all commands. No userspace implementation needed.
Quoted 5 lines
Two different tacts: i can see this as being developer friendly (and we are more trying to be operator friendly).
I need to take a closer look. Sounds like it should be polyglot friendly as well. If i am not mistaken you still have to compile code as a result of generation from the yaml?
Nope, you can run ynl.py and let it parse the yaml on fly.
Quoted 32 lines
cheers,
jamalQuoted 28 lines
Quoted 28 lines
cheers,
jamalQuoted 22 lines
Quoted 22 lines
cheers,
jamalQuoted 17 lines
include/uapi/linux/p4tc.h line 22
Quoted 11 lines
include/uapi/linux/p4tc.h +8
-0+ +#define P4TC_MAXPIPELINE_COUNT 32 +#define P4TC_MAXTABLES_COUNT 32 +#define P4TC_MINTABLES_COUNT 0 +#define P4TC_MSGBATCH_SIZE 16 +#define P4TC_MAX_KEYSZ 512 +#define TEMPLATENAMSZ 32 +#define PIPELINENAMSIZ TEMPLATENAMSZugh. A prefix please?
pw-bot: cr
[...]
Re: [PATCH net-next v8 09/15] p4tc: add template pipeline create, get, update, delete
In reply to Jamal Hadi SalimQuoted 8 lines · Jamal Hadi Salim
Quoted 8 lines
Quoted 8 lines
include/uapi/linux/p4tc.h +0
-0@@ -2,8 +2,71 @@#ifndef __LINUX_P4TC_H#define __LINUX_P4TC_H
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
include/uapi/linux/p4tc.h +6
-0+#include <linux/types.h> +#include <linux/pkt_sched.h> + +/* pipeline header */ +struct p4tcmsg { +__u32 pipeid;Quoted 9 lines
include/uapi/linux/p4tc.h line 12
Quoted 2 lines
include/uapi/linux/p4tc.h +2
-0+__u32 obj; +};I don't follow. Is there any sane reason to use header instead of normal netlink attribute? Moveover, you extend the existing RT netlink with a huge amout of p4 things. Isn't this the good time to finally introduce generic netlink TC family with proper yaml spec with all the benefits it brings and implement p4 tc uapi there? Please?
There is precedence (new netdev APIs) to move new infra to genl, but it is not clear to me if extending existing functionality should fall into that required conversion.
Quoted 13 lines
Several reasons:
a) We are similar to current tc messaging with the subheader being there for multiplexing.
b) Where does this leave iproute2? +Cc David and Stephen. Do other generic netlink conversions get contributed back to iproute2?
c) note: Our API is CRUD-ish instead of RPC(per generic netlink) based. i.e you have:
COMMAND <PATH/TO/OBJECT> [optional data] so we can support arbitrary
P4 programs from the control plane.
d) we have spent many hours optimizing the control to the kernel so i am not sure what it would buy us to switch to generic netlink..
Jamal Hadi Salim
maintainerRe: [PATCH net-next v8 09/15] p4tc: add template pipeline create, get, update, delete
Quoted 26 lines · David Ahern
Quoted 8 lines · Jamal Hadi Salim
Quoted 8 lines
Quoted 8 lines
include/uapi/linux/p4tc.h +0
-0@@ -2,8 +2,71 @@#ifndef __LINUX_P4TC_H#define __LINUX_P4TC_HQuoted 15 lines
Quoted 6 lines
Quoted 6 lines
include/uapi/linux/p4tc.h +6
-0+#include <linux/types.h> +#include <linux/pkt_sched.h> + +/* pipeline header */ +struct p4tcmsg { +__u32 pipeid;Quoted 9 lines
include/uapi/linux/p4tc.h line 12
Quoted 2 lines
include/uapi/linux/p4tc.h +2
-0+__u32 obj; +};I don't follow. Is there any sane reason to use header instead of normal netlink attribute? Moveover, you extend the existing RT netlink with a huge amout of p4 things. Isn't this the good time to finally introduce generic netlink TC family with proper yaml spec with all the benefits it brings and implement p4 tc uapi there? Please?
Quoted 4 lines
There is precedence (new netdev APIs) to move new infra to genl, but it is not clear to me if extending existing functionality should fall into that required conversion.
Big question is: how does the genl (which i am assuming you mean the ynl stuff) fit back into iproute2?
The yaml files approach is a great deal of help for maintenance IMO (a lot of repetitive code gone). But do we leave the rest of the masses out? What is the motivation for pushing anything to be shared? And if the answer is to convert everything onwards into genl then where is the central location to grab that code from? Is it still iproute2 or the kernel? etc
cheers,
jamal
Quoted 14 lines
Quoted 13 lines
Several reasons:
a) We are similar to current tc messaging with the subheader being there for multiplexing.
b) Where does this leave iproute2? +Cc David and Stephen. Do other generic netlink conversions get contributed back to iproute2?
c) note: Our API is CRUD-ish instead of RPC(per generic netlink) based. i.e you have:
COMMAND <PATH/TO/OBJECT> [optional data] so we can support arbitrary
P4 programs from the control plane.
d) we have spent many hours optimizing the control to the kernel so i am not sure what it would buy us to switch to generic netlink..
Jamal Hadi Salim
maintainerPATCH v8 10/15 p4tc: add action template create, update, delete, get, flush and dump
In reply to Jamal Hadi SalimThis commit allows users to create, update, delete, get, flush and dump dynamic action kinds based on P4 action definition.
At the moment dynamic actions are tied to P4 programs only and cannot be used outside of a P4 program definition.
Visualize the following action in a P4 program:
action ipv4_forward(@tc_type("macaddr) bit<48> dstAddr, @tc_type("dev") bit<8> port)
{
// Action code (generated by the compiler)
}The above is an action called ipv4_forward which receives as parameters a bit<48> dstAddr (a mac address) and a bit<8> port (something close to ifindex).
which is invoked on a P4 table match as such:
table mytable {
key = {
hdr.ipv4.dstAddr @tc_type("ipv4"): lpm;
}
actions = {
ipv4_forward;
drop;
NoAction;
}
size = 1024;
}We don't have an equivalent built in "ipv4_forward" action in TC. So we create this action dynamically.
The mechanics of dynamic actions follow the CRUD semantics.
___DYNAMIC ACTION KIND CREATION___
In this stage we issue the creation command for the dynamic action which specifies the action name, its ID, parameters and the parameter types. So for the ipv4_forward action, the creation would look something like this:
tc p4template create action/aP4proggie/ipv4_forward \
param dstAddr type macaddr id 1 param port type dev id 2
Note1: Although the P4 program defined dstAddr as type bit48 we use our type called macaddr (likewise for port) - see commit on p4 types for details.
Note2: All the template commands (tc p4template) are generated by the p4c compiler.
Note that in the template creation op we usually just specify the action name, the parameters and their respective types. Also see that we specify a pipeline name during the template creation command. As an example, the above command creates an action template that is bounded to pipeline or program named aP4proggie.
Note, In P4, actions are assumed to pre-exist and have an upper bound number of instances. Typically if you have 1M table entries you want to allocate enough action instances to cover the 1M entries. However, this is a big waste waste of memory if the action instances are not in use. So for our case, we allow the user to specify a minimal amount of actions instances in the template and then if more dynamic action instances are needed then they will be added on demand as in the current approach with tc filter-action relationship. For example, if one were to create the action ipv4_forward preallocating 128 instances, one would issue the following command:
tc p4template create action/aP4proggie/ipv4_forward num_prealloc 128 \
param dstAddr type macaddr id 1 param port type dev id 2
By default, 16 action instances will be preallocated.
If the user wishes to have more actions instances, they will have to be created individually by the control plane using the tc actions command. For example:
tc actions add action aP4proggie/ipv4_forward \
param dstAddr AA:BB:CC:DD:EE:DD param port eth1
Only then they can issue a table entry creation command using this newly created action instance.
Note, this does not disqualify a user from binding to an existing action instances. For example:
tc p4ctrl create aP4proggie/table/mycontrol/mytable \
srcAddr 10.10.10.0/24 action ipv4_forward index 1
___ACTION KIND ACTIVATION___
Once we provided all the necessary information for the new dynamic action, we can go to the final stage, which is action activation. In this stage, we activate the dynamic action and make it available for instantiation. To activate the action template, we issue the following command:
tc p4template update action aP4proggie/ipv4_forward state active
After the above the command, the action is ready to be instantiated.
___RUNTIME___
This next section deals with the runtime part of action templates, which handle action template instantiation and binding.
To instantiate a new action that was created from a template, we use the following command:
tc actions add action aP4proggie/ipv4_forward \
param dstAddr AA:BB:CC:DD:EE:FF param port eth0 index 1
Observe these are the same semantics as what tc today already provides with a caveat that we have a keyword "param" to precede the appropriate parameters - as such specifying the index is optional (kernel provides one when unspecified).
As previously stated, we refer to the action by it's "full name" (pipeline_name/action_name). Here we are creating an instance of the ipv4_forward action specifying as parameter values AA:BB:CC:DD:EE:FF for dstAddr and eth0 for port. We can create as many instances for action templates as we wish.
To bind the above instantiated action to a table entry, you can do use the same classical approach used to bind ordinary actions to filters, for example:
tc p4ctrl create aP4proggie/table/mycontrol/mytable \
srcAddr 10.10.10.0/24 action ipv4_forward index 1
The above command will bind our newly instantiated action to a table entry which is executed if there's a match.
Of course one could have created the table entry as:
tc p4ctrl create aP4proggie/table/mycontrol/mytable \
srcAddr 10.10.10.0/24 \
action ipv4_forward param dstAddr AA:BB:CC:DD:EE:FF param port eth0
Actions from other P4 control blocks (in the same pipeline) might be referenced as the action index is global within a pipeline.
___OTHER CONTROL COMMANDS___
The lifetime of the dynamic action is tied to its pipeline.
As with all pipeline components, write operations to action templates, such as create, update and delete, can only be executed if the pipeline is not sealed. Read/get can be issued even after the pipeline is sealed.
If, after we are done with our action template we want to delete it, we should issue the following command:
tc p4template del action/aP4proggie/ipv4_forward
Note: If any instance was created for this action (as illustrated ealier) than this action cannot be deleted, unless you delete all instances first.
If we had created more action templates and wanted to flush all of the action templates from pipeline aP4proggie, one would use the following command:
tc p4template del action/aP4proggie/
After creating or updating a dynamic actions, if one wishes to verify that the dynamic action was created correctly, one would use the following command:
tc p4template get action/aP4proggie/ipv4_forward
The above command will display the relevant data for the action, such as parameter names, types, etc.
If one wanted to check which action templates were associated to a specific pipeline, one could use the following command:
tc p4template get action/aP4proggie/
Note that this command will only display the name of these action templates. To verify their specific details, one should use the get command, which was previously described.
--- include/net/act_api.h | 1 + include/net/p4tc.h | 149 ++- include/net/tc_act/p4tc.h | 28 + include/uapi/linux/p4tc.h | 56 + net/sched/p4tc/Makefile | 3 +- net/sched/p4tc/p4tc_action.c | 2242 ++++++++++++++++++++++++++++++++ net/sched/p4tc/p4tc_pipeline.c | 16 +- net/sched/p4tc/p4tc_tmpl_api.c | 18 + 8 files changed, 2509 insertions(+), 4 deletions(-) create mode 100644 include/net/tc_act/p4tc.h create mode 100644 net/sched/p4tc/p4tc_action.c
include/net/act_api.h +1 -0
@@ -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.
include/net/p4tc.h +148 -1
191 lines not on this page · raw message
include/net/tc_act/p4tc.h new file +28 -0
@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __NET_TC_ACT_P4_H +#define __NET_TC_ACT_P4_H + +#include <net/pkt_cls.h> +#include <net/act_api.h> + +struct tcf_p4act_params { +struct tcf_exts exts; +struct idr params_idr; +struct p4tc_act_param **params_array; +struct rcu_head rcu; +u32 num_params; +u32 tot_params_sz; +}; + +struct tcf_p4act { +struct tc_action common; +/* Params IDR reference passed during runtime */ +struct tcf_p4act_params __rcu *params; +u32 p_id; +u32 act_id; +struct list_head node; +}; + +#define to_p4act (a) ((struct tcf_p4act *)a) + +#endif /* __NET_TC_ACT_P4_H */
include/uapi/linux/p4tc.h +56 -0
89 lines not on this page · raw message
net/sched/p4tc/Makefile +2 -1
@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -obj-y := p4tc_types.o p4tc_tmpl_api.o p4tc_pipeline.o +obj-y := p4tc_types.o p4tc_tmpl_api.o p4tc_pipeline.o \ + p4tc_action.o
net/sched/p4tc/p4tc_action.c new file +2242 -0
2,242 lines not on this page · raw message
net/sched/p4tc/p4tc_pipeline.c +14 -2
@@ -74,6 +74,8 @@ static const struct nla_policy tc_pipeline_policy[P4TC_PIPELINE_MAX + 1] = {static void p4tc_pipeline_destroy (struct p4tc_pipeline *pipeline) { +idr_destroy (&pipeline->p_act_idr); +kfree (pipeline); }
@@ -95,8 +97,12 @@ static void p4tc_pipeline_teardown(struct p4tc_pipeline *pipeline,struct net *net = pipeline->net;struct p4tc_pipeline_net *pipe_net =net_generic (net, pipeline_net_id);struct net *pipeline_net =maybe_get_net (net); +unsigned long iter_act_id; +struct p4tc_act *act; +unsigned long tmp; -idr_remove (&pipe_net->pipeline_idr, pipeline->common.p_id); +idr_for_each_entry_ul (&pipeline->p_act_idr, act, tmp, iter_act_id) + act->common.ops->put (pipeline, &act->common, extack);/* If we are on netns cleanup we can't touch the pipeline_idr. * On pre_exit we will destroy the idr but never call into teardown
@@ -151,6 +157,7 @@ static inline int pipeline_try_set_state_ready(struct p4tc_pipeline *pipeline, } pipeline->p_state =P4TC_STATE_READY ; +return true; }
@@ -248,6 +255,10 @@ static struct p4tc_pipeline *p4tc_pipeline_create(struct net *net,else pipeline->num_tables =P4TC_DEFAULT_NUM_TABLES ; +idr_init (&pipeline->p_act_idr); + + pipeline->num_created_acts =0 ; + pipeline->p_state =P4TC_STATE_NOT_READY ; pipeline->net = net;
@@ -502,7 +513,8 @@ static int p4tc_pipeline_gd(struct net *net, struct sk_buff *skb,return PTR_ERR (pipeline); tmpl = (struct p4tc_template_common *)pipeline; -if (p4tc_pipeline_fill_nlmsg (net, skb, tmpl, extack) <0 ) + ret =p4tc_pipeline_fill_nlmsg (net, skb, tmpl, extack); +if (ret <0 )return -1 ;if (!ids[P4TC_PID_IDX ])
net/sched/p4tc/p4tc_tmpl_api.c +18 -0
@@ -42,6 +42,7 @@ static bool obj_is_valid(u32 obj) {switch (obj) {case P4TC_OBJ_PIPELINE : +case P4TC_OBJ_ACT :return true;default :return false;
@@ -50,6 +51,7 @@ static bool obj_is_valid(u32 obj)static const struct p4tc_template_ops *p4tc_ops[P4TC_OBJ_MAX +1 ] = { [P4TC_OBJ_PIPELINE ] = &p4tc_pipeline_ops, + [P4TC_OBJ_ACT ] = &p4tc_act_ops, }; int p4tc_tmpl_generic_dump(struct sk_buff *skb, struct p4tc_dump_ctx *ctx,
@@ -124,6 +126,11 @@ static int tc_ctl_p4_tmpl_gd_1(struct net *net, struct sk_buff *skb, ids[P4TC_PID_IDX ] = t->pipeid; +if (tb[P4TC_PATH ]) { +const u32 *arg_ids =nla_data (tb[P4TC_PATH ]); + +memcpy (&ids[P4TC_PID_IDX +1 ], arg_ids,nla_len (tb[P4TC_PATH ])); + } nl_path_attrs->ids = ids; op = (struct p4tc_template_ops *)p4tc_ops[t->obj];
@@ -311,6 +318,12 @@ p4tc_tmpl_cu_1(struct sk_buff *skb, struct net *net, struct nlmsghdr *n, } ids[P4TC_PID_IDX ] = t->pipeid; + +if (tb[P4TC_PATH ]) { +const u32 *arg_ids =nla_data (tb[P4TC_PATH ]); + +memcpy (&ids[P4TC_PID_IDX +1 ], arg_ids,nla_len (tb[P4TC_PATH ])); + } nl_path_attrs->ids = ids; op = (struct p4tc_template_ops *)p4tc_ops[t->obj];
@@ -504,6 +517,11 @@ static int tc_ctl_p4_tmpl_dump_1(struct sk_buff *skb, struct nlattr *arg, root =nla_nest_start (skb,P4TC_ROOT ); ids[P4TC_PID_IDX ] = t->pipeid; +if (tb[P4TC_PATH ]) { +const u32 *arg_ids =nla_data (tb[P4TC_PATH ]); + +memcpy (&ids[P4TC_PID_IDX +1 ], arg_ids,nla_len (tb[P4TC_PATH ])); + } op = (struct p4tc_template_ops *)p4tc_ops[t->obj]; ret = op->dump (skb, ctx, tb[P4TC_PARAMS ], &p_name, ids, extack);
Signature · 1 line
2.34.1
Jiri Pirko
maintainerRe: [PATCH net-next v8 10/15] p4tc: add action template create, update, delete, get, flush and dump
Thu, Nov 16, 2023 at 03:59:43PM CET, [email protected] wrote:
[...]
Quoted 17 lines
include/net/act_api.h +1
-0@@ -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. include/net/p4tc.h +0
-0
include/net/p4tc.h line 18
Quoted 10 lines
include/net/p4tc.h +3
-0@@ -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?
Quoted 33 lines
include/net/p4tc.h +10
-0#define P4TC_KERNEL_PIPEID 0#define P4TC_PID_IDX 0 +#define P4TC_AID_IDX 1 +#define P4TC_PARSEID_IDX 1struct 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);
include/net/p4tc.h p4tc_pipeline_find_byany_unsealed(struct net *net, const char *p_name, · line 133
Quoted 10 lines
include/net/p4tc.h +4
-1+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.
[...]
Quoted 13 lines
include/uapi/linux/p4tc.h +1
-0@@ -4,6 +4,7 @@#include <linux/types.h> #include <linux/pkt_sched.h> +#include <linux/pkt_cls.h> /* pipeline header */ struct p4tcmsg {
include/uapi/linux/p4tc.h struct p4tcmsg { · line 26
Quoted 9 lines
include/uapi/linux/p4tc.h +3
-0@@ -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?
[...]
Quoted 31 lines
net/sched/p4tc/p4tc_action.c new file +25
-0@@ -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 <[email protected]> +* Victor Nogueira <[email protected]> +* Pedro Tammela <[email protected]> +*/ + +#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>
net/sched/p4tc/p4tc_action.c line 35
Quoted 10 lines
net/sched/p4tc/p4tc_action.c new file +10
-0+#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:
Quoted 37 lines
net/sched/p4tc/p4tc_action.c new file +37
-0+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,
net/sched/p4tc/p4tc_action.c
Quoted 10 lines
net/sched/p4tc/p4tc_action.c new file +10
-0+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 :/
Jamal Hadi Salim
maintainerRe: [PATCH net-next v8 10/15] p4tc: add action template create, update, delete, get, flush and dump
Quoted 29 lines · Jiri Pirko
Thu, Nov 16, 2023 at 03:59:43PM CET, [email protected] wrote:
[...]
Quoted 23 lines
include/net/act_api.h +1
-0@@ -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. include/net/p4tc.h +2
-0@@ -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>
Quoted 7 lines
include/net/p4tc.h line 18
Quoted 4 lines
include/net/p4tc.h +1
-0#define P4TC_DEFAULT_NUM_TABLES P4TC_MINTABLES_COUNT#define P4TC_DEFAULT_MAX_RULES 1#define P4TC_PATH_MAX 3 +#define P4TC_MAX_TENTRIES 33554432Seeing define like this one always makes me happier. Where does it come from? Why not
0x2000000at least?
I dont recall why we decided to do decimal - will change it.
Quoted 40 lines
Quoted 40 lines
include/net/p4tc.h +12
-0#define P4TC_KERNEL_PIPEID 0#define P4TC_PID_IDX 0 +#define P4TC_AID_IDX 1 +#define P4TC_PARSEID_IDX 1struct 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 ;
Quoted 7 lines
include/net/p4tc.h p4tc_pipeline_find_byany_unsealed(struct net *net, const char *p_name, · line 133
Quoted 4 lines
include/net/p4tc.h +2
-1if (acts) { - ret =tcf_action_destroy (acts,TCA_ACT_UNBIND ); +int j =0 ; +int i;Move declarations to the beginning of the if body.
Didnt follow - which specific declaration?
Quoted 21 lines
[...]
Quoted 18 lines
include/uapi/linux/p4tc.h +2
-0@@ -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
Quoted 7 lines
include/uapi/linux/p4tc.h struct p4tcmsg { · line 26
Quoted 4 lines
include/uapi/linux/p4tc.h +2
-0#define TEMPLATENAMSZ 32#define PIPELINENAMSIZ TEMPLATENAMSZ +#define ACTTMPLNAMSIZ TEMPLATENAMSZ +#define ACTPARAMNAMSIZ TEMPLATENAMSZPrefix? This is uapi. Could you please be more careful with naming at least in the uapi area?
Good point.
Quoted 39 lines
[...]
Quoted 35 lines
net/sched/p4tc/p4tc_action.c new file +29
-0@@ -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 <[email protected]> +* Victor Nogueira <[email protected]> +* Pedro Tammela <[email protected]> +*/ + +#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>
Quoted 9 lines
net/sched/p4tc/p4tc_action.c line 35
Quoted 6 lines
net/sched/p4tc/p4tc_action.c new file +6
-0+#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.
We'll get rid of it.
Quoted 44 lines
To quote a few function names in this file:
Quoted 42 lines
net/sched/p4tc/p4tc_action.c new file +42
-0+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,
Quoted 8 lines
net/sched/p4tc/p4tc_action.c
Quoted 5 lines
net/sched/p4tc/p4tc_action.c new file +5
-0+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 :/
What would be better? tcf_p4_xxxx?
A lot of the tcf_xxx is because that convention is used in that file but we can change it.
cheers,
jamal
Quoted 1 line
Jiri Pirko
maintainerRe: [PATCH net-next v8 10/15] p4tc: add action template create, update, delete, get, flush and dump
Quoted 88 lines · Fri, Nov 17, 2023 at 04:11:29PM CET, [email protected] wrote:
Quoted 29 lines · Jiri Pirko
Thu, Nov 16, 2023 at 03:59:43PM CET, [email protected] wrote:
[...]
Quoted 23 lines
include/net/act_api.h +1
-0@@ -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. include/net/p4tc.h +2
-0@@ -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> Quoted 7 lines
include/net/p4tc.h line 18
Quoted 4 lines
include/net/p4tc.h +1
-0#define P4TC_DEFAULT_NUM_TABLES P4TC_MINTABLES_COUNT#define P4TC_DEFAULT_MAX_RULES 1#define P4TC_PATH_MAX 3 +#define P4TC_MAX_TENTRIES 33554432Seeing define like this one always makes me happier. Where does it come from? Why not
0x2000000at least?I dont recall why we decided to do decimal - will change it.
Quoted 40 lines
Quoted 40 lines
include/net/p4tc.h +12
-0#define P4TC_KERNEL_PIPEID 0#define P4TC_PID_IDX 0 +#define P4TC_AID_IDX 1 +#define P4TC_PARSEID_IDX 1struct 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 ;Quoted 7 lines
include/net/p4tc.h p4tc_pipeline_find_byany_unsealed(struct net *net, const char *p_name, · line 133
Quoted 4 lines
include/net/p4tc.h +2
-1if (acts) { - ret =tcf_action_destroy (acts,TCA_ACT_UNBIND ); +int j =0 ; +int i;Move declarations to the beginning of the if body.
Quoted 1 line
Didnt follow - which specific declaration?
It should look like this:
int j = 0; int i; ret = tcf_action_destroy(acts, TCA_ACT_UNBIND);
Quoted 136 lines
Quoted 22 lines
[...]
Quoted 18 lines
include/uapi/linux/p4tc.h +2
-0@@ -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 16Quoted 7 lines
include/uapi/linux/p4tc.h struct p4tcmsg { · line 26
Quoted 4 lines
include/uapi/linux/p4tc.h +2
-0#define TEMPLATENAMSZ 32#define PIPELINENAMSIZ TEMPLATENAMSZ +#define ACTTMPLNAMSIZ TEMPLATENAMSZ +#define ACTPARAMNAMSIZ TEMPLATENAMSZPrefix? This is uapi. Could you please be more careful with naming at least in the uapi area?
Good point.
Quoted 39 lines
[...]
Quoted 35 lines
net/sched/p4tc/p4tc_action.c new file +29
-0@@ -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 <[email protected]> +* Victor Nogueira <[email protected]> +* Pedro Tammela <[email protected]> +*/ + +#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> Quoted 9 lines
net/sched/p4tc/p4tc_action.c line 35
Quoted 6 lines
net/sched/p4tc/p4tc_action.c new file +6
-0+#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.
We'll get rid of it.
Quoted 44 lines
To quote a few function names in this file:
Quoted 42 lines
net/sched/p4tc/p4tc_action.c new file +42
-0+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,Quoted 8 lines
net/sched/p4tc/p4tc_action.c
Quoted 5 lines
net/sched/p4tc/p4tc_action.c new file +5
-0+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 :/
Quoted 1 line
What would be better?
tcf_p4_xxxx?
Idk, up to you, just please maintain some basic naming consistency and prefixes.
Quoted 6 lines
A lot of the
tcf_xxxis because that convention is used in that file but we can change it.cheers,
jamalQuoted 1 line
Jamal Hadi Salim
maintainerRe: [PATCH net-next v8 10/15] p4tc: add action template create, update, delete, get, flush and dump
Quoted 90 lines · Jiri Pirko
Quoted 88 lines · Fri, Nov 17, 2023 at 04:11:29PM CET, [email protected] wrote:
Quoted 29 lines · Jiri Pirko
Thu, Nov 16, 2023 at 03:59:43PM CET, [email protected] wrote:
[...]
Quoted 23 lines
include/net/act_api.h +1
-0@@ -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. include/net/p4tc.h +2
-0@@ -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> Quoted 7 lines
include/net/p4tc.h line 18
Quoted 4 lines
include/net/p4tc.h +1
-0#define P4TC_DEFAULT_NUM_TABLES P4TC_MINTABLES_COUNT#define P4TC_DEFAULT_MAX_RULES 1#define P4TC_PATH_MAX 3 +#define P4TC_MAX_TENTRIES 33554432Seeing define like this one always makes me happier. Where does it come from? Why not
0x2000000at least?I dont recall why we decided to do decimal - will change it.
Quoted 47 lines
Quoted 34 lines
include/net/p4tc.h +10
-0#define P4TC_KERNEL_PIPEID 0#define P4TC_PID_IDX 0 +#define P4TC_AID_IDX 1 +#define P4TC_PARSEID_IDX 1struct 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);include/net/p4tc.h p4tc_pipeline_find_byany_unsealed(struct net *net, const char *p_name, · line 133
Quoted 10 lines
include/net/p4tc.h +4
-1+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.
Quoted 8 lines
Quoted 1 line
Didnt follow - which specific declaration?
It should look like this:
int j = 0; int i; ret = tcf_action_destroy(acts, TCA_ACT_UNBIND);
Huh? It does look like that already ;-> Note there's a "-" on that line.
Quoted 137 lines
Quoted 137 lines
Quoted 23 lines
[...]
Quoted 18 lines
include/uapi/linux/p4tc.h +2
-0@@ -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 16Quoted 7 lines
include/uapi/linux/p4tc.h struct p4tcmsg { · line 26
Quoted 4 lines
include/uapi/linux/p4tc.h +2
-0#define TEMPLATENAMSZ 32#define PIPELINENAMSIZ TEMPLATENAMSZ +#define ACTTMPLNAMSIZ TEMPLATENAMSZ +#define ACTPARAMNAMSIZ TEMPLATENAMSZPrefix? This is uapi. Could you please be more careful with naming at least in the uapi area?
Good point.
Quoted 39 lines
[...]
Quoted 35 lines
net/sched/p4tc/p4tc_action.c new file +29
-0@@ -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 <[email protected]> +* Victor Nogueira <[email protected]> +* Pedro Tammela <[email protected]> +*/ + +#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> Quoted 9 lines
net/sched/p4tc/p4tc_action.c line 35
Quoted 6 lines
net/sched/p4tc/p4tc_action.c new file +6
-0+#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.
We'll get rid of it.
Quoted 52 lines
To quote a few function names in this file:
Quoted 37 lines
net/sched/p4tc/p4tc_action.c new file +37
-0+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,net/sched/p4tc/p4tc_action.c
Quoted 10 lines
net/sched/p4tc/p4tc_action.c new file +10
-0+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 :/
Quoted 5 lines
Quoted 1 line
What would be better?
tcf_p4_xxxx?Idk, up to you, just please maintain some basic naming consistency and prefixes.
We'll come up with something.
cheers,
jamal
Quoted 7 lines
Quoted 7 lines
A lot of the
tcf_xxxis because that convention is used in that file but we can change it.cheers,
jamalQuoted 1 line
Jiri Pirko
maintainerRe: [PATCH net-next v8 10/15] p4tc: add action template create, update, delete, get, flush and dump
Quoted 93 lines · Mon, Nov 20, 2023 at 02:45:24PM CET, [email protected] wrote:
Quoted 92 lines · Jiri Pirko
Quoted 89 lines · Fri, Nov 17, 2023 at 04:11:29PM CET, [email protected] wrote:
Quoted 29 lines · Jiri Pirko
Thu, Nov 16, 2023 at 03:59:43PM CET, [email protected] wrote:
[...]
Quoted 23 lines
include/net/act_api.h +1
-0@@ -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. include/net/p4tc.h +2
-0@@ -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> Quoted 7 lines
include/net/p4tc.h line 18
Quoted 4 lines
include/net/p4tc.h +1
-0#define P4TC_DEFAULT_NUM_TABLES P4TC_MINTABLES_COUNT#define P4TC_DEFAULT_MAX_RULES 1#define P4TC_PATH_MAX 3 +#define P4TC_MAX_TENTRIES 33554432Seeing define like this one always makes me happier. Where does it come from? Why not
0x2000000at least?I dont recall why we decided to do decimal - will change it.
Quoted 40 lines
Quoted 40 lines
include/net/p4tc.h +12
-0#define P4TC_KERNEL_PIPEID 0#define P4TC_PID_IDX 0 +#define P4TC_AID_IDX 1 +#define P4TC_PARSEID_IDX 1struct 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 ;Quoted 7 lines
include/net/p4tc.h p4tc_pipeline_find_byany_unsealed(struct net *net, const char *p_name, · line 133
Quoted 4 lines
include/net/p4tc.h +2
-1if (acts) { - ret =tcf_action_destroy (acts,TCA_ACT_UNBIND ); +int j =0 ; +int i;Move declarations to the beginning of the if body.
Didnt follow - which specific declaration?
Quoted 8 lines
Quoted 6 lines
It should look like this:
int j = 0; int i; ret = tcf_action_destroy(acts, TCA_ACT_UNBIND);Huh? It does look like that already ;-> Note there's a "-" on that line.
I'm blind. Sorry.
Quoted 156 lines
Quoted 138 lines
Quoted 138 lines
Quoted 24 lines
[...]
Quoted 18 lines
include/uapi/linux/p4tc.h +2
-0@@ -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 16Quoted 7 lines
include/uapi/linux/p4tc.h struct p4tcmsg { · line 26
Quoted 4 lines
include/uapi/linux/p4tc.h +2
-0#define TEMPLATENAMSZ 32#define PIPELINENAMSIZ TEMPLATENAMSZ +#define ACTTMPLNAMSIZ TEMPLATENAMSZ +#define ACTPARAMNAMSIZ TEMPLATENAMSZPrefix? This is uapi. Could you please be more careful with naming at least in the uapi area?
Good point.
Quoted 39 lines
[...]
Quoted 35 lines
net/sched/p4tc/p4tc_action.c new file +29
-0@@ -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 <[email protected]> +* Victor Nogueira <[email protected]> +* Pedro Tammela <[email protected]> +*/ + +#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> Quoted 9 lines
net/sched/p4tc/p4tc_action.c line 35
Quoted 6 lines
net/sched/p4tc/p4tc_action.c new file +6
-0+#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.
We'll get rid of it.
Quoted 52 lines
To quote a few function names in this file:
Quoted 37 lines
net/sched/p4tc/p4tc_action.c new file +37
-0+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,net/sched/p4tc/p4tc_action.c
Quoted 10 lines
net/sched/p4tc/p4tc_action.c new file +10
-0+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 :/
Quoted 5 lines
Quoted 1 line
What would be better?
tcf_p4_xxxx?Idk, up to you, just please maintain some basic naming consistency and prefixes.
We'll come up with something.
cheers,
jamalQuoted 7 lines
Quoted 7 lines
A lot of the
tcf_xxxis because that convention is used in that file but we can change it.cheers,
jamalQuoted 1 line
RE: [PATCH net-next v8 10/15] p4tc: add action template create, update, delete, get, flush and dump
In reply to Jamal Hadi SalimQuoted 11 lines · Jamal Hadi Salim
This commit allows users to create, update, delete, get, flush and dump dynamic action kinds based on P4 action definition.
At the moment dynamic actions are tied to P4 programs only and cannot be used outside of a P4 program definition.
Visualize the following action in a P4 program:
action
ipv4_forward(@tc_type("macaddr) bit<48> dstAddr, @tc_type("dev") bit<8> port){ // Action code (generated by the compiler)
So this is BPF or what?
Quoted 123 lines
}
The above is an action called
ipv4_forwardwhich receives as parameters a bit<48> dstAddr (a mac address) and a bit<8> port (something close to ifindex).which is invoked on a P4 table match as such:
table mytable { key = { hdr.ipv4.dstAddr @tc_type("ipv4"): lpm; } actions = { ipv4_forward; drop; NoAction; } size = 1024; }We don't have an equivalent built in "
ipv4_forward" action in TC. So we create this action dynamically.The mechanics of dynamic actions follow the CRUD semantics.
___DYNAMICACTION KINDCREATION___In this stage we issue the creation command for the dynamic action which specifies the action name, its ID, parameters and the parameter types. So for the
ipv4_forwardaction, the creation would look something like this:tc p4template create action/aP4proggie/ipv4_forward \
param dstAddr type macaddr id 1 param port type dev id 2Note1: Although the P4 program defined dstAddr as type bit48 we use our type called macaddr (likewise for port) - see commit on p4 types for details.
Note2: All the template commands (tc p4template) are generated by the p4c compiler.
Note that in the template creation op we usually just specify the action name, the parameters and their respective types. Also see that we specify a pipeline name during the template creation command. As an example, the above command creates an action template that is bounded to pipeline or program named aP4proggie.
Note, In P4, actions are assumed to pre-exist and have an upper bound number of instances. Typically if you have 1M table entries you want to allocate enough action instances to cover the 1M entries. However, this is a big waste waste of memory if the action instances are not in use. So for our case, we allow the user to specify a minimal amount of actions instances in the template and then if more dynamic action instances are needed then they will be added on demand as in the current approach with tc filter-action relationship. For example, if one were to create the action
ipv4_forwardpreallocating 128 instances, one would issue the following command:tc p4template create action/aP4proggie/ipv4_forward
num_prealloc128 \
param dstAddr type macaddr id 1 param port type dev id 2By default, 16 action instances will be preallocated.
If the user wishes to have more actions instances, they will have to be created individually by the control plane using the tc actions command. For example:tc actions add action aP4proggie/ipv4_forward \
param dstAddr AA:BB:CC:DD:EE:DD param port eth1Only then they can issue a table entry creation command using this newly created action instance.
Note, this does not disqualify a user from binding to an existing action instances. For example:
tc p4ctrl create aP4proggie/table/mycontrol/mytable \ srcAddr 10.10.10.0/24 action ipv4_forward index 1
___ACTIONKINDACTIVATION___Once we provided all the necessary information for the new dynamic action, we can go to the final stage, which is action activation. In this stage, we activate the dynamic action and make it available for instantiation. To activate the action template, we issue the following command:
tc p4template update action aP4proggie/ipv4_forward state active
After the above the command, the action is ready to be instantiated.
___RUNTIME___This next section deals with the runtime part of action templates, which handle action template instantiation and binding.
To instantiate a new action that was created from a template, we use the following command:
tc actions add action aP4proggie/ipv4_forward \
param dstAddr AA:BB:CC:DD:EE:FF param port eth0 index 1Observe these are the same semantics as what tc today already provides with a caveat that we have a keyword "param" to precede the appropriate parameters - as such specifying the index is optional (kernel provides one when unspecified).
As previously stated, we refer to the action by it's "full name" (pipeline_name/action_name). Here we are creating an instance of the
ipv4_forwardaction specifying as parameter values AA:BB:CC:DD:EE:FF for dstAddr and eth0 for port. We can create as many instances for action templates as we wish.To bind the above instantiated action to a table entry, you can do use the same classical approach used to bind ordinary actions to filters, for example:
tc p4ctrl create aP4proggie/table/mycontrol/mytable \ srcAddr 10.10.10.0/24 action ipv4_forward index 1The above command will bind our newly instantiated action to a table entry which is executed if there's a match.
Quoted 9 lines
Of course one could have created the table entry as:
tc p4ctrl create aP4proggie/table/mycontrol/mytable \
srcAddr 10.10.10.0/24 \
actionipv4_forwardparam dstAddr AA:BB:CC:DD:EE:FF param port eth0Actions from other P4 control blocks (in the same pipeline) might be referenced as the action index is global within a pipeline.
Where did what the action actually does get defined? It looks like a label at this point, but without code?
Jamal Hadi Salim
maintainerPATCH v8 11/15 p4tc: add template table create, update, delete, get, flush and dump
In reply to Jamal Hadi SalimThis commit introduces code to creation and maintenance of P4 tables defined in a P4 program.
As with all other P4TC objects, tables' lifetimes conform to extended CRUD operations and are maintained via templates.
It's important to note that write operations, such as create, update and delete can only be made if the pipeline is not sealed.
Per the P4 specification, tables prefix their name with the control block (although this could be overridden by P4 annotations).
As an example, if one were to create a table named table1 in a pipeline named myprog1, on control block "mycontrol", one would use the following command:
tc p4template create table/myprog1/mycontrol/table1 tblid 1 \
keysz 32 nummasks 8 tentries 8192
Above says that we are creating a table (table1) attached to pipeline myprog1 on control block mycontrol. Table1's key size is 32 bits wide and it can have up to 8 associated masks and 8192 entries. The table id for table1 is 1. The table id is typically provided by the compiler.
Parameters such as nummasks (number of masks this table may have) and tentries (maximum number of entries this table may have) may also be omitted in which case 8 masks and 256 entries will be assumed.
Other attributes include:
- Table aging: The aging for the table entries belonging to the table
- Table type: The match type of the table (exact, LPM, or ternary)
- Direct Counter: Table counter instances used directly by the table
- Direct Meter: Table meter instances used directly by the table
If one were to retrieve the table named table1 (before or after the pipeline is sealed) one would use the following command:
tc -j p4template get table/myprog1/mycontrol/table1 | jq .
If one were to dump all the tables from a pipeline named myprog1, one would use the following command:
tc p4template get table/myprog1
If one were to update table1 (before the pipeline is sealed) one would use the following command:
tc p4template update table/myprog1/mycontrol/table1 ....
If one were to delete table1 (before the pipeline is sealed) one would use the following command:
tc p4template del table/myprog1/mycontrol/table1
If one were to flush all the tables from a pipeline named myprog1, control block "mycontrol" one would use the following command:
tc p4template del table/myprog1/mycontrol/
___Table Permissions___
Tables can have permissions which apply to all the entries in the specified table. Permissions are defined for both what the control plane (user space) as well as the data path are allowed to do.
The permissions field is a 16bit value which will hold CRUDXPS (create, read, update, delete, execute, publish and subscribe) permissions for control and data path. Bits 13-7 will have the CRUDXPS values for control and bits 6-0 will have CRUDXPS values for data path. By default each table has the following permissions:
CRUD-PS-R--X--
Which means the control plane can perform CRUDPS operations whereas the data path can only Read and execute on the entries.
The user can override these permissions when creating the table or when updating.
For example, the following command will create a table which will not allow the datapath to create, update or delete entries but give full CRUDP permissions for the control plane.
$TC p4template create table/aP4proggie/cb/tname tblid 1 keysz 64 type lpm \
permissions 0x3D24 ...
Recall that these permissions come in the form of CRUDXPSCRUDXPS, where the first CRUDXPS block is for control and the last is for data path.
So 0x3D24 is equivalent to CR-D-P--R--X--
If we were to issue a read command on a table (tname):
$TC -j p4template get table/aP4proggie/cb/tname | jq .
The output would be the following:
[
{
"obj": "table",
"pname": "aP4Proggie",
"pipeid": 22
},
{
"templates": [
{
"tblid": 1,
"tname": "cb/tname",
"keysz": 64,
"max_entries": 256,
"masks": 8,
"entries": 0,
"permissions": "CRUD-P--R--X--",
"table_type": "lpm",
"acts_list": []
}
] }
]
Note, the permissions concept is more powerful than classical const definition currently taken by P4 which makes everything in a table read-only.
___Initial Table Entries___
Templating can create initial table entries. For example:
tc p4template update table/myprog/cb/tname \
entry srcAddr 10.10.10.10/24 dstAddr 1.1.1.0/24 prio 17
In this command we are "updating" table cb/tname with a new entry. This entry has as its key srcAddr concatenated with dstAddr
(both IPv4 addresses) and prio 17.
If one was to read back the entry by issuing the following command:
tc p4template get table/myprog/cb/tname
They would get:
pipeline id 22
table id 1
table name cb/tname
key_sz 64
max entries 256
masks 8
table entries 1
permissions CRUD-P--R--X--
entry:
entry priority 17[permissions-RUD-P--R--X--]
entry key
srcAddr id:1 size:32b type:ipv4 exact fieldval 10.10.10.10/32
dstAddr id:2 size:32b type:ipv4 exact fieldval 1.1.1.0/24___Table Actions List___
P4 tables allow certain actions but not other to be part of match entry on a table. P4 also defines default actions to be executed when no entries match; we have extended this concept to have a default hit,which is executed upon matching an entry which has no action associated with it.
We also allow flags for each of the actions in this list that specify if the action can be added only as a table entry (tableonly), or only as a default action (defaultonly). If no flags are specified, it is assumed that the action can be used in both contexts.
Both default hit and default miss are optional.
An example of specifying a default miss action is as follows:
tc p4template update table/myprog/cb/mytable \
default_miss_action permissions 0x1124 action dropThe above will drop packets if the entry is not found in mytable. Note the above makes the default action a const. Meaning the control plane can neither replace it nor delete it.
tc p4template update table/myprog/mytable \
default_hit_action permissions 0x3004 action ok
Whereas the above allows a default hit action to accept the packet. The permission 0x3004 (binary 11000000000100) means we have only Create and Read permissions in the control plane and eXecute permissions in the data plane. This means, for example, that now we can only delete the default hit action from the control plane.
--- include/net/p4tc.h | 136 ++- include/net/p4tc_types.h | 2 +- include/uapi/linux/p4tc.h | 122 +++ net/sched/p4tc/Makefile | 2 +- net/sched/p4tc/p4tc_action.c | 13 +- net/sched/p4tc/p4tc_pipeline.c | 23 +- net/sched/p4tc/p4tc_table.c | 1545 ++++++++++++++++++++++++++++++++ net/sched/p4tc/p4tc_tmpl_api.c | 2 + 8 files changed, 1828 insertions(+), 17 deletions(-) create mode 100644 net/sched/p4tc/p4tc_table.c
include/net/p4tc.h +135 -1
@@ -16,10 +16,18 @@#define P4TC_DEFAULT_MAX_RULES 1#define P4TC_PATH_MAX 3#define P4TC_MAX_TENTRIES 33554432 +#define P4TC_DEFAULT_TENTRIES 256 +#define P4TC_MAX_TMASKS 1024 +#define P4TC_DEFAULT_TMASKS 8 +#define P4TC_MAX_T_AGING 864000000 +#define P4TC_DEFAULT_T_AGING 30000 + +#define P4TC_MAX_PERMISSION (GENMASK(P4TC_PERM_MAX_BIT, 0))#define P4TC_KERNEL_PIPEID 0#define P4TC_PID_IDX 0 +#define P4TC_TBLID_IDX 1#define P4TC_AID_IDX 1#define P4TC_PARSEID_IDX 1
@@ -70,6 +78,7 @@ extern const struct p4tc_template_ops p4tc_pipeline_ops;struct p4tc_pipeline {struct p4tc_template_common common;struct idr p_act_idr; +struct idr p_tbl_idr;struct rcu_head rcu;struct net *net;u32 num_created_acts;
@@ -123,6 +132,11 @@ struct p4tc_act *tcf_p4_find_act(struct net *net,void tcf_p4_put_prealloc_act (struct p4tc_act *act,struct tcf_p4act *p4_act); +static inline bool pipeline_sealed (struct p4tc_pipeline *pipeline) +{ +return pipeline->p_state ==P4TC_STATE_READY ; +} +static inline int p4tc_action_destroy (struct tc_action **acts) {struct tc_action *acts_non_prealloc[TCA_ACT_MAX_PRIO ] = {NULL };
@@ -158,6 +172,63 @@ static inline int p4tc_action_destroy(struct tc_action **acts)return ret; } +#define P4TC_CONTROL_PERMISSIONS (GENMASK(13, 7)) +#define P4TC_DATA_PERMISSIONS (GENMASK(6, 0)) + +#define P4TC_TABLE_PERMISSIONS \ + ((GENMASK(P4TC_CTRL_PERM_C_BIT, P4TC_CTRL_PERM_D_BIT)) | \ + P4TC_CTRL_PERM_P | P4TC_CTRL_PERM_S | P4TC_DATA_PERM_R | \ + P4TC_DATA_PERM_X) + +#define P4TC_PERMISSIONS_UNINIT (1 << P4TC_PERM_MAX_BIT) + +struct p4tc_table_defact { +struct tc_action **default_acts; +/* Will have two 7 bits blocks containing CRUDXPS (Create, read, update, +* delete, execute, publish and subscribe) permissions for control plane +* and data plane. The first 5 bits are for control and the next five +* are for data plane. |crudxpscrudxps| if we were to denote it as UNIX +* permission flags. +*/ +__u16 permissions; +struct rcu_head rcu; +}; + +struct p4tc_table_perm { +__u16 permissions; +struct rcu_head rcu; +}; + +struct p4tc_table { +struct p4tc_template_common common; +struct list_head tbl_acts_list; +struct idr tbl_masks_idr; +struct idr tbl_prio_idr; +struct rhltable tbl_entries; +struct p4tc_table_defact __rcu *tbl_default_hitact; +struct p4tc_table_defact __rcu *tbl_default_missact; +struct p4tc_table_perm __rcu *tbl_permissions; +struct p4tc_table_entry_mask __rcu **tbl_masks_array; +unsigned long __rcu *tbl_free_masks_bitmap; +u64 tbl_aging; +/* Locks the available masks IDR which will be used when adding and +* deleting table entries. +*/ +spinlock_t tbl_masks_idr_lock; +u32 tbl_keysz; +u32 tbl_id; +u32 tbl_max_entries; +u32 tbl_max_masks; +u32 tbl_curr_num_masks; +/* Accounts for how many entities refer to this table. Usually just the +* pipeline it belongs to. +*/ +refcount_t tbl_ctrl_ref; +u16 tbl_type; +}; + +extern const struct p4tc_template_ops p4tc_table_ops; +struct p4tc_act_param {struct list_head head;struct rcu_head rcu;
@@ -210,6 +281,12 @@ struct p4tc_act {char full_act_name[ACTNAMSIZ ]; }; +struct p4tc_table_act { +struct list_head node; +struct tc_action_ops *ops; +u8 flags; +}; +extern const struct p4tc_template_ops p4tc_act_ops; static inline int p4tc_action_init(struct net *net, struct nlattr *nla,
@@ -262,12 +339,69 @@ static inline bool p4tc_action_put_ref(struct p4tc_act *act)return refcount_dec_not_one (&act->a_ref); } +struct p4tc_act_param *tcf_param_find_byid (struct idr *params_idr, +const u32 param_id); +struct p4tc_act_param *tcf_param_find_byany (struct p4tc_act *act, +const char *param_name, +const u32 param_id, +struct netlink_ext_ack *extack); + +struct p4tc_table *p4tc_table_find_byany (struct p4tc_pipeline *pipeline, +const char *tblname,const u32 tbl_id, +struct netlink_ext_ack *extack); +struct p4tc_table *p4tc_table_find_byid (struct p4tc_pipeline *pipeline, +const u32 tbl_id); +int p4tc_table_try_set_state_ready (struct p4tc_pipeline *pipeline, +struct netlink_ext_ack *extack); +void p4tc_table_put_mask_array (struct p4tc_pipeline *pipeline); +struct p4tc_table *p4tc_table_find_get (struct p4tc_pipeline *pipeline, +const char *tblname,const u32 tbl_id, +struct netlink_ext_ack *extack); + +static inline bool p4tc_table_put_ref (struct p4tc_table *table) +{ +return refcount_dec_not_one (&table->tbl_ctrl_ref); +} + +struct p4tc_table_default_act_params { +struct p4tc_table_defact *default_hitact; +struct p4tc_table_defact *default_missact; +struct nlattr *default_hit_attr; +struct nlattr *default_miss_attr; +}; + +int +p4tc_table_init_default_acts (struct net *net, +struct p4tc_table_default_act_params *def_params, +struct p4tc_table *table, +struct list_head *acts_list, +struct netlink_ext_ack *extack); + +static inline void +p4tc_table_defacts_acts_copy (struct p4tc_table_defact *defact_copy, +struct p4tc_table_defact *defact_orig) +{ + defact_copy->default_acts = defact_orig->default_acts; +} + +void +p4tc_table_replace_default_acts (struct p4tc_table *table, +struct p4tc_table_default_act_params *def_params, +bool lock_rtnl); + +struct p4tc_table_perm * +p4tc_table_init_permissions (struct p4tc_table *table,u16 permissions, +struct netlink_ext_ack *extack); +void p4tc_table_replace_permissions (struct p4tc_table *table, +struct p4tc_table_perm *tbl_perm, +bool lock_rtnl); +struct tcf_p4act *tcf_p4_get_next_prealloc_act (struct p4tc_act *act);void tcf_p4_set_init_flags (struct tcf_p4act *p4act);#define to_pipeline (t) ((struct p4tc_pipeline *)t) -#define to_hdrfield (t) ((struct p4tc_hdrfield *)t)#define to_act (t) ((struct p4tc_act *)t) +#define to_table (t) ((struct p4tc_table *)t)#endif
include/net/p4tc_types.h +1 -1
@@ -8,7 +8,7 @@#include <uapi/linux/p4tc.h> -#define P4T_MAX_BITSZ 128 +#define P4T_MAX_BITSZ P4TC_MAX_KEYSZstruct p4tc_type_mask_shift {void *mask;
include/uapi/linux/p4tc.h +122 -0
140 lines not on this page · raw message
net/sched/p4tc/Makefile +1 -1
@@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-y := p4tc_types.o p4tc_tmpl_api.o p4tc_pipeline.o \ - p4tc_action.o + p4tc_action.o p4tc_table.o
net/sched/p4tc/p4tc_action.c +6 -7
@@ -655,17 +655,16 @@ static struct p4tc_act_param *param_find_byname(struct idr *params_idr,return NULL ; } -static struct p4tc_act_param *tcf_param_find_byid (struct idr *params_idr, -const u32 param_id) +struct p4tc_act_param *tcf_param_find_byid (struct idr *params_idr, +const u32 param_id) {return idr_find (params_idr, param_id); } -static struct p4tc_act_param * -tcf_param_find_byany (struct p4tc_act *act, -const char *param_name, -const u32 param_id, -struct netlink_ext_ack *extack) +struct p4tc_act_param *tcf_param_find_byany (struct p4tc_act *act, +const char *param_name, +const u32 param_id, +struct netlink_ext_ack *extack) {struct p4tc_act_param *param;int err;
net/sched/p4tc/p4tc_pipeline.c +16 -7
@@ -75,6 +75,7 @@ static const struct nla_policy tc_pipeline_policy[P4TC_PIPELINE_MAX + 1] = {static void p4tc_pipeline_destroy (struct p4tc_pipeline *pipeline) {idr_destroy (&pipeline->p_act_idr); +idr_destroy (&pipeline->p_tbl_idr);kfree (pipeline); }
@@ -97,9 +98,13 @@ static void p4tc_pipeline_teardown(struct p4tc_pipeline *pipeline,struct net *net = pipeline->net;struct p4tc_pipeline_net *pipe_net =net_generic (net, pipeline_net_id);struct net *pipeline_net =maybe_get_net (net); -unsigned long iter_act_id; +unsigned long iter_act_id, tmp; +struct p4tc_table *table;struct p4tc_act *act; -unsigned long tmp; +unsigned long tbl_id; + +idr_for_each_entry_ul (&pipeline->p_tbl_idr, table, tmp, tbl_id) + table->common.ops->put (pipeline, &table->common, extack);idr_for_each_entry_ul (&pipeline->p_act_idr, act, tmp, iter_act_id) act->common.ops->put (pipeline, &act->common, extack);
@@ -150,22 +155,23 @@ static int __p4tc_pipeline_put(struct p4tc_pipeline *pipeline,static inline int pipeline_try_set_state_ready (struct p4tc_pipeline *pipeline,struct netlink_ext_ack *extack) { +int ret; +if (pipeline->curr_tables != pipeline->num_tables) {NL_SET_ERR_MSG (extack,"Must have all table defined to update state to ready" );return -EINVAL ; } + ret =p4tc_table_try_set_state_ready (pipeline, extack); +if (ret <0 ) +return ret; + pipeline->p_state =P4TC_STATE_READY ;return true; } -static inline bool pipeline_sealed (struct p4tc_pipeline *pipeline) -{ -return pipeline->p_state ==P4TC_STATE_READY ; -} -struct p4tc_pipeline *p4tc_pipeline_find_byid (struct net *net,const u32 pipeid) {struct p4tc_pipeline_net *pipe_net;
@@ -257,6 +263,9 @@ static struct p4tc_pipeline *p4tc_pipeline_create(struct net *net,idr_init (&pipeline->p_act_idr); +idr_init (&pipeline->p_tbl_idr); + pipeline->curr_tables =0 ; + pipeline->num_created_acts =0 ; pipeline->p_state =P4TC_STATE_NOT_READY ;
net/sched/p4tc/p4tc_table.c new file +1545 -0
1,545 lines not on this page · raw message
net/sched/p4tc/p4tc_tmpl_api.c +2 -0
@@ -43,6 +43,7 @@ static bool obj_is_valid(u32 obj)switch (obj) {case P4TC_OBJ_PIPELINE :case P4TC_OBJ_ACT : +case P4TC_OBJ_TABLE :return true;default :return false;
@@ -52,6 +53,7 @@ static bool obj_is_valid(u32 obj)static const struct p4tc_template_ops *p4tc_ops[P4TC_OBJ_MAX +1 ] = { [P4TC_OBJ_PIPELINE ] = &p4tc_pipeline_ops, [P4TC_OBJ_ACT ] = &p4tc_act_ops, + [P4TC_OBJ_TABLE ] = &p4tc_table_ops, }; int p4tc_tmpl_generic_dump(struct sk_buff *skb, struct p4tc_dump_ctx *ctx,
Signature · 1 line
2.34.1
Jamal Hadi Salim
maintainerPATCH v8 12/15 p4tc: add runtime table entry create, update, get, delete, flush and dump
In reply to Jamal Hadi SalimTables are conceptually similar to TCAMs and this implementation could be labelled as an "algorithmic" TCAM. Tables have a key of a specific size, maximum number of entries and masks allowed. The basic P4 key types are supported (exact, LPM, ternary, and ranges) although the kernel side is oblivious of all that and sees only bit blobs which it masks before a lookup is performed.
This commit allows users to create, update, delete, get, flush and dump table _entries_ (templates were described in earlier patch).
Note that table entries can only be created once the pipeline template is sealed.
For example, a user issuing the following command:
tc p4ctrl create myprog/table/cb/tname \
dstAddr 10.10.10.0/24 srcAddr 192.168.0.0/16 prio 16 \
action send param port port1
indicates we are creating a table entry in table "cb/tname" (a table residing in control block "cb") on a pipeline named "myprog".
User space tc will create a key which has a value of 0x0a0a0a00c0a00000 (10.10.10.0 concatenated with 192.168.0.0) and a mask value of 0xffffff00ffff0000 (/24 concatenated with /16) that will be sent to the kernel. In addition a priority field of 16 is passed to the kernel as well as the action definition.
The priority field is needed to disambiguate in case two entries match. In that case, the kernel will choose the one with lowest priority number.
If the user wanted to, for example, update our just created entry with an action, they'd issue the following command:
tc p4ctrl update myprog/table/cb/tname srcAddr 10.10.10.0/24 \
dstAddr 192.168.0.0/16 prio 16 action send param port port5
In this case, the user needs to specify the pipeline name, the table name, the key and the priority, so that we can locate the table entry.
If the user wanted to, for example, get the table entry that we just updated, they'd issue the following command:
tc p4ctrl get myprog/table/cb/tname srcAddr 10.10.10.0/24 \
dstAddr 192.168.0.0/16 prio 16
Note that, again, we need to specify the pipeline name, the table name, the key and the priority, so that we can locate the table entry.
If the user wanted to delete the table entry we created, they'd issue the following command:
tc p4ctrl del myprog/table/cb/tname srcAddr 10.10.10.0/24 \
dstAddr 192.168.0.0/16 prio 16
Note that, again, we need to specify the pipeline name, the table name, the key and the priority, so that we can
locate the table entry.
We can also flush all the table entries from a specific table. To flush the table entries of table tname ane pipeline ptables, the user would issue the following command:
tc p4ctrl del myprog/table/cb/tname
We can also dump all the table entries from a specific table. To dump the table entries of table tname and pipeline myprog, the user would issue the following command:
tc p4ctrl get myprog/table/cb/tname
__Table Entry Permissions__
Table entries can have permissions specified when they are being added.
Caveat: we are doing a lot more than what P4 defines because we feel it is necessary.
It should be noted that there are two types of permissions:
- Table permissions which are a property of the table (think directory in file systems). These are set by the template (see earlier patch on table template).
- Table entry permissions which are specific to a table entry (think a file in a directory). This patch describes those permissions.
Furthermore in both cases the permissions are split into datapath vs control path. The template definition can set either one. For example, one could allow for adding table entries by the datapath in case of PNA add-on-miss is needed.
By default tables entries have control plane RUD, meaning the control plane can Read, Update or Delete entries. By default, as well, the control plane can create new entries unless specified otherwise by the template.
Lets see an example of which creates the table "cb/tname" at template time:
tc p4template create table/aP4proggie/cb/tname tblid 1 keysz 64 \
permissions 0x3C24 ...Above is setting the table tname's permission to be 0x3C24 is equivalent to CRUD----R--X-- meaning:
The control plane can Create, Read, Update, Delete The datapath can only Read and Execute table entries. If one was to dump this table with:
tc -j p4template get table/aP4proggie/cb/tname | jq .
The output would be the following:
[
{
"obj": "table",
"pname": "aP4proggie",
"pipeid": 22
},
{
"templates": [
{
"tblid": 1,
"tname": "cb/tname",
"keysz": 64,
"max_entries": 256,
"masks": 8,
"entries": 0,
"permissions": "CRUD----R--X--",
"table_type": "exact",
"acts_list": []
}
] }
]
The expressed permissions above are probably the most practical for most use cases.
__Constant Tables And P4-programmed Defined Entries__
If one wanted to restrict the table to be an equivalent to a "const" then the permissions would be set to be: -R------R--X--
In such a case, typically the P4 program will have some entries defined (see the famous P4 calculate example). The "initial entries" specified in the P4 program will have to be added by the template (as generated by the compiler), as such:
tc p4template update table/aP4proggie/cb/tname \
entry srcAddr 10.10.10.10/24 dstAddr 1.1.1.0/24 prio 17
This table cannot be updated at runtime. Any attempt to add an entry of a table which is read-only at runtime will get a permission denied response back from the kernel.
Note: If one was to create an equivalent for PNA add-on-miss feature for this table, then the template would issue table permissions as:
-R-----CR--X-- PNA doesn't specify whether the datapath can also delete or update entries, but if it did then more appropriate permissions will be:
-R-----CRUDX--
__Mix And Match of RW vs Constant Entries__
Lets look at other scenarios; lets say the table has CRUD----R--X-- permissions as defined by the template...
At runtime the user could add entries which are "const" - by specifying the entry's permission as -R------R--X-- example:
tc p4ctrl create aP4proggie/table/cb/tname srcAddr 10.10.10.10/24 \
dstAddr 1.1.1.0/24 prio 17 permissions 0x1024 action drop
or not specify permissions at all as such:
tc p4ctrl create aP4proggie/table/cb/tname srcAddr 10.10.10.10/24 \
dstAddr 1.1.1.0/24 prio 17 action drop
in which case the table's permissions defined at template time(CRUD----R--X--) are assumed; meaning the table entry can be deleted or updated by the control plane.
__Entries permissions Allowed On A Table Entry Creation At Runtime__
When an entry is added with expressed permissions it has at most to have what the template table definition expressed but could ask for less permission. For example, assuming a table with templated specified permissions of CR-D----R--X--:
An entry created at runtime with permission of -R------R--X-- is allowed but an entry with -RUD----R--X-- will be rejected.
--- include/net/p4tc.h | 124 +- include/uapi/linux/p4tc.h | 68 +- include/uapi/linux/rtnetlink.h | 9 + net/sched/p4tc/Makefile | 3 +- net/sched/p4tc/p4tc_runtime_api.c | 145 ++ net/sched/p4tc/p4tc_table.c | 54 +- net/sched/p4tc/p4tc_tbl_entry.c | 2569 +++++++++++++++++++++++++++++ net/sched/p4tc/p4tc_tmpl_api.c | 4 +- security/selinux/nlmsgtab.c | 6 +- 9 files changed, 2965 insertions(+), 17 deletions(-) create mode 100644 net/sched/p4tc/p4tc_runtime_api.c create mode 100644 net/sched/p4tc/p4tc_tbl_entry.c
include/net/p4tc.h +122 -2
@@ -120,6 +120,11 @@ static inline bool p4tc_pipeline_get(struct p4tc_pipeline *pipeline)return refcount_inc_not_zero (&pipeline->p_ctrl_ref); } +static inline void p4tc_pipeline_put_ref (struct p4tc_pipeline *pipeline) +{ +refcount_dec (&pipeline->p_ctrl_ref); +} +void p4tc_pipeline_put (struct p4tc_pipeline *pipeline);struct p4tc_pipeline * p4tc_pipeline_find_byany_unsealed(struct net *net, const char *p_name,
@@ -182,6 +187,8 @@ static inline int p4tc_action_destroy(struct tc_action **acts)#define P4TC_PERMISSIONS_UNINIT (1 << P4TC_PERM_MAX_BIT) +#define P4TC_MAX_PARAM_DATA_SIZE 124 +struct p4tc_table_defact {struct tc_action **default_acts;/* Will have two 7 bits blocks containing CRUDXPS (Create, read, update,
@@ -203,8 +210,9 @@ struct p4tc_table {struct p4tc_template_common common;struct list_head tbl_acts_list;struct idr tbl_masks_idr; -struct idr tbl_prio_idr; +struct ida tbl_prio_idr;struct rhltable tbl_entries; +struct p4tc_table_entry *tbl_const_entry;struct p4tc_table_defact __rcu *tbl_default_hitact;struct p4tc_table_defact __rcu *tbl_default_missact;struct p4tc_table_perm __rcu *tbl_permissions;
@@ -220,11 +228,14 @@ struct p4tc_table {u32 tbl_max_entries;u32 tbl_max_masks;u32 tbl_curr_num_masks; +/* Accounts for how many entries this table has */ +atomic_t tbl_nelems;/* Accounts for how many entities refer to this table. Usually just the * pipeline it belongs to. */ refcount_t tbl_ctrl_ref;u16 tbl_type; +u16 PAD0 ; };extern const struct p4tc_template_ops p4tc_table_ops;
@@ -289,6 +300,86 @@ struct p4tc_table_act {extern const struct p4tc_template_ops p4tc_act_ops; +extern const struct rhashtable_params entry_hlt_params; + +struct p4tc_table_entry ; +struct p4tc_table_entry_work { +struct work_struct work; +struct p4tc_pipeline *pipeline; +struct p4tc_table_entry *entry; +struct p4tc_table *table; +u16 who_deleted; +bool send_event; +}; + +struct p4tc_table_entry_key { +u32 keysz; +/* Key start */ +u32 maskid; +unsigned char fa_key[]__aligned(8) ; +}; + +struct p4tc_table_entry_value { +u32 prio; +int num_acts; +struct tc_action **acts; +/* Accounts for how many entities are referencing, eg: Data path, +* one or more control path and timer. +*/ +refcount_t entries_ref; +u32 permissions; +struct p4tc_table_entry_tm __rcu *tm; +struct p4tc_table_entry_work *entry_work; +u64 aging_ms; +struct hrtimer entry_timer; +bool is_dyn; +}; + +struct p4tc_table_entry_mask { +struct rcu_head rcu; +u32 sz; +u32 mask_index; +/* Accounts for how many entries are using this mask */ +refcount_t mask_ref; +u32 mask_id; +unsigned char fa_value[]__aligned(8) ; +}; + +struct p4tc_table_entry { +struct rcu_head rcu; +struct rhlist_head ht_node; +struct p4tc_table_entry_key key; +/* fallthrough: key data + value */ +}; + +#define P4TC_KEYSZ_BYTES (bits) (round_up(BITS_TO_BYTES(bits), 8)) + +#define ENTRY_KEY_OFFSET (offsetof(struct p4tc_table_entry_key, fa_key)) + +#define P4TC_ENTRY_VALUE_OFFSET (entry) \ + (offsetof(struct p4tc_table_entry, key) + ENTRY_KEY_OFFSET \ + + P4TC_KEYSZ_BYTES((entry)->key.keysz)) + +static inline void *p4tc_table_entry_value (struct p4tc_table_entry *entry) +{ +return entry->key.fa_key +P4TC_KEYSZ_BYTES (entry->key.keysz); +} + +static inline struct p4tc_table_entry_work * +p4tc_table_entry_work (struct p4tc_table_entry *entry) +{ +struct p4tc_table_entry_value *value =p4tc_table_entry_value (entry); + +return value->entry_work; +} + +extern const struct nla_policy p4tc_root_policy[P4TC_ROOT_MAX +1 ]; +extern const struct nla_policy p4tc_policy[P4TC_MAX +1 ]; + +struct p4tc_table_entry * +p4tc_table_entry_lookup_direct (struct p4tc_table *table, +struct p4tc_table_entry_key *key); +static inline int p4tc_action_init (struct net *net,struct nlattr *nla,struct tc_action *acts[],u32 pipeid,u32 flags,struct netlink_ext_ack *extack)
@@ -377,6 +468,14 @@ p4tc_table_init_default_acts(struct net *net,struct list_head *acts_list, struct netlink_ext_ack *extack); +static inline void p4tc_table_defact_destroy (struct p4tc_table_defact *defact) +{ +if (defact) { +p4tc_action_destroy (defact->default_acts); +kfree (defact); + } +} +static inline void p4tc_table_defacts_acts_copy (struct p4tc_table_defact *defact_copy,struct p4tc_table_defact *defact_orig)
@@ -391,15 +490,36 @@ p4tc_table_replace_default_acts(struct p4tc_table *table,struct p4tc_table_perm *p4tc_table_init_permissions (struct p4tc_table *table,u16 permissions, -struct netlink_ext_ack *extack); +struct netlink_ext_ack *extack);void p4tc_table_replace_permissions (struct p4tc_table *table,struct p4tc_table_perm *tbl_perm,bool lock_rtnl); +void p4tc_table_entry_destroy_hash (void *ptr,void *arg); + +struct p4tc_table_entry * +p4tc_table_const_entry_cu (struct net *net,struct nlattr *arg, +struct p4tc_pipeline *pipeline, +struct p4tc_table *table, +struct netlink_ext_ack *extack); +int p4tc_tbl_entry_crud (struct net *net,struct sk_buff *skb, +struct nlmsghdr *n,int cmd, +struct netlink_ext_ack *extack); +int p4tc_tbl_entry_dumpit (struct net *net,struct sk_buff *skb, +struct netlink_callback *cb, +struct nlattr *arg,char *p_name); +int p4tc_tbl_entry_fill (struct sk_buff *skb,struct p4tc_table *table, +struct p4tc_table_entry *entry,u32 tbl_id, +u16 who_deleted);struct tcf_p4act *tcf_p4_get_next_prealloc_act (struct p4tc_act *act);void tcf_p4_set_init_flags (struct tcf_p4act *p4act); +static inline bool p4tc_runtime_msg_is_update (struct nlmsghdr *n) +{ +return n->nlmsg_type ==RTM_P4TC_UPDATE ; +} +#define to_pipeline (t) ((struct p4tc_pipeline *)t)#define to_act (t) ((struct p4tc_act *)t)#define to_table (t) ((struct p4tc_table *)t)
include/uapi/linux/p4tc.h +67 -1
98 lines not on this page · raw message
include/uapi/linux/rtnetlink.h +9 -0
@@ -203,6 +203,15 @@ enum { RTM_UPDATEP4TEMPLATE,#define RTM_UPDATEP4TEMPLATE RTM_UPDATEP4TEMPLATE + RTM_P4TC_CREATE = 128, +#define RTM_P4TC_CREATE RTM_P4TC_CREATE + RTM_P4TC_DEL, +#define RTM_P4TC_DEL RTM_P4TC_DEL + RTM_P4TC_GET, +#define RTM_P4TC_GET RTM_P4TC_GET + RTM_P4TC_UPDATE, +#define RTM_P4TC_UPDATE RTM_P4TC_UPDATE + __RTM_MAX,#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1) };
net/sched/p4tc/Makefile +2 -1
@@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 obj-y := p4tc_types.o p4tc_tmpl_api.o p4tc_pipeline.o \ - p4tc_action.o p4tc_table.o + p4tc_action.o p4tc_table.o p4tc_tbl_entry.o \ + p4tc_runtime_api.o
net/sched/p4tc/p4tc_runtime_api.c new file +145 -0
145 lines not on this page · raw message
net/sched/p4tc/p4tc_table.c +44 -10
102 lines not on this page · raw message
net/sched/p4tc/p4tc_tbl_entry.c new file +2569 -0
2,454 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.34.1
Part of the diff is not shown here. View the raw message.
Jamal Hadi Salim
maintainerPATCH v8 13/15 p4tc: add set of P4TC table kfuncs
In reply to Jamal Hadi SalimWe add an initial set of kfuncs to allow interactions from eBPF programs to the P4TC domain.
- bpf_p4tc_tbl_read: Used to lookup a table entry from a BPF program installed in TC. To find the table entry we take in an skb, the pipeline ID, the table ID, a key and a key size.
We use the skb to get the network namespace structure where all the pipelines are stored. After that we use the pipeline ID and the table ID, to find the table. We then use the key to search for the entry. We return an entry on success and NULL on failure.
- xdp_p4tc_tbl_read: Used to lookup a table entry from a BPF program installed in XDP. To find the table entry we take in an xdp_md, the pipeline ID, the table ID, a key and a key size.
We use struct xdp_md to get the network namespace structure where all the pipelines are stored. After that we use the pipeline ID and the table ID, to find the table. We then use the key to search for the entry. We return an entry on success and NULL on failure.
- bpf_p4tc_entry_create: Used to create a table entry from a BPF program installed in TC. To create the table entry we take an skb, the pipeline ID, the table ID, a key and its size, and an action which will be associated with the new entry.
We return 0 on success and a negative errno on failure
- xdp_p4tc_entry_create: Used to create a table entry from a BPF program installed in XDP. To create the table entry we take an xdp_md, the pipeline ID, the table ID, a key and its size, and an action which will be associated with the new entry.
We return 0 on success and a negative errno on failure
- bpf_p4tc_entry_create_on_miss: conforms to PNA "add on miss". First does a lookup using the passed key and upon a miss will add the entry to the table.
We return 0 on success and a negative errno on failure
- xdp_p4tc_entry_create_on_miss: conforms to PNA "add on miss". First does a lookup using the passed key and upon a miss will add the entry to the table.
We return 0 on success and a negative errno on failure
- bpf_p4tc_entry_update: Used to update a table entry from a BPF program installed in TC. To update the table entry we take an skb, the pipeline ID, the table ID, a key and its size, and an action which will be associated with the new entry.
We return 0 on success and a negative errno on failure
- xdp_p4tc_entry_update: Used to update a table entry from a BPF program installed in XDP. To update the table entry we take an xdp_md, the pipeline ID, the table ID, a key and its size, and an action which will be associated with the new entry.
We return 0 on success and a negative errno on failure
- bpf_p4tc_entry_delete: Used to delete a table entry from a BPF program installed in TC. To delete the table entry we take an skb, the pipeline ID, the table ID, a key and a key size.
We return 0 on success and a negative errno on failure
- xdp_p4tc_entry_delete: Used to delete a table entry from a BPF program installed in XDP. To delete the table entry we take an xdp_md, the pipeline ID, the table ID, a key and a key size.
We return 0 on success and a negative errno on failure
--- include/linux/bitops.h | 1 + include/net/p4tc.h | 58 +++++- include/net/tc_act/p4tc.h | 24 +++ include/uapi/linux/p4tc.h | 2 + net/sched/p4tc/Makefile | 1 + net/sched/p4tc/p4tc_action.c | 69 ++++++- net/sched/p4tc/p4tc_bpf.c | 337 ++++++++++++++++++++++++++++++++ net/sched/p4tc/p4tc_pipeline.c | 47 ++++- net/sched/p4tc/p4tc_table.c | 8 + net/sched/p4tc/p4tc_tbl_entry.c | 288 ++++++++++++++++++++++++++- net/sched/p4tc/p4tc_tmpl_api.c | 2 + 11 files changed, 828 insertions(+), 9 deletions(-) create mode 100644 net/sched/p4tc/p4tc_bpf.c
include/linux/bitops.h +1 -0
@@ -19,6 +19,7 @@#define BITS_TO_LONGS (nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(long))#define BITS_TO_U64 (nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(u64))#define BITS_TO_U32 (nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(u32)) +#define BITS_TO_U16 (nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(u16))#define BITS_TO_BYTES (nr) __KERNEL_DIV_ROUND_UP(nr, BITS_PER_TYPE(char))extern unsigned int __sw_hweight8 (unsigned int w);
include/net/p4tc.h +57 -1
89 lines not on this page · raw message
include/net/tc_act/p4tc.h +24 -0
@@ -14,10 +14,23 @@ struct tcf_p4act_params {u32 tot_params_sz; }; +#define P4TC_MAX_PARAM_DATA_SIZE 124 + +struct p4tc_table_entry_act_bpf { +u32 act_id; +u8 params[P4TC_MAX_PARAM_DATA_SIZE ]; +} __packed; + +struct p4tc_table_entry_act_bpf_kern { +struct rcu_head rcu; +struct p4tc_table_entry_act_bpf act_bpf; +}; +struct tcf_p4act {struct tc_action common;/* Params IDR reference passed during runtime */ struct tcf_p4act_params __rcu *params; +struct p4tc_table_entry_act_bpf_kern __rcu *act_bpf;u32 p_id;u32 act_id;struct list_head node;
@@ -25,4 +38,15 @@ struct tcf_p4act {#define to_p4act (a) ((struct tcf_p4act *)a) +static inline struct p4tc_table_entry_act_bpf * +p4tc_table_entry_act_bpf (struct tc_action *action) +{ +struct p4tc_table_entry_act_bpf_kern *act_bpf; +struct tcf_p4act *p4act =to_p4act (action); + + act_bpf =rcu_dereference (p4act->act_bpf); + +return &act_bpf->act_bpf; +} +#endif /* __NET_TC_ACT_P4_H */
include/uapi/linux/p4tc.h +2 -0
@@ -17,6 +17,8 @@ struct p4tcmsg {#define P4TC_MINTABLES_COUNT 0#define P4TC_MSGBATCH_SIZE 16 +#define P4TC_ACT_MAX_NUM_PARAMS P4TC_MSGBATCH_SIZE +#define P4TC_MAX_KEYSZ 512#define P4TC_DEFAULT_NUM_PREALLOC 16
net/sched/p4tc/Makefile +1 -0
@@ -3,3 +3,4 @@ obj-y := p4tc_types.o p4tc_tmpl_api.o p4tc_pipeline.o \ p4tc_action.o p4tc_table.o p4tc_tbl_entry.o \ p4tc_runtime_api.o +obj-$(CONFIG_DEBUG_INFO_BTF) += p4tc_bpf.o
net/sched/p4tc/p4tc_action.c +68 -1
131 lines not on this page · raw message
net/sched/p4tc/p4tc_bpf.c new file +337 -0
337 lines not on this page · raw message
net/sched/p4tc/p4tc_pipeline.c +45 -2
65 lines not on this page · raw message
net/sched/p4tc/p4tc_table.c +8 -0
@@ -380,6 +380,7 @@ static int _p4tc_table_put(struct net *net, struct nlattr **tb,rhltable_free_and_destroy (&table->tbl_entries, p4tc_table_entry_destroy_hash, table); +p4tc_tbl_cache_remove (net, table);idr_destroy (&table->tbl_masks_idr);ida_destroy (&table->tbl_prio_idr);
@@ -1147,6 +1148,10 @@ static struct p4tc_table *p4tc_table_create(struct net *net, struct nlattr **tb, goto defaultacts_destroy; } + ret =p4tc_tbl_cache_insert (net, pipeline->common.p_id, table); +if (ret <0 ) + goto entries_hashtable_destroy; + pipeline->curr_tables +=1 ; table->common.ops = (struct p4tc_template_ops *)&p4tc_table_ops;
@@ -1154,6 +1159,9 @@ static struct p4tc_table *p4tc_table_create(struct net *net, struct nlattr **tb,return table; +entries_hashtable_destroy: +rhltable_destroy (&table->tbl_entries); + defaultacts_destroy:p4tc_table_defact_destroy (def_params.default_hitact);p4tc_table_defact_destroy (def_params.default_missact);
net/sched/p4tc/p4tc_tbl_entry.c +283 -5
318 lines not on this page · raw message
net/sched/p4tc/p4tc_tmpl_api.c +2 -0
@@ -599,6 +599,8 @@ static int __init p4tc_template_init(void) op->init (); } +register_p4tc_tbl_bpf (); +return 0 ; }
Signature · 1 line
2.34.1
RE: [PATCH net-next v8 13/15] p4tc: add set of P4TC table kfuncs
Quoted 3 lines · Jamal Hadi Salim
We add an initial set of kfuncs to allow interactions from eBPF programs to the P4TC domain.
If you just use bpf maps then you get all the bpf map type for free and you get the bpf_map_* ops from BPF side.
I don't see any use for this duplication.
Quoted 66 lines
-
bpf_p4tc_tbl_read: Used to lookup a table entry from a BPF program installed in TC. To find the table entry we take in an skb, the pipeline ID, the table ID, a key and a key size.
We use the skb to get the network namespace structure where all the pipelines are stored. After that we use the pipeline ID and the table ID, to find the table. We then use the key to search for the entry. We return an entry on success and NULL on failure.-
xdp_p4tc_tbl_read: Used to lookup a table entry from a BPF program installed in XDP. To find the table entry we take in anxdp_md, the pipeline ID, the table ID, a key and a key size.
We use structxdp_mdto get the network namespace structure where all the pipelines are stored. After that we use the pipeline ID and the table ID, to find the table. We then use the key to search for the entry. We return an entry on success and NULL on failure.-
bpf_p4tc_entry_create: Used to create a table entry from a BPF program installed in TC. To create the table entry we take an skb, the pipeline ID, the table ID, a key and its size, and an action which will be associated with the new entry.
We return 0 on success and a negative errno on failure-
xdp_p4tc_entry_create: Used to create a table entry from a BPF program installed in XDP. To create the table entry we take anxdp_md, the pipeline ID, the table ID, a key and its size, and an action which will be associated with the new entry.
We return 0 on success and a negative errno on failure-
bpf_p4tc_entry_create_on_miss: conforms to PNA "add on miss". First does a lookup using the passed key and upon a miss will add the entry to the table.
We return 0 on success and a negative errno on failure-
xdp_p4tc_entry_create_on_miss: conforms to PNA "add on miss". First does a lookup using the passed key and upon a miss will add the entry to the table.
We return 0 on success and a negative errno on failure-
bpf_p4tc_entry_update: Used to update a table entry from a BPF program installed in TC. To update the table entry we take an skb, the pipeline ID, the table ID, a key and its size, and an action which will be associated with the new entry.
We return 0 on success and a negative errno on failure-
xdp_p4tc_entry_update: Used to update a table entry from a BPF program installed in XDP. To update the table entry we take anxdp_md, the pipeline ID, the table ID, a key and its size, and an action which will be associated with the new entry.
We return 0 on success and a negative errno on failure-
bpf_p4tc_entry_delete: Used to delete a table entry from a BPF program installed in TC. To delete the table entry we take an skb, the pipeline ID, the table ID, a key and a key size.
We return 0 on success and a negative errno on failure-
xdp_p4tc_entry_delete: Used to delete a table entry from a BPF program installed in XDP. To delete the table entry we take anxdp_md, the pipeline ID, the table ID, a key and a key size.
We return 0 on success and a negative errno on failureCo-developed-by Victor Nogueira <[email protected]>Signed-off-by Victor Nogueira <[email protected]>Co-developed-by Pedro Tammela <[email protected]>Signed-off-by Pedro Tammela <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>---
kernel test robot
build botRe: [PATCH net-next v8 13/15] p4tc: add set of P4TC table kfuncs
In reply to Jamal Hadi Salimkernel test robot noticed the following build errors:
Hi Jamal,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Jamal-Hadi-Salim/net-sched-act_api-Introduce-dynamic-actions-list/20231116-230427 base: net-next/main patch link: https://lore.kernel.org/r/20231116145948.203001-14-jhs%40mojatatu.com patch subject: [PATCH net-next v8 13/15] p4tc: add set of P4TC table kfuncs config: um-randconfig-r132-20231119 (https://download.01.org/0day-ci/archive/20231119/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231119/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
/usr/bin/ld: net/sched/p4tc/p4tc_tmpl_api.o: in function `p4tc_template_init':
>> p4tc_tmpl_api.c:(.init.text+0x71): undefined reference to `register_p4tc_tbl_bpf'
collect2: error: ld returned 1 exit status
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH net-next v8 13/15] p4tc: add set of P4TC table kfuncs
In reply to Jamal Hadi Salimkernel test robot noticed the following build errors:
Hi Jamal,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Jamal-Hadi-Salim/net-sched-act_api-Introduce-dynamic-actions-list/20231116-230427 base: net-next/main patch link: https://lore.kernel.org/r/20231116145948.203001-14-jhs%40mojatatu.com patch subject: [PATCH net-next v8 13/15] p4tc: add set of P4TC table kfuncs config: i386-randconfig-r113-20231120 (https://download.01.org/0day-ci/archive/20231121/[email protected]/config) compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231121/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> ld.lld: error: undefined symbol: register_p4tc_tbl_bpf >>> referenced by p4tc_tmpl_api.c:602 (net/sched/p4tc/p4tc_tmpl_api.c:602) >>> net/sched/p4tc/p4tc_tmpl_api.o:(p4tc_template_init) in archive vmlinux.a
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Jamal Hadi Salim
maintainerPATCH v8 14/15 p4tc: add P4 classifier
In reply to Jamal Hadi SalimIntroduce P4 tc classifier. A tc filter instantiated on this classifier is used to bind a P4 pipeline to one or more netdev ports. To use P4 classifier you must specify a pipeline name that will be associated to this filter, a s/w parser and datapath ebpf program. The pipeline must have already been created via a template.
For example, if we were to add a filter to ingress of network interface device $P0 and associate it to P4 pipeline simple_l3 we'd issue the following command:
tc filter add dev $P0 parent ffff: protocol all prio 6 p4 pname simple_l3 \
action bpf obj $PARSER.o section prog/tc-parser \
action bpf obj $PROGNAME.o section prog/tc-ingress
$PROGNAME.o and $PARSER.o is a compilation of the eBPF programs generated by the P4 compiler and will be the representation of the P4 program. Note that filter understands that $PARSER.o is a parser to be loaded at the tc level. The datapath program is merely an eBPF action.
Note we do support a distinct way of loading the parser as opposed to making it be an action, the above example would be:
tc filter add dev $P0 parent ffff: protocol all prio 6 p4 pname simple_l3 \
prog type tc obj $PARSER.o ... \
action bpf obj $PROGNAME.o section prog/tc-ingress
We support two types of loadings of these initial programs in the pipeline and differentiate between what gets loaded at tc vs xdp by using syntax of
either "prog type tc obj" or "prog type xdp obj"
For XDP:
tc filter add dev $P0 ingress protocol all prio 1 p4 pname simple_l3 \
prog type xdp obj $PARSER.o section parser/xdp \
pinned_link /sys/fs/bpf/mylink \
action bpf obj $PROGNAME.o section prog/tc-ingressThe theory of operations is as follows:
================================1. PARSING================================
The packet first encounters the parser.
The parser is implemented in ebpf residing either at the TC or XDP level. The parsed header values are stored in a shared eBPF map. When the parser runs at XDP level, we load it into XDP using tc filter command and pin it to a file.
=============================2. ACTIONS=============================
In the above example, the P4 program (minus the parser) is encoded in an action($PROGNAME.o). It should be noted that classical tc actions continue to work:
IOW, someone could decide to add a mirred action to mirror all packets after or before the ebpf action.
tc filter add dev $P0 parent ffff: protocol all prio 6 p4 pname simple_l3 \
prog type tc obj $PARSER.o section parser/tc-ingress \
action bpf obj $PROGNAME.o section prog/tc-ingress \
action mirred egress mirror index 1 dev $P1 \
action bpf obj $ANOTHERPROG.o section mysect/section-1It should also be noted that it is feasible to split some of the ingress datapath into XDP first and more into TC later (as was shown above for example where the parser runs at XDP level). YMMV.
--- include/uapi/linux/pkt_cls.h | 18 ++ net/sched/Kconfig | 12 + net/sched/Makefile | 1 + net/sched/cls_p4.c | 447 +++++++++++++++++++++++++++++++++++ net/sched/p4tc/Makefile | 4 +- net/sched/p4tc/trace.c | 10 + net/sched/p4tc/trace.h | 44 ++++ 7 files changed, 535 insertions(+), 1 deletion(-) create mode 100644 net/sched/cls_p4.c create mode 100644 net/sched/p4tc/trace.c create mode 100644 net/sched/p4tc/trace.h
include/uapi/linux/pkt_cls.h +18 -0
@@ -739,6 +739,24 @@ enum {#define TCA_MATCHALL_MAX (__TCA_MATCHALL_MAX - 1) +/* P4 classifier */ + +enum { +TCA_P4_UNSPEC , +TCA_P4_CLASSID , +TCA_P4_ACT , +TCA_P4_PNAME , +TCA_P4_PIPEID , +TCA_P4_PROG_FD , +TCA_P4_PROG_NAME , +TCA_P4_PROG_TYPE , +TCA_P4_PROG_ID , +TCA_P4_PAD , + __TCA_P4_MAX, +}; + +#define TCA_P4_MAX (__TCA_P4_MAX - 1) +/* Extended Matches */ struct tcf_ematch_tree_hdr {
net/sched/Kconfig +12 -0
@@ -565,6 +565,18 @@ config NET_CLS_MATCHALL To compile this code as a module, choose M here: the module will be called cls_matchall. +config NET_CLS_P4 + tristate "P4 classifier" + select NET_CLS + select NET_P4_TC + help + If you say Y here, you will be able to bind a P4 pipeline + program. You will need to install a P4 template representing the + program successfully to use this feature. + + To compile this code as a module, choose M here: the module will + be called cls_p4. + config NET_EMATCH bool "Extended Matches" select NET_CLS
net/sched/Makefile +1 -0
@@ -73,6 +73,7 @@ obj-$(CONFIG_NET_CLS_CGROUP) += cls_cgroup.o obj-$(CONFIG_NET_CLS_BPF) += cls_bpf.o obj-$(CONFIG_NET_CLS_FLOWER) += cls_flower.o obj-$(CONFIG_NET_CLS_MATCHALL) += cls_matchall.o +obj-$(CONFIG_NET_CLS_P4) += cls_p4.o obj-$(CONFIG_NET_EMATCH) += ematch.o obj-$(CONFIG_NET_EMATCH_CMP) += em_cmp.o obj-$(CONFIG_NET_EMATCH_NBYTE) += em_nbyte.o
net/sched/cls_p4.c new file +447 -0
447 lines not on this page · raw message
net/sched/p4tc/Makefile +3 -1
@@ -1,6 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 +CFLAGS_trace.o := -I$(src) + obj-y := p4tc_types.o p4tc_tmpl_api.o p4tc_pipeline.o \ p4tc_action.o p4tc_table.o p4tc_tbl_entry.o \ - p4tc_runtime_api.o + p4tc_runtime_api.o trace.o obj-$(CONFIG_DEBUG_INFO_BTF) += p4tc_bpf.o
net/sched/p4tc/trace.c new file +10 -0
@@ -0,0 +1,10 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) + +#include <net/p4tc.h> + +#ifndef __CHECKER__ + +#define CREATE_TRACE_POINTS +#include "trace.h" +EXPORT_TRACEPOINT_SYMBOL_GPL (p4_classify); +#endif
net/sched/p4tc/trace.h new file +44 -0
44 lines not on this page · raw message
Signature · 1 line
2.34.1
RE: [PATCH net-next v8 14/15] p4tc: add P4 classifier
Quoted 30 lines · Jamal Hadi Salim
Introduce P4 tc classifier. A tc filter instantiated on this classifier is used to bind a P4 pipeline to one or more netdev ports. To use P4 classifier you must specify a pipeline name that will be associated to this filter, a s/w parser and datapath ebpf program. The pipeline must have already been created via a template.
For example, if we were to add a filter to ingress of network interface device $P0 and associate it to P4 pipelinesimple_l3we'd issue the following command:tc filter add dev $P0 parent ffff: protocol all prio 6 p4 pname
simple_l3\
action bpf obj $PARSER.o section prog/tc-parser \
action bpf obj $PROGNAME.o section prog/tc-ingress$PROGNAME.o and $PARSER.o is a compilation of the eBPF programs generated by the P4 compiler and will be the representation of the P4 program. Note that filter understands that $PARSER.o is a parser to be loaded at the tc level. The datapath program is merely an eBPF action.
Note we do support a distinct way of loading the parser as opposed to making it be an action, the above example would be:
tc filter add dev $P0 parent ffff: protocol all prio 6 p4 pname
simple_l3\
prog type tc obj $PARSER.o ... \
action bpf obj $PROGNAME.o section prog/tc-ingressWe support two types of loadings of these initial programs in the pipeline and differentiate between what gets loaded at tc vs xdp by using syntax of
either "prog type tc obj" or "prog type xdp obj"
Quoted 8 lines
For XDP:
tc filter add dev $P0 ingress protocol all prio 1 p4 pname
simple_l3\prog type xdp obj $PARSER.o section parser/xdp \ pinned_link /sys/fs/bpf/mylink \ action bpf obj $PROGNAME.o section prog/tc-ingressThe theory of operations is as follows:
You've lost me here. You have a BPF parser program and some BPF actions. Why not have the parser program just call the BPF action?
It seems the action is based on LPM or some software like TCAM. So steps in BPF would be,
Parse -> bpf_map_lookup to find action -> call action
Just use the normal way to load the bpf program through 'tc' or 'xdp'. Or its all about hardware, but I still have no idea how this BPF parser gets into hardware and how these actions get there. So we can't even evaluate what that looks like.
Quoted 32 lines
================================1. PARSING================================
The packet first encounters the parser.
The parser is implemented in ebpf residing either at the TC or XDP level. The parsed header values are stored in a shared eBPF map. When the parser runs at XDP level, we load it into XDP using tc filter command and pin it to a file.=============================2. ACTIONS=============================
In the above example, the P4 program (minus the parser) is encoded in an action($PROGNAME.o). It should be noted that classical tc actions continue to work:
IOW, someone could decide to add a mirred action to mirror all packets after or before the ebpf action.tc filter add dev $P0 parent ffff: protocol all prio 6 p4 pname
simple_l3\prog type tc obj $PARSER.o section parser/tc-ingress \ action bpf obj $PROGNAME.o section prog/tc-ingress \ action mirred egress mirror index 1 dev $P1 \ action bpf obj $ANOTHERPROG.o section mysect/section-1It should also be noted that it is feasible to split some of the ingress datapath into XDP first and more into TC later (as was shown above for example where the parser runs at XDP level). YMMV.
Co-developed-by Victor Nogueira <[email protected]>Signed-off-by Victor Nogueira <[email protected]>Co-developed-by Pedro Tammela <[email protected]>Signed-off-by Pedro Tammela <[email protected]>Signed-off-by Jamal Hadi Salim <[email protected]>
Jamal Hadi Salim
maintainerPATCH v8 15/15 p4tc: Add P4 extern interface
In reply to Jamal Hadi SalimP4 externs are an abstraction in the language to call for extending language functionality. For example, the function that sends a packet to a specific port (send_to_port) in P4 PNA is an extern.
Externs can be seen as classes, which have constructors and methods. Take, for example, the Register extern definition:
extern Register<T> {
Register(@tc_numel bit<32> size);
@tc_md_read T read(@tc_key bit<32> index);
@tc_md_write void write(@tc_key bit<32> index, @tc_data T value);
}struct tc_ControlPath_Register<T> {
@tc_key bit<32> index;
@tc_data T value;
}Which can then be instantiated within a P4 program as:
Register<bit<32>>(128) reg1; Register<bit<16>>(1024) reg2;
Will be abstracted into the template by the P4C compiler for "reg1" as follows:
tc p4template create extern/root/register extid 10 numinstances 2 tc p4template create extern_inst/aP4Proggie/register/reg1 instid 1 \control_path tc_key index type bit32 tc_data value type bit32 \
numelemens 128 default_value 22
=========================EXTERN RUNTIME COMMANDS=========================
Once we seal the pipeline, the register values will be assigned to the default value specified on the template as "default_value". After sealing, we can update the runtime instance element. For example to update reg1[2] with the value 33, we will do the following:
tc p4ctrl update aP4proggie/extern/register/reg1 tc_key index 2 \tc_data value 33
We can also get its value:
tc p4ctrl get aP4proggie/extern/register/reg1 tc_key index 2
Which will yield the following output:
total exts 0
extern order 1:
tc_key index id 1 type bit32 value: 1
tc_data value id 2 type bit32 value: 33
We can also dump all of the elements in this register:
tc p4ctrl get aP4proggie/extern/register/reg1
Note that the only valid runtime operations are get and update.
=========================EXTERN P4 Runtime =========================
The generated ebpf code invokes the externs in the P4TC domain using the md_read or md_write kfuncs, for example:
if the P4 program had this invocation:
tmp1 = reg1.read(index1);
Then equivalent generated ebpf code is as follows:
param.pipe_id = aP4Proggie_ID;
param.ext_id = EXTERN_REGISTER;
param.inst_id = EXTERN_REGISTER_INSTANCE_ID1;
param.index = index1;
param.param_id = EXTERN_REGISTER_PARAM_ID;bpf_p4tc_extern_md_read(skb, &res, ¶m);
tmp1 = (u32 *)res.params;
--- include/net/p4tc.h | 161 +++ include/net/p4tc_ext_api.h | 199 +++ include/uapi/linux/p4tc.h | 61 + include/uapi/linux/p4tc_ext.h | 36 + net/sched/p4tc/Makefile | 2 +- net/sched/p4tc/p4tc_bpf.c | 79 +- net/sched/p4tc/p4tc_ext.c | 2204 ++++++++++++++++++++++++++++ net/sched/p4tc/p4tc_pipeline.c | 34 +- net/sched/p4tc/p4tc_runtime_api.c | 10 +- net/sched/p4tc/p4tc_table.c | 57 +- net/sched/p4tc/p4tc_tbl_entry.c | 25 +- net/sched/p4tc/p4tc_tmpl_api.c | 4 + net/sched/p4tc/p4tc_tmpl_ext.c | 2221 +++++++++++++++++++++++++++++ 13 files changed, 5083 insertions(+), 10 deletions(-) create mode 100644 include/net/p4tc_ext_api.h create mode 100644 include/uapi/linux/p4tc_ext.h create mode 100644 net/sched/p4tc/p4tc_ext.c create mode 100644 net/sched/p4tc/p4tc_tmpl_ext.c
include/net/p4tc.h +161 -0
@@ -11,6 +11,7 @@#include <linux/rhashtable-types.h> #include <net/tc_act/p4tc.h> #include <net/p4tc_types.h> +#include <linux/bpf.h> #define P4TC_DEFAULT_NUM_TABLES P4TC_MINTABLES_COUNT#define P4TC_DEFAULT_MAX_RULES 1
@@ -21,6 +22,10 @@#define P4TC_DEFAULT_TMASKS 8#define P4TC_MAX_T_AGING 864000000#define P4TC_DEFAULT_T_AGING 30000 +#define P4TC_DEFAULT_NUM_EXT_INSTS 1 +#define P4TC_MAX_NUM_EXT_INSTS 1024 +#define P4TC_DEFAULT_NUM_EXT_INST_ELEMS 1 +#define P4TC_MAX_NUM_EXT_INST_ELEMS 1024#define P4TC_MAX_PERMISSION (GENMASK(P4TC_PERM_MAX_BIT, 0))
@@ -30,6 +35,8 @@#define P4TC_TBLID_IDX 1#define P4TC_AID_IDX 1#define P4TC_PARSEID_IDX 1 +#define P4TC_TMPL_EXT_IDX 1 +#define P4TC_TMPL_EXT_INST_IDX 2struct p4tc_dump_ctx {u32 ids[P4TC_PATH_MAX ];
@@ -79,9 +86,14 @@ struct p4tc_pipeline {struct p4tc_template_common common;struct idr p_act_idr;struct idr p_tbl_idr; +/* IDR where the externs are stored globally in the root pipeline */ +struct idr p_ext_idr; +/* IDR where the per user pipeline data related to externs is stored */ +struct idr user_ext_idr;struct rcu_head rcu;struct net *net;u32 num_created_acts; +u32 num_created_ext_elems;/* Accounts for how many entities are referencing this pipeline. * As for now only P4 filters can refer to pipelines. */
@@ -207,6 +219,27 @@ static inline int p4tc_action_destroy(struct tc_action **acts)#define P4TC_MAX_PARAM_DATA_SIZE 124 +#define P4TC_EXT_FLAGS_UNSPEC 0x0 +#define P4TC_EXT_FLAGS_CONTROL_READ 0x1 +#define P4TC_EXT_FLAGS_CONTROL_WRITE 0x2 + +struct p4tc_ext_bpf_params { +u32 pipe_id; +u32 ext_id; +u32 inst_id; +u32 index; +u32 param_id; +u32 flags; +u8 in_params[128 ];/* extern specific params if any */ +}; + +struct p4tc_ext_bpf_res { +u32 ext_id; +u32 index; +u32 verdict; +u8 out_params[128 ];/* specific values if any */ +}; +struct p4tc_table_defact {struct tc_action **default_acts;/* Will have two 7 bits blocks containing CRUDXPS (Create, read, update,
@@ -237,6 +270,7 @@ struct p4tc_table {struct p4tc_table_perm __rcu *tbl_permissions;struct p4tc_table_entry_mask __rcu **tbl_masks_array;unsigned long __rcu *tbl_free_masks_bitmap; +struct p4tc_extern_inst *tbl_counter;u64 tbl_aging;/* Locks the available masks IDR which will be used when adding and * deleting table entries.
@@ -352,6 +386,7 @@ struct p4tc_table_entry_key {struct p4tc_table_entry_value {u32 prio;int num_acts; +struct p4tc_extern_common *counter;struct tc_action **acts;/* Accounts for how many entities are referencing, eg: Data path, * one or more control path and timer.
@@ -576,8 +611,134 @@ static inline bool p4tc_runtime_msg_is_update(struct nlmsghdr *n)return n->nlmsg_type ==RTM_P4TC_UPDATE ; } +struct p4tc_user_pipeline_extern { +struct idr e_inst_idr; +struct p4tc_tmpl_extern *tmpl_ext; +void (*free)(struct p4tc_user_pipeline_extern *pipe_ext, +struct idr *tmpl_exts_idr); +u32 ext_id; +/* Accounts for how many instances refer to this extern. */ +refcount_t ext_ref; +/* Counts how many instances this extern has */ +atomic_t curr_insts_num; +u32 PAD0; +char ext_name[EXTERNNAMSIZ ]; +}; + +struct p4tc_tmpl_extern { +struct p4tc_template_common common; +struct idr params_idr; +const struct p4tc_extern_ops *ops; +u32 ext_id; +u32 num_params; +u32 max_num_insts; +/* Accounts for how many pipelines refer to this extern. */ +refcount_t tmpl_ref; +char mod_name[MODULE_NAME_LEN ]; +bool has_exec_method; +}; + +struct p4tc_extern_inst { +struct p4tc_template_common common; +struct p4tc_extern_params *params; +const struct p4tc_extern_ops *ops; +struct idr control_elems_idr; +struct list_head unused_elems; +/* Locks the available externs list. +* Which will be used by table entries that reference externs (refer to +* direct counters and meters in P4). +* Note that table entries can be created, update or deleted by both +* control and data path. So this list may be modified from both +* contexts. +*/ +spinlock_t available_list_lock; +/* Accounts for how many elements refer to this extern. */ +refcount_t inst_ref; +struct p4tc_user_pipeline_extern *pipe_ext; +char *ext_name; +/* Counts how many elements this extern has */ +atomic_t curr_num_elems; +u32 max_num_elems; +u32 ext_id; +u32 ext_inst_id; +u32 num_control_params; +struct p4tc_extern_params *constr_params; +u32 flags; +bool tbl_bindable; +bool is_scalar; +}; + +int p4tc_pipeline_create_extern_net (struct p4tc_tmpl_extern *tmpl_ext); +int p4tc_pipeline_del_extern_net (struct p4tc_tmpl_extern *tmpl_ext); +struct p4tc_extern_inst * +p4tc_ext_inst_find_bynames (struct net *net,struct p4tc_pipeline *pipeline, +const char *extname,const char *instname, +struct netlink_ext_ack *extack); +struct p4tc_user_pipeline_extern * +p4tc_pipe_ext_find_bynames (struct net *net,struct p4tc_pipeline *pipeline, +const char *extname,struct netlink_ext_ack *extack); +struct p4tc_extern_inst * +p4tc_ext_inst_table_bind (struct p4tc_pipeline *pipeline, +struct p4tc_user_pipeline_extern **pipe_ext, +const char *ext_inst_path, +struct netlink_ext_ack *extack); +void +p4tc_ext_inst_table_unbind (struct p4tc_table *table, +struct p4tc_user_pipeline_extern *pipe_ext, +struct p4tc_extern_inst *inst); +struct p4tc_extern_inst * +p4tc_ext_inst_get_byids (struct net *net,struct p4tc_pipeline **pipeline, +struct p4tc_ext_bpf_params *params); +struct p4tc_extern_inst * +p4tc_ext_find_byids (struct p4tc_pipeline *pipeline, +const u32 ext_id,const u32 inst_id); +struct p4tc_extern_inst * +p4tc_ext_inst_alloc (const struct p4tc_extern_ops *ops,const u32 max_num_elems, +bool tbl_bindable,char *ext_name); + +int __bpf_p4tc_extern_md_write (struct net *net, +struct p4tc_ext_bpf_params *params); +int __bpf_p4tc_extern_md_read (struct net *net, +struct p4tc_ext_bpf_res *res, +struct p4tc_ext_bpf_params *params); +struct p4tc_extern_params * +p4tc_ext_params_copy (struct p4tc_extern_params *params_orig); + +extern const struct p4tc_template_ops p4tc_tmpl_ext_ops; +extern const struct p4tc_template_ops p4tc_ext_inst_ops; + +struct p4tc_extern_param { +struct p4tc_extern_param_ops *ops; +struct p4tc_extern_param_ops *mod_ops; +void *value; +struct p4tc_type *type; +struct p4tc_type_mask_shift *mask_shift; +u32 id; +u32 index; +u32 bitsz; +u32 flags; +char name[EXTPARAMNAMSIZ ]; +struct rcu_head rcu; +}; + +struct p4tc_extern_param_ops { +int (*init_value)(struct net *net, +struct p4tc_extern_param *nparam,void *value, +struct netlink_ext_ack *extack); +/* Only for bit<X> parameter types */ +void (*default_value)(struct p4tc_extern_param *nparam); +int (*dump_value)(struct sk_buff *skb,struct p4tc_extern_param_ops *op, +struct p4tc_extern_param *param); +void (*free)(struct p4tc_extern_param *param); +u32 len; +u32 alloc_len; +}; +#define to_pipeline (t) ((struct p4tc_pipeline *)t)#define to_act (t) ((struct p4tc_act *)t)#define to_table (t) ((struct p4tc_table *)t) +#define to_extern (t) ((struct p4tc_tmpl_extern *)t) +#define to_extern_inst (t) ((struct p4tc_extern_inst *)t) +#endif
include/net/p4tc_ext_api.h new file +199 -0
199 lines not on this page · raw message
include/uapi/linux/p4tc.h +61 -0
109 lines not on this page · raw message
include/uapi/linux/p4tc_ext.h new file +36 -0
@@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __LINUX_P4TC_EXT_H +#define __LINUX_P4TC_EXT_H + +#include <linux/types.h> +#include <linux/pkt_sched.h> + +#define P4TC_EXT_NAMSIZ 64 + +/* Extern attributes */ +enum { +P4TC_EXT_UNSPEC , +P4TC_EXT_INST_NAME , +P4TC_EXT_KIND , +P4TC_EXT_PARAMS , +P4TC_EXT_KEY , +P4TC_EXT_PAD , +P4TC_EXT_FLAGS , + __P4TC_EXT_MAX +}; + +#define P4TC_EXT_ID_DYN 0x01 +#define P4TC_EXT_ID_MAX 1023 + +/* See other P4TC_EXT_FLAGS_ * flags in include/net/act_api.h. */ +#define P4TC_EXT_FLAGS_NO_PERCPU_STATS (1 << 0)/* Don't use percpu allocator +* for externs stats. +*/ +#define P4TC_EXT_FLAGS_SKIP_HW (1 << 1)/* don't offload action to HW */ +#define P4TC_EXT_FLAGS_SKIP_SW (1 << 2)/* don't use action in SW */ + +#define P4TC_EXT_FLAG_LARGE_DUMP_ON (1 << 0) + +#define P4TC_EXT_MAX __P4TC_EXT_MAX + +#endif
net/sched/p4tc/Makefile +1 -1
@@ -4,5 +4,5 @@ CFLAGS_trace.o := -I$(src) obj-y := p4tc_types.o p4tc_tmpl_api.o p4tc_pipeline.o \ p4tc_action.o p4tc_table.o p4tc_tbl_entry.o \ - p4tc_runtime_api.o trace.o + p4tc_runtime_api.o trace.o p4tc_ext.o p4tc_tmpl_ext.o obj-$(CONFIG_DEBUG_INFO_BTF) += p4tc_bpf.o
net/sched/p4tc/p4tc_bpf.c +78 -1
108 lines not on this page · raw message
net/sched/p4tc/p4tc_ext.c new file +2204 -0
2,204 lines not on this page · raw message
net/sched/p4tc/p4tc_pipeline.c +33 -1
@@ -27,6 +27,7 @@#include <net/netlink.h> #include <net/flow_offload.h> #include <net/p4tc_types.h> +#include <net/p4tc_ext_api.h> static unsigned int pipeline_net_id;static struct p4tc_pipeline *root_pipeline;
@@ -99,6 +100,7 @@ static void __net_exit pipeline_exit_net(struct net *net)__p4tc_pipeline_put (pipeline, &pipeline->common,NULL ); }idr_destroy (&pipe_net->pipeline_idr); +rtnl_unlock (); }
@@ -119,6 +121,7 @@ static void p4tc_pipeline_destroy(struct p4tc_pipeline *pipeline) {idr_destroy (&pipeline->p_act_idr);idr_destroy (&pipeline->p_tbl_idr); +idr_destroy (&pipeline->user_ext_idr);kfree (pipeline); }
@@ -141,7 +144,8 @@ static void p4tc_pipeline_teardown(struct p4tc_pipeline *pipeline,struct net *net = pipeline->net;struct p4tc_pipeline_net *pipe_net =net_generic (net, pipeline_net_id);struct net *pipeline_net =maybe_get_net (net); -unsigned long iter_act_id, tmp; +struct p4tc_user_pipeline_extern *pipe_ext; +unsigned long iter_act_id, ext_id, tmp;struct p4tc_table *table;struct p4tc_act *act;unsigned long tbl_id;
@@ -152,6 +156,20 @@ static void p4tc_pipeline_teardown(struct p4tc_pipeline *pipeline,idr_for_each_entry_ul (&pipeline->p_act_idr, act, tmp, iter_act_id) act->common.ops->put (pipeline, &act->common, extack); +idr_for_each_entry_ul (&pipeline->user_ext_idr, pipe_ext, tmp, ext_id) { +unsigned long tmp_in, inst_id; +struct p4tc_extern_inst *inst; + +idr_for_each_entry_ul (&pipe_ext->e_inst_idr, inst, tmp_in, + inst_id) { +struct p4tc_template_common *common = &inst->common; + + common->ops->put (pipeline, common, extack); + } + + pipe_ext->free (pipe_ext, &pipeline->user_ext_idr); + } +/* If we are on netns cleanup we can't touch the pipeline_idr. * On pre_exit we will destroy the idr but never call into teardown * if filters are active which makes pipeline pointers dangle until
@@ -210,9 +228,18 @@ static int pipeline_try_set_state_ready(struct p4tc_pipeline *pipeline,if (ret <0 )return ret; + ret =p4tc_extern_insts_init_elems (&pipeline->user_ext_idr); +if (ret <0 ) + goto unset_table_state_ready; + pipeline->p_state =P4TC_STATE_READY ;return true; + +unset_table_state_ready: +p4tc_table_put_mask_array (pipeline); + +return ret; }struct p4tc_pipeline *p4tc_pipeline_find_byid (struct net *net,const u32 pipeid)
@@ -308,6 +335,9 @@ static struct p4tc_pipeline *p4tc_pipeline_create(struct net *net,idr_init (&pipeline->p_tbl_idr); pipeline->curr_tables =0 ; +idr_init (&pipeline->p_tbl_idr); + +idr_init (&pipeline->user_ext_idr); pipeline->num_created_acts =0 ;
@@ -645,6 +675,8 @@ static void __p4tc_pipeline_init(void)strscpy (root_pipeline->common.name,"kernel" ,PIPELINENAMSIZ ); +idr_init (&root_pipeline->p_ext_idr); + root_pipeline->common.ops = (struct p4tc_template_ops *)&p4tc_pipeline_ops;
net/sched/p4tc/p4tc_runtime_api.c +9 -1
@@ -27,16 +27,17 @@#include <net/p4tc.h> #include <net/netlink.h> #include <net/flow_offload.h> +#include <net/p4tc_ext_api.h> static int tc_ctl_p4_root (struct sk_buff *skb,struct nlmsghdr *n,int cmd,struct netlink_ext_ack *extack) {struct p4tcmsg *t = (struct p4tcmsg *)nlmsg_data (n); +int ret;switch (t->obj) {case P4TC_OBJ_RUNTIME_TABLE : {struct net *net =sock_net (skb->sk); -int ret; net =maybe_get_net (net);if (!net) {
@@ -50,6 +51,11 @@ static int tc_ctl_p4_root(struct sk_buff *skb, struct nlmsghdr *n, int cmd,return ret; } +case P4TC_OBJ_RUNTIME_EXTERN : +rtnl_lock (); + ret =p4tc_ctl_extern (skb, n, cmd, extack); +rtnl_unlock (); +return ret;default :NL_SET_ERR_MSG (extack,"Unknown P4 runtime object type" );return -EOPNOTSUPP ;
@@ -120,6 +126,8 @@ static int tc_ctl_p4_dump(struct sk_buff *skb, struct netlink_callback *cb)case P4TC_OBJ_RUNTIME_TABLE :return p4tc_tbl_entry_dumpit (sock_net (skb->sk), skb, cb, tb[P4TC_ROOT ], p_name); +case P4TC_OBJ_RUNTIME_EXTERN : +return p4tc_ctl_extern_dump (skb, cb, tb, p_name);default : NL_SET_ERR_MSG_FMT(cb->extack, "Unknown p4 runtime object type %u\n",
net/sched/p4tc/p4tc_table.c +52 -5
2 lines not on this page · raw message
net/sched/p4tc/p4tc_tmpl_ext.c new file +2221 -0
2,221 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.34.1
Part of the diff is not shown here. View the raw message.
Jiri Pirko
maintainerRe: [PATCH net-next v8 15/15] p4tc: Add P4 extern interface
Thu, Nov 16, 2023 at 03:59:48PM CET, [email protected] wrote:
[...]
Quoted 6 lines
include/net/p4tc.h | 161 +++ include/net/p4tc_ext_api.h | 199 +++ include/uapi/linux/p4tc.h | 61 + include/uapi/linux/p4tc_ext.h | 36 + net/sched/p4tc/Makefile | 2 +- net/sched/p4tc/p4tc_bpf.c | 79 +-
Quoted 8 lines
net/sched/p4tc/p4tc_ext.c | 2204 ++++++++++++++++++++++++++++ net/sched/p4tc/p4tc_pipeline.c | 34 +- net/sched/p4tc/p4tc_runtime_api.c | 10 +- net/sched/p4tc/p4tc_table.c | 57 +- net/sched/p4tc/p4tc_tbl_entry.c | 25 +- net/sched/p4tc/p4tc_tmpl_api.c | 4 + net/sched/p4tc/p4tc_tmpl_ext.c | 2221 +++++++++++++++++++++++++++++ 13 files changed, 5083 insertions(+), 10 deletions(-)
This is for this patch. Now for the whole patchset you have:
30 files changed, 16676 insertions(+), 39 deletions(-)
I understand that you want to fit into 15 patches with all the work. But sorry, patches like this are unreviewable. My suggestion is to split the patchset into multiple ones including smaller patches and allow people to digest this. I don't believe that anyone can seriously stand to review a patch with more than 200 lines changes.
[...]
Jamal Hadi Salim
maintainerRe: [PATCH net-next v8 15/15] p4tc: Add P4 extern interface
Quoted 20 lines · Jiri Pirko
Thu, Nov 16, 2023 at 03:59:48PM CET, [email protected] wrote:
[...]
Quoted 6 lines
include/net/p4tc.h | 161 +++ include/net/p4tc_ext_api.h | 199 +++ include/uapi/linux/p4tc.h | 61 + include/uapi/linux/p4tc_ext.h | 36 + net/sched/p4tc/Makefile | 2 +- net/sched/p4tc/p4tc_bpf.c | 79 +-Quoted 8 lines
net/sched/p4tc/p4tc_ext.c | 2204 ++++++++++++++++++++++++++++ net/sched/p4tc/p4tc_pipeline.c | 34 +- net/sched/p4tc/p4tc_runtime_api.c | 10 +- net/sched/p4tc/p4tc_table.c | 57 +- net/sched/p4tc/p4tc_tbl_entry.c | 25 +- net/sched/p4tc/p4tc_tmpl_api.c | 4 + net/sched/p4tc/p4tc_tmpl_ext.c | 2221 +++++++++++++++++++++++++++++ 13 files changed, 5083 insertions(+), 10 deletions(-)
Quoted 8 lines
This is for this patch. Now for the whole patchset you have:
30 files changed, 16676 insertions(+), 39 deletions(-)I understand that you want to fit into 15 patches with all the work. But sorry, patches like this are unreviewable. My suggestion is to split the patchset into multiple ones including smaller patches and allow people to digest this. I don't believe that anyone can seriously stand to review a patch with more than 200 lines changes.
This specific patch is not difficult to split into two. I can do that and send out minus the first 8 trivial patches - but not familiar with how to do "here's part 1 of the patches" and "here's patchset two". There's dependency between them so not clear how patchwork and reviewers would deal with it. Thoughts?
Note: The code machinery is really repeatable; for example if you look at the tables control you will see very similar patterns to actions etc. i.e spending time to review one will make it easy for the rest.
cheers,
jamal
Quoted 1 line
[...]
Jiri Pirko
maintainerRe: [PATCH net-next v8 15/15] p4tc: Add P4 extern interface
Quoted 30 lines · Fri, Nov 17, 2023 at 01:14:43PM CET, [email protected] wrote:
Quoted 20 lines · Jiri Pirko
Thu, Nov 16, 2023 at 03:59:48PM CET, [email protected] wrote:
[...]
Quoted 6 lines
include/net/p4tc.h | 161 +++ include/net/p4tc_ext_api.h | 199 +++ include/uapi/linux/p4tc.h | 61 + include/uapi/linux/p4tc_ext.h | 36 + net/sched/p4tc/Makefile | 2 +- net/sched/p4tc/p4tc_bpf.c | 79 +-Quoted 8 lines
net/sched/p4tc/p4tc_ext.c | 2204 ++++++++++++++++++++++++++++ net/sched/p4tc/p4tc_pipeline.c | 34 +- net/sched/p4tc/p4tc_runtime_api.c | 10 +- net/sched/p4tc/p4tc_table.c | 57 +- net/sched/p4tc/p4tc_tbl_entry.c | 25 +- net/sched/p4tc/p4tc_tmpl_api.c | 4 + net/sched/p4tc/p4tc_tmpl_ext.c | 2221 +++++++++++++++++++++++++++++ 13 files changed, 5083 insertions(+), 10 deletions(-)Quoted 8 lines
This is for this patch. Now for the whole patchset you have:
30 files changed, 16676 insertions(+), 39 deletions(-)I understand that you want to fit into 15 patches with all the work. But sorry, patches like this are unreviewable. My suggestion is to split the patchset into multiple ones including smaller patches and allow people to digest this. I don't believe that anyone can seriously stand to review a patch with more than 200 lines changes.
Quoted 3 lines
This specific patch is not difficult to split into two. I can do that and send out minus the first 8 trivial patches - but not familiar with how to do "here's part 1 of the patches" and "here's patchset two".
Split into multiple patchsets and send one by one. No need to have all in at once.
Quoted 1 line
There's dependency between them so not clear how patchwork and
What dependency. It should compile. Introduce some basic functionality first and extend it incrementally with other patchsets. The usual way.
Quoted 10 lines
reviewers would deal with it. Thoughts?
Note: The code machinery is really repeatable; for example if you look at the tables control you will see very similar patterns to actions etc. i.e spending time to review one will make it easy for the rest.
cheers,
jamalQuoted 1 line
[...]
Jamal Hadi Salim
maintainerRe: [PATCH net-next v8 15/15] p4tc: Add P4 extern interface
Quoted 36 lines · Jiri Pirko
Quoted 30 lines · Fri, Nov 17, 2023 at 01:14:43PM CET, [email protected] wrote:
Quoted 20 lines · Jiri Pirko
Thu, Nov 16, 2023 at 03:59:48PM CET, [email protected] wrote:
[...]
Quoted 6 lines
include/net/p4tc.h | 161 +++ include/net/p4tc_ext_api.h | 199 +++ include/uapi/linux/p4tc.h | 61 + include/uapi/linux/p4tc_ext.h | 36 + net/sched/p4tc/Makefile | 2 +- net/sched/p4tc/p4tc_bpf.c | 79 +-Quoted 8 lines
net/sched/p4tc/p4tc_ext.c | 2204 ++++++++++++++++++++++++++++ net/sched/p4tc/p4tc_pipeline.c | 34 +- net/sched/p4tc/p4tc_runtime_api.c | 10 +- net/sched/p4tc/p4tc_table.c | 57 +- net/sched/p4tc/p4tc_tbl_entry.c | 25 +- net/sched/p4tc/p4tc_tmpl_api.c | 4 + net/sched/p4tc/p4tc_tmpl_ext.c | 2221 +++++++++++++++++++++++++++++ 13 files changed, 5083 insertions(+), 10 deletions(-)Quoted 8 lines
This is for this patch. Now for the whole patchset you have:
30 files changed, 16676 insertions(+), 39 deletions(-)I understand that you want to fit into 15 patches with all the work. But sorry, patches like this are unreviewable. My suggestion is to split the patchset into multiple ones including smaller patches and allow people to digest this. I don't believe that anyone can seriously stand to review a patch with more than 200 lines changes.
Quoted 3 lines
This specific patch is not difficult to split into two. I can do that and send out minus the first 8 trivial patches - but not familiar with how to do "here's part 1 of the patches" and "here's patchset two".
Quoted 9 lines
Split into multiple patchsets and send one by one. No need to have all in at once.
Quoted 1 line
There's dependency between them so not clear how patchwork and
What dependency. It should compile. Introduce some basic functionality first and extend it incrementally with other patchsets. The usual way.
Sorry, still not following:
Lets say i split the current patchset 1 with patch 1-8 (which are trivial and have been reviewed) then make the rest into patchset 2 with a new set 1-8. I dont see how patchset 2 compiles unless it has access to code from patchset 1. Unless patchset 1 is merged i dont see how this works with patchwork or reviewers. Am i missing something?
cheers,
jamal
Quoted 11 lines
Quoted 11 lines
reviewers would deal with it. Thoughts?
Note: The code machinery is really repeatable; for example if you look at the tables control you will see very similar patterns to actions etc. i.e spending time to review one will make it easy for the rest.
cheers,
jamalQuoted 1 line
[...]
Jiri Pirko
maintainerRe: [PATCH net-next v8 15/15] p4tc: Add P4 extern interface
Quoted 47 lines · Mon, Nov 20, 2023 at 03:02:49PM CET, [email protected] wrote:
Quoted 36 lines · Jiri Pirko
Quoted 30 lines · Fri, Nov 17, 2023 at 01:14:43PM CET, [email protected] wrote:
Quoted 20 lines · Jiri Pirko
Thu, Nov 16, 2023 at 03:59:48PM CET, [email protected] wrote:
[...]
Quoted 6 lines
include/net/p4tc.h | 161 +++ include/net/p4tc_ext_api.h | 199 +++ include/uapi/linux/p4tc.h | 61 + include/uapi/linux/p4tc_ext.h | 36 + net/sched/p4tc/Makefile | 2 +- net/sched/p4tc/p4tc_bpf.c | 79 +-Quoted 8 lines
net/sched/p4tc/p4tc_ext.c | 2204 ++++++++++++++++++++++++++++ net/sched/p4tc/p4tc_pipeline.c | 34 +- net/sched/p4tc/p4tc_runtime_api.c | 10 +- net/sched/p4tc/p4tc_table.c | 57 +- net/sched/p4tc/p4tc_tbl_entry.c | 25 +- net/sched/p4tc/p4tc_tmpl_api.c | 4 + net/sched/p4tc/p4tc_tmpl_ext.c | 2221 +++++++++++++++++++++++++++++ 13 files changed, 5083 insertions(+), 10 deletions(-)Quoted 8 lines
This is for this patch. Now for the whole patchset you have:
30 files changed, 16676 insertions(+), 39 deletions(-)I understand that you want to fit into 15 patches with all the work. But sorry, patches like this are unreviewable. My suggestion is to split the patchset into multiple ones including smaller patches and allow people to digest this. I don't believe that anyone can seriously stand to review a patch with more than 200 lines changes.
Quoted 3 lines
This specific patch is not difficult to split into two. I can do that and send out minus the first 8 trivial patches - but not familiar with how to do "here's part 1 of the patches" and "here's patchset two".
Quoted 9 lines
Split into multiple patchsets and send one by one. No need to have all in at once.
Quoted 1 line
There's dependency between them so not clear how patchwork and
What dependency. It should compile. Introduce some basic functionality first and extend it incrementally with other patchsets. The usual way.
Quoted 6 lines
Sorry, still not following:
Lets say i split the current patchset 1 with patch 1-8 (which are trivial and have been reviewed) then make the rest into patchset 2 with a new set 1-8. I dont see how patchset 2 compiles unless it has access to code from patchset 1. Unless patchset 1 is merged i dont see how this works with patchwork or reviewers. Am i missing something?
Why it would not work. Describe your motivation and plans and submit part of the work, the rest later on. No problem.
Quoted 15 lines
cheers,
jamalQuoted 11 lines
Quoted 11 lines
reviewers would deal with it. Thoughts?
Note: The code machinery is really repeatable; for example if you look at the tables control you will see very similar patterns to actions etc. i.e spending time to review one will make it easy for the rest.
cheers,
jamalQuoted 1 line
[...]
Jamal Hadi Salim
maintainerRe: [PATCH net-next v8 15/15] p4tc: Add P4 extern interface
Quoted 56 lines · Jiri Pirko
Quoted 47 lines · Mon, Nov 20, 2023 at 03:02:49PM CET, [email protected] wrote:
Quoted 36 lines · Jiri Pirko
Quoted 30 lines · Fri, Nov 17, 2023 at 01:14:43PM CET, [email protected] wrote:
Quoted 20 lines · Jiri Pirko
Thu, Nov 16, 2023 at 03:59:48PM CET, [email protected] wrote:
[...]
Quoted 6 lines
include/net/p4tc.h | 161 +++ include/net/p4tc_ext_api.h | 199 +++ include/uapi/linux/p4tc.h | 61 + include/uapi/linux/p4tc_ext.h | 36 + net/sched/p4tc/Makefile | 2 +- net/sched/p4tc/p4tc_bpf.c | 79 +-Quoted 8 lines
net/sched/p4tc/p4tc_ext.c | 2204 ++++++++++++++++++++++++++++ net/sched/p4tc/p4tc_pipeline.c | 34 +- net/sched/p4tc/p4tc_runtime_api.c | 10 +- net/sched/p4tc/p4tc_table.c | 57 +- net/sched/p4tc/p4tc_tbl_entry.c | 25 +- net/sched/p4tc/p4tc_tmpl_api.c | 4 + net/sched/p4tc/p4tc_tmpl_ext.c | 2221 +++++++++++++++++++++++++++++ 13 files changed, 5083 insertions(+), 10 deletions(-)Quoted 8 lines
This is for this patch. Now for the whole patchset you have:
30 files changed, 16676 insertions(+), 39 deletions(-)I understand that you want to fit into 15 patches with all the work. But sorry, patches like this are unreviewable. My suggestion is to split the patchset into multiple ones including smaller patches and allow people to digest this. I don't believe that anyone can seriously stand to review a patch with more than 200 lines changes.
Quoted 3 lines
This specific patch is not difficult to split into two. I can do that and send out minus the first 8 trivial patches - but not familiar with how to do "here's part 1 of the patches" and "here's patchset two".
Quoted 9 lines
Split into multiple patchsets and send one by one. No need to have all in at once.
Quoted 1 line
There's dependency between them so not clear how patchwork and
What dependency. It should compile. Introduce some basic functionality first and extend it incrementally with other patchsets. The usual way.
Quoted 6 lines
Sorry, still not following:
Lets say i split the current patchset 1 with patch 1-8 (which are trivial and have been reviewed) then make the rest into patchset 2 with a new set 1-8. I dont see how patchset 2 compiles unless it has access to code from patchset 1. Unless patchset 1 is merged i dont see how this works with patchwork or reviewers. Am i missing something?
Quoted 2 lines
Why it would not work. Describe your motivation and plans and submit part of the work, the rest later on. No problem.
Sorry, still not following ;->
So push the trivial patches 1-8 for merge - then push rest in small increments?
cheers,
jamal
Quoted 16 lines
Quoted 16 lines
cheers,
jamalQuoted 11 lines
Quoted 11 lines
reviewers would deal with it. Thoughts?
Note: The code machinery is really repeatable; for example if you look at the tables control you will see very similar patterns to actions etc. i.e spending time to review one will make it easy for the rest.
cheers,
jamalQuoted 1 line
[...]
Quoted 2 lines · Jamal Hadi Salim
We are seeking community feedback on P4TC patches.
[...]
Quoted 3 lines
What is P4?
-----------
I read the cover letter here is my high level takeaway.
P4c-bpf backend exists and I don't see why we wouldn't use that as a starting point. At least the cover letter needs to explain why this path is not taken. From the cover letter there appears to be bpf pieces and non-bpf pieces, but I don't see any reason not to just land it all in BPF. Support exists and if its missing some smaller things add them and everyone gets them vs niche P4 backend.
Without hardware support for any of this its impossible to understand how 'tc' would work as a hardware offload interface for a p4 device so we need hardware support to evaluate. For example I'm not even sure how you would take a BPF parser into hardware on most network devices that aren't processor based.
P4 has a P4Runtime I think most folks would prefer a P4 UI vs typing in 'tc' commands so arguing for 'tc' UI is nice is not going to be very compelling. Best we can say is it works well enough and we use it.
more commentary below.
Quoted 14 lines
The Programming Protocol-independent Packet Processors (P4) is an open source, domain-specific programming language for specifying data plane behavior.
The P4 ecosystem includes an extensive range of deployments, products, projects and services, etc[9][10][11][12].
__Whatis P4TC?__P4TC is a net-namespace aware implementation, meaning multiple P4 programs can run independently in different namespaces alongside their appropriate state. The implementation builds on top of many years of Linux TC experiences. On why P4 - see small treatise here:[4].
Quoted 8 lines
There have been many discussions and meetings since about 2015 in regards to P4 over TC[2] and we are finally proving the naysayers that we do get stuff done!
A lot more of the P4TC motivation is captured at:
https://github.com/p4tc-dev/docs/blob/main/why-p4tc.md**In this patch series we focus on s/w datapath only**.
I don't see the value in adding 16676 lines of code for s/w only datapath of something we already can do with p4c-ebpf backend. Or one of the other backends already there. Namely take P4 programs and run them on CPUs in Linux.
Also I suspect a pipelined datapath is going to be slower than a O(1) lookup datapath so I'm guessing its slower than most datapaths we have already.
What do we gain here over existing p4c-ebpf?
Quoted 11 lines
__P4TCWorkflow__These patches enable kernel and user space code change _independence_ for any new P4 program that describes a new datapath. The workflow is as follows:
1) A developer writes a P4 program, "myprog"
2) Compiles it using the P4C compiler[8]. The compiler generates 3 outputs:
a) shell script(s) which form template definitions for the different P4 objects "myprog" utilizes (tables, externs, actions etc).
This is odd to me. I think packing around shell scrips as a program is not very usable. Why not just an object file.
Quoted 3 lines
b) the parser and the rest of the datapath are generated
in eBPF and need to be compiled into binaries.
c) A json introspection file used for the control plane (by iproute2/tc).
Why split up the eBPF and control plane like this? eBPF has a control plane just use the existing one?
Quoted 28 lines
3) The developer (or operator) executes the shell script(s) to manifest the functional "myprog" into the kernel.
4) The developer (or operator) instantiates "myprog" via the tc P4 filter to ingress/egress (depending on P4 arch) of one or more netdevs/ports.
Example1: parser is an action:
"tc filter add block 22 ingress protocol all prio 10 p4 pname myprog \
action bpf obj $PARSER.o section parser/tc-ingress \
action bpf obj $PROGNAME.o section p4prog/tc"Example2: parser explicitly bound and rest of dpath as an action:
"tc filter add block 22 ingress protocol all prio 10 p4 pname myprog \
prog tc obj $PARSER.o section parser/tc-ingress \
action bpf obj $PROGNAME.o section p4prog/tc"Example3: parser is at XDP, rest of dpath as an action:
"tc filter add block 22 ingress protocol all prio 10 p4 pname myprog \
prog type xdp obj $PARSER.o section parser/xdp-ingress \
pinned_link/path/to/xdp-prog-link \
action bpf obj $PROGNAME.o section p4prog/tc"Example4: parser+prog at XDP:
"tc filter add block 22 ingress protocol all prio 10 p4 pname myprog \
prog type xdp obj $PROGNAME.o section p4prog/xdp \
pinned_link/path/to/xdp-prog-link"
Quoted 8 lines
see individual patches for more examples tc vs xdp etc. Also see section on "challenges" (on this cover letter).
Once "myprog" P4 program is instantiated one can start updating table entries that are associated with myprog's table named "mytable". Example:
tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1
As a UI above is entirely cryptic to most folks I bet.
myprog table is a BPF map? If so then I don't see any need for this just interact with it like a BPF map. I suspect its some other object, but I don't see any ratoinal for that.
Quoted 8 lines
A packet arriving on ingress of any of the ports on block 22 will first be exercised via the (eBPF) parser to find the headers pointing to the ip destination address.
The remainder eBPF datapath uses the result dstAddr as a key to do a lookup in myprog's mytable which returns the action params which are then used to execute the action in the eBPF datapath (eventually sending out packets to eno1). On a table miss, mytable's default miss action is executed.
This chunk looks like standard BPF program. Parse pkt, lookup an action, do the action.
Quoted 9 lines
__DescriptionofPatches__P4TC is designed to have no impact on the core code for other users of TC. IOW, you can compile it out but even if it compiled in and you dont use it there should be no impact on your performance.
We do make core kernel changes. Patch #1 adds infrastructure for "dynamic" actions that can be created on "the fly" based on the P4 program requirement.
the common pattern in bpf for this is to use a tail call map and populate it at runtime and/or just compile your program with the actions. Here the actions came from the p4 back up at step 1 so no reason we can't just compile them with p4c.
Quoted 6 lines
This patch makes a small incision into
act_apiwhich shouldn't affect the performance (or functionality) of the existing actions. Patches 2-4,6-7 are minimalist enablers for P4TC and have no effect the classical tc action. Patch 5 adds infrastructure support for preallocation of dynamic actions.The core P4TC code implements several P4 objects.
[...]
Quoted 11 lines
__RestatingOurRequirements__The initial release made in January/2023 had a "scriptable" datapath (think u32 classifier and pedit action). In this section we review the scriptable version against the current implementation we are pushing upstream which uses eBPF.
Our intention is to target the TC crowd.
Essentially developers and ops people deploying TC based infra.
More importantly the original intent for P4TC was to enable_opsfolks_more than devs (given code is being generated and doesn't need humans to write it).
I don't follow. humans wrote the p4.
I think the intent should be to enable P4 to run on Linux. Ideally efficiently. If the _ops folks are writing P4 great as long as we give them an efficient way to run their p4 I don't think they care about what executes it.
Quoted 9 lines
With TC, we get whole "familiar" package of match-action pipeline abstraction++, meaning from the control plane all the way to the tooling infra, i.e iproute2/tc cli, netlink
infra(request/resp, event subscribe/multicast-publish, congestion control etc), s/w and h/w symbiosis, the autonomous kernel control, etc.
The main advantage is that we have a singular vendor-neutral interface via the kernel using well understood mechanisms based on deployment experience (and at least this part doesnt need retraining).
A seemless p4 experience would be great. That looks like a tooling problem at the p4c-backend and p4c-frontend problem. Rather than a bunch of 'tc' glue I would aim for,
$ p4c-* myprog.p4 $ p4cRun ./myprog
And maybe some options like,
$ p4cRun -i eth0 ./myprog
Then use the p4runtime to interface with the system. If you don't like the runtime then it should be brought up in that working group.
Quoted 9 lines
1) Supporting expressibility of the universe set of P4 progs
It is a must to support 100% of all possible P4 programs. In the past the eBPF verifier had to be worked around and even then there are cases where we couldnt avoid path explosion when branching is involved. Kfunc-ing solves these issues for us. Note, there are still challenges running all potential P4 programs at the XDP level - the solution to that is to have the compiler generate XDP based code only if it possible to map it to that layer.
Examples and we can fix it.
Quoted 6 lines
2) Support for P4 HW and SW equivalence.
This feature continues to work even in the presence of eBPF as the s/w datapath. There are cases of square-hole-round-peg scenarios but those are implementation issues we can live with.
But no hw support.
Quoted 8 lines
3) Operational usability
By maintaining the TC control plane (even in presence of eBPF datapath) runtime aspects remain unchanged. So for our target audience of folks who have deployed tc including offloads - the comfort zone is unchanged. There is also the comfort zone of continuing to use the true-and-tried netlink interfacing.
The P4 control plane should be P4Runtime.
Quoted 13 lines
There is some loss in operational usability because we now have more knobs:
the extra compilation, loading and syncing of ebpf binaries, etc. IOW, I can no longer just ship someone a shell script in an email to say go run this and "myprog" will just work.4) Operational and development Debuggability
If something goes wrong, the tc craftsperson is now required to have additional knowledge of eBPF code and process. This applies to both the operational person as well as someone who wrote a driver. We dont believe this is solvable.
5) Opportunity for rapid prototyping of new ideas
[...]
Quoted 4 lines
6) Supporting per namespace program
This requirement is still met (by virtue of keeping P4 control objects within the TC domain).
BPF can also be network namespaced I'm not sure I understand comment.
Quoted 20 lines
__Challenges__1) Concept of tc block in XDP is
_verytedious_to implement. It would be nice if we can use concept there as well, since we expect P4 to work with many ports. It will likely require some core patches to fix this.2) Right now we are using "packed" construct to enforce alignment in kfunc data exchange; but we're wondering if there is potential to use BTF to understand parameters and their offsets and encode this information at the compiler level.
3) At the moment we are creating a static buffer of 128B to retrieve the action parameters. If you have a lot of table entries and individual(non-shared) action instances with actions that require very little (or no) param space a lot of memory is wasted. There may also be cases where 128B may not be enough; (likely this is something we can teach the P4C compiler). If we can have dynamic pointers instead for kfunc fixed length parameterization then this issue is resolvable.
Quoted 4 lines
4) See "Restating Our Requirements" #5.
We would really appreciate ideas/suggestions, etc.
__References__
Thanks,
John
Jamal Hadi Salim
maintainerQuoted 5 lines · John Fastabend
Quoted 2 lines · Jamal Hadi Salim
We are seeking community feedback on P4TC patches.
Quoted 8 lines
[...]
Quoted 3 lines
What is P4?
-----------I read the cover letter here is my high level takeaway.
At least you read the cover letter this time ;->
Quoted 2 lines
P4c-bpf backend exists and I don't see why we wouldn't use that as a starting point.
Are you familiar with P4 architectures? That code was for PSA (which is essentially for switches) we are doing PNA (which is more nic oriented).
And yes, we used that code as a starting point and made the necessary changes needed to conform to PNA. We made it actually work better by using kfuncs.
Quoted 1 line
At least the cover letter needs to explain why this path is not taken.
I thought we had a reference to that backend - but will add it for the next update.
Quoted 4 lines
From the cover letter there appears to be bpf pieces and non-bpf pieces, but I don't see any reason not to just land it all in BPF. Support exists and if its missing some smaller things add them and everyone gets them vs niche P4 backend.
Ok, i thought you said you read the cover letter. Reasons are well stated, primarily that we need to make sure all P4 programs work.
Quoted 6 lines
Without hardware support for any of this its impossible to understand how 'tc' would work as a hardware offload interface for a p4 device so we need hardware support to evaluate. For example I'm not even sure how you would take a BPF parser into hardware on most network devices that aren't processor based.
P4 has nothing to do with parsers in hardware. Where did you get this requirement from?
Quoted 3 lines
P4 has a P4Runtime I think most folks would prefer a P4 UI vs typing in 'tc' commands so arguing for 'tc' UI is nice is not going to be very compelling. Best we can say is it works well enough and we use it.
The control plane interface is netlink. This part is not negotiable. You can write whatever you want on top of it(for example P4runtime using netlink as its southbound interface). We feel that tc - a well understood utility - is one we should make publicly available for the rest of the world to use. For example we have rust code that runs on top of netlink to do performance testing.
Quoted 20 lines
more commentary below.
Quoted 18 lines
The Programming Protocol-independent Packet Processors (P4) is an open source, domain-specific programming language for specifying data plane behavior.
The P4 ecosystem includes an extensive range of deployments, products, projects and services, etc[9][10][11][12].
__Whatis P4TC?__P4TC is a net-namespace aware implementation, meaning multiple P4 programs can run independently in different namespaces alongside their appropriate state. The implementation builds on top of many years of Linux TC experiences. On why P4 - see small treatise here:[4].
There have been many discussions and meetings since about 2015 in regards to P4 over TC[2] and we are finally proving the naysayers that we do get stuff done!
Quoted 7 lines
Quoted 4 lines
A lot more of the P4TC motivation is captured at:
https://github.com/p4tc-dev/docs/blob/main/why-p4tc.md**In this patch series we focus on s/w datapath only**.
I don't see the value in adding 16676 lines of code for s/w only datapath of something we already can do with p4c-ebpf backend.
Please please stop this entitlement politics (which i frankly think you guys have been getting away with for a few years now). This code does not touch any core code - you guys constantly push code that touches core code and it is not unusual we have to pick up the pieces after but now you are going to call me out for the number of lines of code? Is it ok for you to write lines of code in the kernel but not me? Judge the technical work then we can have a meaningful discussion.
TBH, I am trying very hard to see if i should respond to any more comments from you. I was very happy with our original scriptable approach and you came out and banged on the table that you want ebpf. We spent 10 months of multiple people working on this code to make it ebpf friendly and now you want more (actually i am not sure what the hell you want).
Quoted 8 lines
Or one of the other
backends already there. Namely take P4 programs and run them on CPUs in Linux.Also I suspect a pipelined datapath is going to be slower than a O(1) lookup datapath so I'm guessing its slower than most datapaths we have already.
What do we gain here over existing p4c-ebpf?
see above.
Quoted 15 lines
Quoted 11 lines
__P4TCWorkflow__These patches enable kernel and user space code change _independence_ for any new P4 program that describes a new datapath. The workflow is as follows:
1) A developer writes a P4 program, "myprog"
2) Compiles it using the P4C compiler[8]. The compiler generates 3 outputs:
a) shell script(s) which form template definitions for the different P4 objects "myprog" utilizes (tables, externs, actions etc).This is odd to me. I think packing around shell scrips as a program is not very usable. Why not just an object file.
Quoted 7 lines
Quoted 3 lines
b) the parser and the rest of the datapath are generated
in eBPF and need to be compiled into binaries.
c) A json introspection file used for the control plane (by iproute2/tc).Why split up the eBPF and control plane like this? eBPF has a control plane just use the existing one?
The cover letter clearly states that we are using netlink as the control api. Does eBPF support netlink?
Quoted 31 lines
Quoted 31 lines
3) The developer (or operator) executes the shell script(s) to manifest the functional "myprog" into the kernel.
4) The developer (or operator) instantiates "myprog" via the tc P4 filter to ingress/egress (depending on P4 arch) of one or more netdevs/ports.
Example1: parser is an action:
"tc filter add block 22 ingress protocol all prio 10 p4 pname myprog \
action bpf obj $PARSER.o section parser/tc-ingress \
action bpf obj $PROGNAME.o section p4prog/tc"Example2: parser explicitly bound and rest of dpath as an action:
"tc filter add block 22 ingress protocol all prio 10 p4 pname myprog \
prog tc obj $PARSER.o section parser/tc-ingress \
action bpf obj $PROGNAME.o section p4prog/tc"Example3: parser is at XDP, rest of dpath as an action:
"tc filter add block 22 ingress protocol all prio 10 p4 pname myprog \
prog type xdp obj $PARSER.o section parser/xdp-ingress \
pinned_link/path/to/xdp-prog-link \
action bpf obj $PROGNAME.o section p4prog/tc"Example4: parser+prog at XDP:
"tc filter add block 22 ingress protocol all prio 10 p4 pname myprog \
prog type xdp obj $PROGNAME.o section p4prog/xdp \
pinned_link/path/to/xdp-prog-link"see individual patches for more examples tc vs xdp etc. Also see section on "challenges" (on this cover letter).
Quoted 8 lines
Quoted 5 lines
Once "myprog" P4 program is instantiated one can start updating table entries that are associated with myprog's table named "mytable". Example:
tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1As a UI above is entirely cryptic to most folks I bet.
But ebpf is not?
Quoted 3 lines
myprog table is a BPF map? If so then I don't see any need for this just interact with it like a BPF map. I suspect its some other object, but I don't see any ratoinal for that.
All the P4 objects sit in the TC domain. The datapath program is ebpf. Control is via netlink.
Quoted 9 lines
Quoted 8 lines
A packet arriving on ingress of any of the ports on block 22 will first be exercised via the (eBPF) parser to find the headers pointing to the ip destination address.
The remainder eBPF datapath uses the result dstAddr as a key to do a lookup in myprog's mytable which returns the action params which are then used to execute the action in the eBPF datapath (eventually sending out packets to eno1). On a table miss, mytable's default miss action is executed.
Quoted 3 lines
This chunk looks like standard BPF program. Parse pkt, lookup an action, do the action.
Yes, the ebpf datapath does the parsing, and then interacts with kfuncs to the tc world before it (the ebpf datapath) executes the action.
Note: ebpf did not invent any of that (parse, lookup, action). It has existed in tc for 20 years before ebpf existed.
Quoted 30 lines
Quoted 8 lines
__DescriptionofPatches__P4TC is designed to have no impact on the core code for other users of TC. IOW, you can compile it out but even if it compiled in and you dont use it there should be no impact on your performance.
We do make core kernel changes. Patch #1 adds infrastructure for "dynamic" actions that can be created on "the fly" based on the P4 program requirement.
the common pattern in bpf for this is to use a tail call map and populate it at runtime and/or just compile your program with the actions. Here the actions came from the p4 back up at step 1 so no reason we can't just compile them with p4c.
Quoted 6 lines
This patch makes a small incision into
act_apiwhich shouldn't affect the performance (or functionality) of the existing actions. Patches 2-4,6-7 are minimalist enablers for P4TC and have no effect the classical tc action. Patch 5 adds infrastructure support for preallocation of dynamic actions.The core P4TC code implements several P4 objects.
[...]
Quoted 7 lines
__RestatingOurRequirements__The initial release made in January/2023 had a "scriptable" datapath (think u32 classifier and pedit action). In this section we review the scriptable version against the current implementation we are pushing upstream which uses eBPF.
Quoted 7 lines
Quoted 4 lines
Our intention is to target the TC crowd.
Essentially developers and ops people deploying TC based infra.
More importantly the original intent for P4TC was to enable_opsfolks_more than devs (given code is being generated and doesn't need humans to write it).I don't follow. humans wrote the p4.
But not the ebpf code, that is compiler generated. P4 is a higher level Domain specific language and ebpf is just one backend (others s/w variants include DPDK, Rust, C, etc)
Quoted 18 lines
I think the intent should be to enable P4 to run on Linux. Ideally efficiently. If the
_opsfolks are writing P4 great as long as we give them an efficient way to run their p4 I don't think they care about what executes it.Quoted 9 lines
With TC, we get whole "familiar" package of match-action pipeline abstraction++, meaning from the control plane all the way to the tooling infra, i.e iproute2/tc cli, netlink
infra(request/resp, event subscribe/multicast-publish, congestion control etc), s/w and h/w symbiosis, the autonomous kernel control, etc.
The main advantage is that we have a singular vendor-neutral interface via the kernel using well understood mechanisms based on deployment experience (and at least this part doesnt need retraining).A seemless p4 experience would be great. That looks like a tooling problem at the p4c-backend and p4c-frontend problem. Rather than a bunch of 'tc' glue I would aim for,
Quoted 6 lines
$ p4c-* myprog.p4 $ p4cRun ./myprogAnd maybe some options like,
$ p4cRun -i eth0 ./myprog
Armchair lawyering and classical ML bikesheding
Quoted 6 lines
Then use the p4runtime to interface with the system. If you don't like the runtime then it should be brought up in that working group.
Quoted 3 lines
1) Supporting expressibility of the universe set of P4 progs
Quoted 8 lines
Quoted 6 lines
It is a must to support 100% of all possible P4 programs. In the past the eBPF verifier had to be worked around and even then there are cases where we couldnt avoid path explosion when branching is involved. Kfunc-ing solves these issues for us. Note, there are still challenges running all potential P4 programs at the XDP level - the solution to that is to have the compiler generate XDP based code only if it possible to map it to that layer.
Examples and we can fix it.
Right. Let me wait for you to fix something 5 years from now. I would never have used eBPF at all but the kfunc is what changed my mind.
Quoted 9 lines
Quoted 6 lines
2) Support for P4 HW and SW equivalence.
This feature continues to work even in the presence of eBPF as the s/w datapath. There are cases of square-hole-round-peg scenarios but those are implementation issues we can live with.
But no hw support.
This patcheset has nothing to do with offload (you read the cover letter?). All above is saying is that by virtue of using TC we have a path to a proven offload approach.
Quoted 11 lines
Quoted 8 lines
3) Operational usability
By maintaining the TC control plane (even in presence of eBPF datapath) runtime aspects remain unchanged. So for our target audience of folks who have deployed tc including offloads - the comfort zone is unchanged. There is also the comfort zone of continuing to use the true-and-tried netlink interfacing.
The P4 control plane should be P4Runtime.
And be my guest and write it on top of netlink.
cheers,
jamal
Quoted 50 lines
Quoted 13 lines
There is some loss in operational usability because we now have more knobs:
the extra compilation, loading and syncing of ebpf binaries, etc. IOW, I can no longer just ship someone a shell script in an email to say go run this and "myprog" will just work.4) Operational and development Debuggability
If something goes wrong, the tc craftsperson is now required to have additional knowledge of eBPF code and process. This applies to both the operational person as well as someone who wrote a driver. We dont believe this is solvable.
5) Opportunity for rapid prototyping of new ideas
[...]
Quoted 4 lines
6) Supporting per namespace program
This requirement is still met (by virtue of keeping P4 control objects within the TC domain).
BPF can also be network namespaced I'm not sure I understand comment.
Quoted 20 lines
__Challenges__1) Concept of tc block in XDP is
_verytedious_to implement. It would be nice if we can use concept there as well, since we expect P4 to work with many ports. It will likely require some core patches to fix this.2) Right now we are using "packed" construct to enforce alignment in kfunc data exchange; but we're wondering if there is potential to use BTF to understand parameters and their offsets and encode this information at the compiler level.
3) At the moment we are creating a static buffer of 128B to retrieve the action parameters. If you have a lot of table entries and individual(non-shared) action instances with actions that require very little (or no) param space a lot of memory is wasted. There may also be cases where 128B may not be enough; (likely this is something we can teach the P4C compiler). If we can have dynamic pointers instead for kfunc fixed length parameterization then this issue is resolvable.
Quoted 4 lines
4) See "Restating Our Requirements" #5.
We would really appreciate ideas/suggestions, etc.
__References__Thanks,
John
Quoted 9 lines · Jamal Hadi Salim
Quoted 8 lines · John Fastabend
Quoted 2 lines · Jamal Hadi Salim
We are seeking community feedback on P4TC patches.
[...]
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
What is P4?
-----------I read the cover letter here is my high level takeaway.
At least you read the cover letter this time ;->
I read it last time as well. About mid way down I tried to list the points (1-5) more concisely if folks want to get to the meat of my argument quickly.
Quoted 6 lines
Quoted 2 lines
P4c-bpf backend exists and I don't see why we wouldn't use that as a starting point.
Are you familiar with P4 architectures? That code was for PSA (which is essentially for switches) we are doing PNA (which is more nic oriented).
Yes. But for folks that are not PSA is a switch architecture it looks roughly like this,
parser -> ingress -> deparser -> pkt replication -> parser
-> egress
-> deparser
-> queueingThe gist is ingress/egress blocks hold your p4 logic (match action tables usually) to xfrm headers, counters, registers, and so on. You get one on ingress and one on egress to build your logic up.
And PNA is a roughly like this,
ingress -> parser -> control -> deparser -> accelerators -> host | network
An accelerators are externs more or less defined outside P4. Control has all your metrics, header transforms, registers, and so on. And parser well it parsers headers. Deparser is something we don't typically think about much on sw side but it serializes the object back into a packet. That is a rough couple line explanation.
You can also define whatever architecture like and there are some ways to do that. But if you want to be a PSA or PNA you define those blocks in your P4. The key idea is to have architectures that map to a large set of different vendor hardware. Clearly sw and FPGAs can build mostly any architecture needed.
As an editorial comment P4 is very much a hardware centric view of the world when looking at P4 architectures. SW never needed these because we mostly have general purpose CPUs.
Quoted 3 lines
And yes, we used that code as a starting point and made the necessary changes needed to conform to PNA. We made it actually work better by using kfuncs.
Better performance? More P4 DSL program space implemented? The kfuncs added are equivelant to map ops already in BPF but over 'tc' map types. Or did I miss some kfuncs.
The p4c-ebpf backend already supports two models we could have added the PNA model to it as well. Its actually simpler than PSA model in many ways at least its fewer blocks. I think all this infrastructure here could be unesseary with updates to p4c-ebpf.
Quoted 6 lines
Quoted 2 lines
At least the cover letter needs to explain why this path is not taken.
I thought we had a reference to that backend - but will add it for the next update.
Quoted 7 lines
Quoted 4 lines
From the cover letter there appears to be bpf pieces and non-bpf pieces, but I don't see any reason not to just land it all in BPF. Support exists and if its missing some smaller things add them and everyone gets them vs niche P4 backend.
Ok, i thought you said you read the cover letter. Reasons are well stated, primarily that we need to make sure all P4 programs work.
I don't think that is a very strong argument to use/build a p4c-tc architecture and implementation instead of p4c-ebpf. I can't think of any reason p4c-ebpf can't support all programs other than perhaps its missing a few items. From a design side though it should be capabable of any PSA, PNA, and many more architectures you come up with.
And I'm genuinely curious what is missing so a list would be nice. The missing block perhaps is a perfomant software TCAM, but I'm not fully convinced that software should even bother to try and duplicate a TCAM. If you need a performant TCAM buy hw with a TCAM emulating one is always going to be slower. Have Intel/AMD/ARM glue a TCAM to the core if its so useful.
To be clear p4c-tc is only targeting PNA programs not all P4 space.
Quoted 10 lines
Quoted 7 lines
Without hardware support for any of this its impossible to understand how 'tc' would work as a hardware offload interface for a p4 device so we need hardware support to evaluate. For example I'm not even sure how you would take a BPF parser into hardware on most network devices that aren't processor based.
P4 has nothing to do with parsers in hardware. Where did you get this requirement from?
P4 is/was primarily developed as a DSL to program hardware. We've never figured out how to do a native Linux P4 controller for hardware. There are a couple blockers for that in my opinion. First no one has ever opened up the hardware to an OSS solution. Two its never been entirely clear what the big win for enough people would be. So we get targetted offloads, timestamp, vxlan, tso, ktls, even heard quic offload yesterday. And its easy enough to just program the hardware directly from user space.
So yes I think P4 has a lot to do with hardware, its probably fair to say this p4c-tc thing isn't hardware. But, I think its very limiting and the value of any p4 implementation in kernel would be its ability to use hardware.
I'm not even convinced P4 is a good DSL for SW implementations. I don't think its obvious how hw P4 and sw datapaths integrate effectively. My opinion is p4c-tc is not moving us forward here.
Quoted 9 lines
Quoted 4 lines
P4 has a P4Runtime I think most folks would prefer a P4 UI vs typing in 'tc' commands so arguing for 'tc' UI is nice is not going to be very compelling. Best we can say is it works well enough and we use it.
The control plane interface is netlink. This part is not negotiable. You can write whatever you want on top of it(for example P4runtime using netlink as its southbound interface). We feel that tc - a well
Sure we need a low level interface for p4runtime to use and I agree we don't need all blocks done at once.
Quoted 3 lines
understood utility - is one we should make publicly available for the rest of the world to use. For example we have rust code that runs on top of netlink to do performance testing.
If updates/lookups from userspace is a performance vector you care about I can't see how netlink is more efficient than a mmapped bpf map. If you have data share it, but it seems highly unlikely.
The argument I'm trying to make is netlink vs bpf maps vs some other goo shouldn't matter to users because we should build them higher level tooling to interact with the p4 objects. Then it comes down to performance in my opinion. And if map updates matter I suspect netlink is relatively slow.
Quoted 24 lines
Quoted 24 lines
more commentary below.
Quoted 21 lines
The Programming Protocol-independent Packet Processors (P4) is an open source, domain-specific programming language for specifying data plane behavior.
The P4 ecosystem includes an extensive range of deployments, products, projects and services, etc[9][10][11][12].
__Whatis P4TC?__P4TC is a net-namespace aware implementation, meaning multiple P4 programs can run independently in different namespaces alongside their appropriate state. The implementation builds on top of many years of Linux TC experiences. On why P4 - see small treatise here:[4].
There have been many discussions and meetings since about 2015 in regards to P4 over TC[2] and we are finally proving the naysayers that we do get stuff done!
A lot more of the P4TC motivation is captured at:
https://github.com/p4tc-dev/docs/blob/main/why-p4tc.md
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
**In this patch series we focus on s/w datapath only**.
I don't see the value in adding 16676 lines of code for s/w only datapath of something we already can do with p4c-ebpf backend.
Please please stop this entitlement politics (which i frankly think you guys have been getting away with for a few years now).
I'm allowed to disagree with your architecture and propose what I think is a betteer way to translate P4 into software.
Its common to argue against adding new code if it duplicates functionality we already support.
Quoted 6 lines
This code does not touch any core code - you guys constantly push code that touches core code and it is not unusual we have to pick up the pieces after but now you are going to call me out for the number of lines of code? Is it ok for you to write lines of code in the kernel but not me? Judge the technical work then we can have a meaningful discussion.
I think I'm judging the technical work here. Bullet points.
1. p4c-tc implementation looks like it should be slower than a in terms of pkts/sec than a bpf implementation. Meaning I suspect pipeline and objects laid out like this will lose to a BPF program with an parser and single lookup. The p4c-ebpf compiler should look to create optimized EBPF code not some emulated switch topology.
2. p4c-tc control plan looks slower than a directly mmaped bpf map. Doing a simple update vs a netlink msg. The argument that BPF can't do CRUD (which we had offlist) seems incorrect to me. Correct me if I'm wrong with details about why.
2. I don't see why ebpf can not support all P4 programs. Because the DSL compiler side doesn't support the nic architecture side to me indicates fixing the compiler is the direction not pushing on the kernel.
3. Working in BPF framework will benefit more folks than a tc framework. I just don't see a large user base of P4 software running on Linux. It doesn't mean we can't have it in linux, but worth considering. We have lots of niche stuff in the kernel, but usually the niche thing doesn't have another more common way to run it.
4. The win for P4 is not sw implementation. Its about getting programmable hardware and this doesn't advance that goal in any meaningful way as far as I can see.
5. By pushing the P4 model so low in the stack of tooling you lose ability for compiler to do interesting things. Combining match action tables, converting them to switch statements or jumps, finding inverse operations and removing them. I still think there is lots of unexplored work on compiling P4 that has not been done.
Quoted 7 lines
TBH, I am trying very hard to see if i should respond to any more comments from you. I was very happy with our original scriptable approach and you came out and banged on the table that you want ebpf. We spent 10 months of multiple people working on this code to make it ebpf friendly and now you want more (actually i am not sure what the hell you want).
I've made the above arguments on early versions of the code, and when we talked, and even offered it in p4 working group. It shouldn't be surprising I've not changed my opinion.
Its a argument against duplicating existing functionality with something that is slower and doesn't give us HW P4 support. The bullets above.
Quoted 11 lines
Quoted 9 lines
Or one of the other
backends already there. Namely take P4 programs and run them on CPUs in Linux.Also I suspect a pipelined datapath is going to be slower than a O(1) lookup datapath so I'm guessing its slower than most datapaths we have already.
What do we gain here over existing p4c-ebpf?
see above.
We are talking past eachother becaus here I argue it looks like a slow datapath and you say 'see above' but what above was I meant to see? That it doesn't have PNA support? Compared to PSA doing a PNA support should be straightforward.
I disagree that software should try to emulate hardware to closely. They are fundamentally different platforms. One has CAMs, TCAMs, and LPMs and obscure instruction sets to make all this work. The other is working on a general purpose CPU. I think slamming a hardware architecture into software with emulated TCAMs and what not, will be a losing performance proposition. Experience shows you can either go SIMD direction and parrallize everything with these instructions or you reduce the datapath to a single (or minimal set) of lookups. Find a counter-example.
Quoted 20 lines
Quoted 20 lines
Quoted 4 lines
__P4TCWorkflow__Quoted 8 lines
These patches enable kernel and user space code change _independence_ for any new P4 program that describes a new datapath. The workflow is as follows:
1) A developer writes a P4 program, "myprog"
2) Compiles it using the P4C compiler[8]. The compiler generates 3 outputs:
a) shell script(s) which form template definitions for the different P4 objects "myprog" utilizes (tables, externs, actions etc).This is odd to me. I think packing around shell scrips as a program is not very usable. Why not just an object file.
Quoted 3 lines
b) the parser and the rest of the datapath are generated
in eBPF and need to be compiled into binaries.
c) A json introspection file used for the control plane (by iproute2/tc).
Quoted 6 lines
Quoted 3 lines
Why split up the eBPF and control plane like this? eBPF has a control plane just use the existing one?
The cover letter clearly states that we are using netlink as the control api. Does eBPF support netlink?
But why? The statement is there but no rational is given. People are used to it was maybe stated, but my argument is users of P4 shouldn't be crafting netlink messages they need tooling if its netlink or BPF or some new thing. So pick the most efficient tool for the job. Why is netlink the most efficient option here.
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
3) The developer (or operator) executes the shell script(s) to manifest the functional "myprog" into the kernel.
4) The developer (or operator) instantiates "myprog" via the tc P4 filter to ingress/egress (depending on P4 arch) of one or more netdevs/ports.
Example1: parser is an action:
"tc filter add block 22 ingress protocol all prio 10 p4 pname myprog \
action bpf obj $PARSER.o section parser/tc-ingress \
action bpf obj $PROGNAME.o section p4prog/tc"Example2: parser explicitly bound and rest of dpath as an action:
"tc filter add block 22 ingress protocol all prio 10 p4 pname myprog \
prog tc obj $PARSER.o section parser/tc-ingress \
action bpf obj $PROGNAME.o section p4prog/tc"Example3: parser is at XDP, rest of dpath as an action:
"tc filter add block 22 ingress protocol all prio 10 p4 pname myprog \
prog type xdp obj $PARSER.o section parser/xdp-ingress \
pinned_link/path/to/xdp-prog-link \
action bpf obj $PROGNAME.o section p4prog/tc"Example4: parser+prog at XDP:
"tc filter add block 22 ingress protocol all prio 10 p4 pname myprog \
prog type xdp obj $PROGNAME.o section p4prog/xdp \
pinned_link/path/to/xdp-prog-link"see individual patches for more examples tc vs xdp etc. Also see section on "challenges" (on this cover letter).
Once "myprog" P4 program is instantiated one can start updating table entries that are associated with myprog's table named "mytable". Example:
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1As a UI above is entirely cryptic to most folks I bet.
But ebpf is not?
We don't need everything out the gate but my point is that the UI should be abstracted away from the P4 programmer and operator at this level. My observation that 'tc' is cryptic was just an off-hand comment I don't think its relevant to the overall argument for or against, what we should understand is how to map p4runtime or at least a operator friendly UI onto the semantics.
Quoted 7 lines
Quoted 4 lines
myprog table is a BPF map? If so then I don't see any need for this just interact with it like a BPF map. I suspect its some other object, but I don't see any ratoinal for that.
All the P4 objects sit in the TC domain. The datapath program is ebpf. Control is via netlink.
I'm missing something fundamental. What do we gain from this TC domain. There are some TC maps for LPM and TCAMs we have LPM already in BPF and TCAM you have could easily be added if you want to. Then entire program runs to completion. Surely this is more performant. Throw in XDP and the redirect never leaves the NIC, no skb, etc.
From the architecture side I don't think we need kernel objects for pipelines and some P4 notion of match action tables those can all be mapped into the BPF program. The packet never leaves XDP. Performance is good on datapath and performance is good on map update side. It looks like noise to me teaching the kernel about P4 objects and types. More importantly you are constraining the optimizations the compiler can make. Perhaps the compiler wants no map at all and implements it as a switch stmt for example. Maybe the compiler can find inverse operations and fastpaths to short circuit. By forcing the model so low in the stack you remove this ability.
Quoted 15 lines
Quoted 11 lines
Quoted 10 lines
A packet arriving on ingress of any of the ports on block 22 will first be exercised via the (eBPF) parser to find the headers pointing to the ip destination address.
The remainder eBPF datapath uses the result dstAddr as a key to do a lookup in myprog's mytable which returns the action params which are then used to execute the action in the eBPF datapath (eventually sending out packets to eno1). On a table miss, mytable's default miss action is executed.Quoted 3 lines
This chunk looks like standard BPF program. Parse pkt, lookup an action, do the action.
Quoted 5 lines
Yes, the ebpf datapath does the parsing, and then interacts with kfuncs to the tc world before it (the ebpf datapath) executes the action.
Note: ebpf did not invent any of that (parse, lookup, action). It has existed in tc for 20 years before ebpf existed.
Its not about who invented what. All this goes way back.
My point is the 'tc' world here looks unnecessary. It can be managed from outside the kernel entirely.
Quoted 36 lines
Quoted 36 lines
Quoted 9 lines
__DescriptionofPatches__P4TC is designed to have no impact on the core code for other users of TC. IOW, you can compile it out but even if it compiled in and you dont use it there should be no impact on your performance.
We do make core kernel changes. Patch #1 adds infrastructure for "dynamic" actions that can be created on "the fly" based on the P4 program requirement.
the common pattern in bpf for this is to use a tail call map and populate it at runtime and/or just compile your program with the actions. Here the actions came from the p4 back up at step 1 so no reason we can't just compile them with p4c.
Quoted 6 lines
This patch makes a small incision into
act_apiwhich shouldn't affect the performance (or functionality) of the existing actions. Patches 2-4,6-7 are minimalist enablers for P4TC and have no effect the classical tc action. Patch 5 adds infrastructure support for preallocation of dynamic actions.The core P4TC code implements several P4 objects.
[...]
Quoted 11 lines
__RestatingOurRequirements__The initial release made in January/2023 had a "scriptable" datapath (think u32 classifier and pedit action). In this section we review the scriptable version against the current implementation we are pushing upstream which uses eBPF.
Our intention is to target the TC crowd.
Essentially developers and ops people deploying TC based infra.
More importantly the original intent for P4TC was to enable_opsfolks_more than devs (given code is being generated and doesn't need humans to write it).
Quoted 6 lines
Quoted 2 lines
I don't follow. humans wrote the p4.
But not the ebpf code, that is compiler generated. P4 is a higher level Domain specific language and ebpf is just one backend (others s/w variants include DPDK, Rust, C, etc)
Yes. I still don't follow. Of course ebpf is just one backend.
Quoted 19 lines
Quoted 19 lines
I think the intent should be to enable P4 to run on Linux. Ideally efficiently. If the
_opsfolks are writing P4 great as long as we give them an efficient way to run their p4 I don't think they care about what executes it.Quoted 9 lines
With TC, we get whole "familiar" package of match-action pipeline abstraction++, meaning from the control plane all the way to the tooling infra, i.e iproute2/tc cli, netlink
infra(request/resp, event subscribe/multicast-publish, congestion control etc), s/w and h/w symbiosis, the autonomous kernel control, etc.
The main advantage is that we have a singular vendor-neutral interface via the kernel using well understood mechanisms based on deployment experience (and at least this part doesnt need retraining).A seemless p4 experience would be great. That looks like a tooling problem at the p4c-backend and p4c-frontend problem. Rather than a bunch of 'tc' glue I would aim for,
Quoted 8 lines
Quoted 6 lines
$ p4c-* myprog.p4 $ p4cRun ./myprogAnd maybe some options like,
$ p4cRun -i eth0 ./myprogArmchair lawyering and classical ML bikesheding
It was just an example of what I think the end goal should be.
Quoted 26 lines
Quoted 7 lines
Then use the p4runtime to interface with the system. If you don't like the runtime then it should be brought up in that working group.
Quoted 3 lines
1) Supporting expressibility of the universe set of P4 progs
Quoted 8 lines
Quoted 6 lines
It is a must to support 100% of all possible P4 programs. In the past the eBPF verifier had to be worked around and even then there are cases where we couldnt avoid path explosion when branching is involved. Kfunc-ing solves these issues for us. Note, there are still challenges running all potential P4 programs at the XDP level - the solution to that is to have the compiler generate XDP based code only if it possible to map it to that layer.
Examples and we can fix it.
Right. Let me wait for you to fix something 5 years from now. I would never have used eBPF at all but the kfunc is what changed my mind.
Quoted 7 lines
Quoted 6 lines
2) Support for P4 HW and SW equivalence.
This feature continues to work even in the presence of eBPF as the s/w datapath. There are cases of square-hole-round-peg scenarios but those are implementation issues we can live with.
Quoted 6 lines
Quoted 2 lines
But no hw support.
This patcheset has nothing to do with offload (you read the cover letter?). All above is saying is that by virtue of using TC we have a path to a proven offload approach.
I'm arguing P4 is in a big part about programmable HW. If we merge a P4 into the kernel all the way down to the p4 types and don't consider how it works with hardware that is a non starter for me.
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
3) Operational usability
By maintaining the TC control plane (even in presence of eBPF datapath) runtime aspects remain unchanged. So for our target audience of folks who have deployed tc including offloads - the comfort zone is unchanged. There is also the comfort zone of continuing to use the true-and-tried netlink interfacing.
Quoted 4 lines
Quoted 2 lines
The P4 control plane should be P4Runtime.
And be my guest and write it on top of netlink.
But I would prefer it was a BPF map and gave my reasons above.
Quoted 3 lines
cheers,
jamal
Jamal Hadi Salim
maintainerQuoted 14 lines · John Fastabend
Quoted 12 lines · Jamal Hadi Salim
Quoted 11 lines · John Fastabend
Quoted 2 lines · Jamal Hadi Salim
We are seeking community feedback on P4TC patches.
[...]
Quoted 3 lines
What is P4?
-----------
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
I read the cover letter here is my high level takeaway.
At least you read the cover letter this time ;->
I read it last time as well. About mid way down I tried to list the points (1-5) more concisely if folks want to get to the meat of my argument quickly.
You wrote an essay - i will just jump to your points further down the text below and try and summarize it...
Quoted 186 lines
Quoted 6 lines
Quoted 2 lines
P4c-bpf backend exists and I don't see why we wouldn't use that as a starting point.
Are you familiar with P4 architectures? That code was for PSA (which is essentially for switches) we are doing PNA (which is more nic oriented).
Yes. But for folks that are not PSA is a switch architecture it looks roughly like this,
parser -> ingress -> deparser -> pkt replication -> parser -> egress -> deparser -> queueingThe gist is ingress/egress blocks hold your p4 logic (match action tables usually) to xfrm headers, counters, registers, and so on. You get one on ingress and one on egress to build your logic up.
And PNA is a roughly like this,
ingress -> parser -> control -> deparser -> accelerators -> host | networkAn accelerators are externs more or less defined outside P4. Control has all your metrics, header transforms, registers, and so on. And parser well it parsers headers. Deparser is something we don't typically think about much on sw side but it serializes the object back into a packet. That is a rough couple line explanation.
You can also define whatever architecture like and there are some ways to do that. But if you want to be a PSA or PNA you define those blocks in your P4. The key idea is to have architectures that map to a large set of different vendor hardware. Clearly sw and FPGAs can build mostly any architecture needed.
As an editorial comment P4 is very much a hardware centric view of the world when looking at P4 architectures. SW never needed these because we mostly have general purpose CPUs.
Quoted 3 lines
And yes, we used that code as a starting point and made the necessary changes needed to conform to PNA. We made it actually work better by using kfuncs.
Better performance? More P4 DSL program space implemented? The kfuncs added are equivelant to map ops already in BPF but over 'tc' map types. Or did I miss some kfuncs.
The p4c-ebpf backend already supports two models we could have added the PNA model to it as well. Its actually simpler than PSA model in many ways at least its fewer blocks. I think all this infrastructure here could be unesseary with updates to p4c-ebpf.
Quoted 6 lines
Quoted 2 lines
At least the cover letter needs to explain why this path is not taken.
I thought we had a reference to that backend - but will add it for the next update.
Quoted 7 lines
Quoted 4 lines
From the cover letter there appears to be bpf pieces and non-bpf pieces, but I don't see any reason not to just land it all in BPF. Support exists and if its missing some smaller things add them and everyone gets them vs niche P4 backend.
Ok, i thought you said you read the cover letter. Reasons are well stated, primarily that we need to make sure all P4 programs work.
I don't think that is a very strong argument to use/build a p4c-tc architecture and implementation instead of p4c-ebpf. I can't think of any reason p4c-ebpf can't support all programs other than perhaps its missing a few items. From a design side though it should be capabable of any PSA, PNA, and many more architectures you come up with.
And I'm genuinely curious what is missing so a list would be nice. The missing block perhaps is a perfomant software TCAM, but I'm not fully convinced that software should even bother to try and duplicate a TCAM. If you need a performant TCAM buy hw with a TCAM emulating one is always going to be slower. Have Intel/AMD/ARM glue a TCAM to the core if its so useful.
To be clear p4c-tc is only targeting PNA programs not all P4 space.
Quoted 10 lines
Quoted 7 lines
Without hardware support for any of this its impossible to understand how 'tc' would work as a hardware offload interface for a p4 device so we need hardware support to evaluate. For example I'm not even sure how you would take a BPF parser into hardware on most network devices that aren't processor based.
P4 has nothing to do with parsers in hardware. Where did you get this requirement from?
P4 is/was primarily developed as a DSL to program hardware. We've never figured out how to do a native Linux P4 controller for hardware. There are a couple blockers for that in my opinion. First no one has ever opened up the hardware to an OSS solution. Two its never been entirely clear what the big win for enough people would be. So we get targetted offloads, timestamp, vxlan, tso, ktls, even heard quic offload yesterday. And its easy enough to just program the hardware directly from user space.
So yes I think P4 has a lot to do with hardware, its probably fair to say this p4c-tc thing isn't hardware. But, I think its very limiting and the value of any p4 implementation in kernel would be its ability to use hardware.
I'm not even convinced P4 is a good DSL for SW implementations. I don't think its obvious how hw P4 and sw datapaths integrate effectively. My opinion is p4c-tc is not moving us forward here.
Quoted 9 lines
Quoted 4 lines
P4 has a P4Runtime I think most folks would prefer a P4 UI vs typing in 'tc' commands so arguing for 'tc' UI is nice is not going to be very compelling. Best we can say is it works well enough and we use it.
The control plane interface is netlink. This part is not negotiable. You can write whatever you want on top of it(for example P4runtime using netlink as its southbound interface). We feel that tc - a well
Sure we need a low level interface for p4runtime to use and I agree we don't need all blocks done at once.
Quoted 3 lines
understood utility - is one we should make publicly available for the rest of the world to use. For example we have rust code that runs on top of netlink to do performance testing.
If updates/lookups from userspace is a performance vector you care about I can't see how netlink is more efficient than a mmapped bpf map. If you have data share it, but it seems highly unlikely.
The argument I'm trying to make is netlink vs bpf maps vs some other goo shouldn't matter to users because we should build them higher level tooling to interact with the p4 objects. Then it comes down to performance in my opinion. And if map updates matter I suspect netlink is relatively slow.
Quoted 24 lines
Quoted 24 lines
more commentary below.
Quoted 21 lines
The Programming Protocol-independent Packet Processors (P4) is an open source, domain-specific programming language for specifying data plane behavior.
The P4 ecosystem includes an extensive range of deployments, products, projects and services, etc[9][10][11][12].
__Whatis P4TC?__P4TC is a net-namespace aware implementation, meaning multiple P4 programs can run independently in different namespaces alongside their appropriate state. The implementation builds on top of many years of Linux TC experiences. On why P4 - see small treatise here:[4].
There have been many discussions and meetings since about 2015 in regards to P4 over TC[2] and we are finally proving the naysayers that we do get stuff done!
A lot more of the P4TC motivation is captured at:
https://github.com/p4tc-dev/docs/blob/main/why-p4tc.mdQuoted 7 lines
Quoted 4 lines
Quoted 1 line
**In this patch series we focus on s/w datapath only**.
I don't see the value in adding 16676 lines of code for s/w only datapath of something we already can do with p4c-ebpf backend.
Please please stop this entitlement politics (which i frankly think you guys have been getting away with for a few years now).
I'm allowed to disagree with your architecture and propose what I think is a betteer way to translate P4 into software.
Its common to argue against adding new code if it duplicates functionality we already support.
Quoted 6 lines
This code does not touch any core code - you guys constantly push code that touches core code and it is not unusual we have to pick up the pieces after but now you are going to call me out for the number of lines of code? Is it ok for you to write lines of code in the kernel but not me? Judge the technical work then we can have a meaningful discussion.
Quoted 9 lines
I think I'm judging the technical work here. Bullet points.
1. p4c-tc implementation looks like it should be slower than a in terms of pkts/sec than a bpf implementation. Meaning I suspect pipeline and objects laid out like this will lose to a BPF program with an parser and single lookup. The p4c-ebpf compiler should look to create optimized EBPF code not some emulated switch topology.
The parser is ebpf based. The other objects which require control plane interaction are not - those interact via netlink.
We published perf data a while back - presented at the P4 workshop back in April (was in the cover letter)
https://github.com/p4tc-dev/docs/blob/main/p4-conference-2023/2023P4WorkshopP4TC.pdf
But do note: the correct abstraction is the first priority. Optimization is something we can teach the compiler over time. But even with the minimalist code generation you can see that our approach always beats ebpf in LPM and ternary. The other ones I am pretty sure we can optimize over time.
Your view of "single lookup" is true for simple programs but if you have 10 tables trying to model a 5G function then it doesnt make sense (and i think the data we published was clear that you gain no advantage using ebpf - as a matter of fact there was no perf difference between XDP and tc in such cases).
Quoted 5 lines
2. p4c-tc control plan looks slower than a directly mmaped bpf map. Doing a simple update vs a netlink msg. The argument that BPF can't do CRUD (which we had offlist) seems incorrect to me. Correct me if I'm wrong with details about why.
So let me see....
you want me to replace netlink and all its features and rewrite it using the ebpf system calls? Congestion control, event handling, arbitrary message crafting, etc and the years of work that went into netlink? NO to the HELL.
I should note: that there was an interesting talk at netdevconf 0x17 where the speaker showed the challenges of dealing with ebpf on "day two" - slides or videos are not up yet, but link is:
https://netdevconf.info/0x17/sessions/talk/is-scaling-ebpf-easy-yet-a-small-step-to-one-server-but-giant-leap-to-distributed-network.html
The point the speaker was making is it's always easy to whip an ebpf program that can slice and dice packets and maybe even flush LEDs but the real work and challenge is in the control plane. I agree with the speaker based on my experiences. This discussion of replacing netlink with ebpf system calls is absolutely a non-starter. Let's just end the discussion and agree to disagree if you are going to keep insisting on that.
Quoted 5 lines
2. I don't see why ebpf can not support all P4 programs. Because the DSL compiler side doesn't support the nic architecture side to me indicates fixing the compiler is the direction not pushing on the kernel.
Wrestling with the verifier, different version of toolchains, etc. This is not just a problem we are facing, but about everyone out there that tries to do something serious with ebpf eventually hits these issues. Kfuncs really opened the door for us (i think it improved usability of ebpf by probably orders of magnitude). Without kfuncs i would not have even considered ebpf - and did i say i was fine with u32 and pedit approach we had.
Quoted 7 lines
3. Working in BPF framework will benefit more folks than a tc framework. I just don't see a large user base of P4 software running on Linux. It doesn't mean we can't have it in linux, but worth considering. We have lots of niche stuff in the kernel, but usually the niche thing doesn't have another more common way to run it.
To each their itch - that's what open source is about. This is our itch. You dont have to like it nor use it. There are a lot of things i dont like in the kernel and would never use. Saying you dont see a "large user base of P4 software on Linux" is handwaving at best. Under what metric do you reach such a conclusion? The fact that i can describe something in a _simple_ high level language like P4 and get low level ebpf for free is of great value. I dont need to go and look for an ebpf expert to hand code things for me.
Quoted 3 lines
4. The win for P4 is not sw implementation. Its about getting programmable hardware and this doesn't advance that goal in any meaningful way as far as I can see.
And all the s/w incarnations of P4 out there would disagree with you. The fact that P4 has use in h/w doesnt disqualify it from being useful in s/w.
Quoted 7 lines
5. By pushing the P4 model so low in the stack of tooling you lose ability for compiler to do interesting things. Combining match action tables, converting them to switch statements or jumps, finding inverse operations and removing them. I still think there is lots of unexplored work on compiling P4 that has not been done.
And that can be done over time unless you are saying it is impossible. ebpf != P4, they are two different levels of expression. eBPF is just a tool to get us there and nothing more.
cheers,
jamal
Quoted 312 lines
Quoted 7 lines
TBH, I am trying very hard to see if i should respond to any more comments from you. I was very happy with our original scriptable approach and you came out and banged on the table that you want ebpf. We spent 10 months of multiple people working on this code to make it ebpf friendly and now you want more (actually i am not sure what the hell you want).
I've made the above arguments on early versions of the code, and when we talked, and even offered it in p4 working group. It shouldn't be surprising I've not changed my opinion.
Its a argument against duplicating existing functionality with something that is slower and doesn't give us HW P4 support. The bullets above.
Quoted 11 lines
Quoted 9 lines
Or one of the other
backends already there. Namely take P4 programs and run them on CPUs in Linux.Also I suspect a pipelined datapath is going to be slower than a O(1) lookup datapath so I'm guessing its slower than most datapaths we have already.
What do we gain here over existing p4c-ebpf?
see above.
We are talking past eachother becaus here I argue it looks like a slow datapath and you say 'see above' but what above was I meant to see? That it doesn't have PNA support? Compared to PSA doing a PNA support should be straightforward.
I disagree that software should try to emulate hardware to closely. They are fundamentally different platforms. One has CAMs, TCAMs, and LPMs and obscure instruction sets to make all this work. The other is working on a general purpose CPU. I think slamming a hardware architecture into software with emulated TCAMs and what not, will be a losing performance proposition. Experience shows you can either go SIMD direction and parrallize everything with these instructions or you reduce the datapath to a single (or minimal set) of lookups. Find a counter-example.
Quoted 20 lines
Quoted 20 lines
Quoted 4 lines
__P4TCWorkflow__Quoted 8 lines
These patches enable kernel and user space code change _independence_ for any new P4 program that describes a new datapath. The workflow is as follows:
1) A developer writes a P4 program, "myprog"
2) Compiles it using the P4C compiler[8]. The compiler generates 3 outputs:
a) shell script(s) which form template definitions for the different P4 objects "myprog" utilizes (tables, externs, actions etc).This is odd to me. I think packing around shell scrips as a program is not very usable. Why not just an object file.
Quoted 3 lines
b) the parser and the rest of the datapath are generated
in eBPF and need to be compiled into binaries.
c) A json introspection file used for the control plane (by iproute2/tc).Quoted 6 lines
Quoted 3 lines
Why split up the eBPF and control plane like this? eBPF has a control plane just use the existing one?
The cover letter clearly states that we are using netlink as the control api. Does eBPF support netlink?
But why? The statement is there but no rational is given. People are used to it was maybe stated, but my argument is users of P4 shouldn't be crafting netlink messages they need tooling if its netlink or BPF or some new thing. So pick the most efficient tool for the job. Why is netlink the most efficient option here.
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
3) The developer (or operator) executes the shell script(s) to manifest the functional "myprog" into the kernel.
4) The developer (or operator) instantiates "myprog" via the tc P4 filter to ingress/egress (depending on P4 arch) of one or more netdevs/ports.
Example1: parser is an action:
"tc filter add block 22 ingress protocol all prio 10 p4 pname myprog \
action bpf obj $PARSER.o section parser/tc-ingress \
action bpf obj $PROGNAME.o section p4prog/tc"Example2: parser explicitly bound and rest of dpath as an action:
"tc filter add block 22 ingress protocol all prio 10 p4 pname myprog \
prog tc obj $PARSER.o section parser/tc-ingress \
action bpf obj $PROGNAME.o section p4prog/tc"Example3: parser is at XDP, rest of dpath as an action:
"tc filter add block 22 ingress protocol all prio 10 p4 pname myprog \
prog type xdp obj $PARSER.o section parser/xdp-ingress \
pinned_link/path/to/xdp-prog-link \
action bpf obj $PROGNAME.o section p4prog/tc"Example4: parser+prog at XDP:
"tc filter add block 22 ingress protocol all prio 10 p4 pname myprog \
prog type xdp obj $PROGNAME.o section p4prog/xdp \
pinned_link/path/to/xdp-prog-link"see individual patches for more examples tc vs xdp etc. Also see section on "challenges" (on this cover letter).
Once "myprog" P4 program is instantiated one can start updating table entries that are associated with myprog's table named "mytable". Example:
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1As a UI above is entirely cryptic to most folks I bet.
But ebpf is not?
We don't need everything out the gate but my point is that the UI should be abstracted away from the P4 programmer and operator at this level. My observation that 'tc' is cryptic was just an off-hand comment I don't think its relevant to the overall argument for or against, what we should understand is how to map p4runtime or at least a operator friendly UI onto the semantics.
Quoted 7 lines
Quoted 4 lines
myprog table is a BPF map? If so then I don't see any need for this just interact with it like a BPF map. I suspect its some other object, but I don't see any ratoinal for that.
All the P4 objects sit in the TC domain. The datapath program is ebpf. Control is via netlink.
I'm missing something fundamental. What do we gain from this TC domain. There are some TC maps for LPM and TCAMs we have LPM already in BPF and TCAM you have could easily be added if you want to. Then entire program runs to completion. Surely this is more performant. Throw in XDP and the redirect never leaves the NIC, no skb, etc.
From the architecture side I don't think we need kernel objects for pipelines and some P4 notion of match action tables those can all be mapped into the BPF program. The packet never leaves XDP. Performance is good on datapath and performance is good on map update side. It looks like noise to me teaching the kernel about P4 objects and types. More importantly you are constraining the optimizations the compiler can make. Perhaps the compiler wants no map at all and implements it as a switch stmt for example. Maybe the compiler can find inverse operations and fastpaths to short circuit. By forcing the model so low in the stack you remove this ability.
Quoted 15 lines
Quoted 11 lines
Quoted 10 lines
A packet arriving on ingress of any of the ports on block 22 will first be exercised via the (eBPF) parser to find the headers pointing to the ip destination address.
The remainder eBPF datapath uses the result dstAddr as a key to do a lookup in myprog's mytable which returns the action params which are then used to execute the action in the eBPF datapath (eventually sending out packets to eno1). On a table miss, mytable's default miss action is executed.Quoted 3 lines
This chunk looks like standard BPF program. Parse pkt, lookup an action, do the action.
Quoted 5 lines
Yes, the ebpf datapath does the parsing, and then interacts with kfuncs to the tc world before it (the ebpf datapath) executes the action.
Note: ebpf did not invent any of that (parse, lookup, action). It has existed in tc for 20 years before ebpf existed.Its not about who invented what. All this goes way back.
My point is the 'tc' world here looks unnecessary. It can be managed from outside the kernel entirely.
Quoted 36 lines
Quoted 36 lines
Quoted 9 lines
__DescriptionofPatches__P4TC is designed to have no impact on the core code for other users of TC. IOW, you can compile it out but even if it compiled in and you dont use it there should be no impact on your performance.
We do make core kernel changes. Patch #1 adds infrastructure for "dynamic" actions that can be created on "the fly" based on the P4 program requirement.
the common pattern in bpf for this is to use a tail call map and populate it at runtime and/or just compile your program with the actions. Here the actions came from the p4 back up at step 1 so no reason we can't just compile them with p4c.
Quoted 6 lines
This patch makes a small incision into
act_apiwhich shouldn't affect the performance (or functionality) of the existing actions. Patches 2-4,6-7 are minimalist enablers for P4TC and have no effect the classical tc action. Patch 5 adds infrastructure support for preallocation of dynamic actions.The core P4TC code implements several P4 objects.
[...]
Quoted 11 lines
__RestatingOurRequirements__The initial release made in January/2023 had a "scriptable" datapath (think u32 classifier and pedit action). In this section we review the scriptable version against the current implementation we are pushing upstream which uses eBPF.
Our intention is to target the TC crowd.
Essentially developers and ops people deploying TC based infra.
More importantly the original intent for P4TC was to enable_opsfolks_more than devs (given code is being generated and doesn't need humans to write it).Quoted 6 lines
Quoted 2 lines
I don't follow. humans wrote the p4.
But not the ebpf code, that is compiler generated. P4 is a higher level Domain specific language and ebpf is just one backend (others s/w variants include DPDK, Rust, C, etc)
Yes. I still don't follow. Of course ebpf is just one backend.
Quoted 19 lines
Quoted 19 lines
I think the intent should be to enable P4 to run on Linux. Ideally efficiently. If the
_opsfolks are writing P4 great as long as we give them an efficient way to run their p4 I don't think they care about what executes it.Quoted 9 lines
With TC, we get whole "familiar" package of match-action pipeline abstraction++, meaning from the control plane all the way to the tooling infra, i.e iproute2/tc cli, netlink
infra(request/resp, event subscribe/multicast-publish, congestion control etc), s/w and h/w symbiosis, the autonomous kernel control, etc.
The main advantage is that we have a singular vendor-neutral interface via the kernel using well understood mechanisms based on deployment experience (and at least this part doesnt need retraining).A seemless p4 experience would be great. That looks like a tooling problem at the p4c-backend and p4c-frontend problem. Rather than a bunch of 'tc' glue I would aim for,
Quoted 8 lines
Quoted 6 lines
$ p4c-* myprog.p4 $ p4cRun ./myprogAnd maybe some options like,
$ p4cRun -i eth0 ./myprogArmchair lawyering and classical ML bikesheding
It was just an example of what I think the end goal should be.
Quoted 26 lines
Quoted 7 lines
Then use the p4runtime to interface with the system. If you don't like the runtime then it should be brought up in that working group.
Quoted 3 lines
1) Supporting expressibility of the universe set of P4 progs
Quoted 8 lines
Quoted 6 lines
It is a must to support 100% of all possible P4 programs. In the past the eBPF verifier had to be worked around and even then there are cases where we couldnt avoid path explosion when branching is involved. Kfunc-ing solves these issues for us. Note, there are still challenges running all potential P4 programs at the XDP level - the solution to that is to have the compiler generate XDP based code only if it possible to map it to that layer.
Examples and we can fix it.
Right. Let me wait for you to fix something 5 years from now. I would never have used eBPF at all but the kfunc is what changed my mind.
Quoted 7 lines
Quoted 6 lines
2) Support for P4 HW and SW equivalence.
This feature continues to work even in the presence of eBPF as the s/w datapath. There are cases of square-hole-round-peg scenarios but those are implementation issues we can live with.
Quoted 6 lines
Quoted 2 lines
But no hw support.
This patcheset has nothing to do with offload (you read the cover letter?). All above is saying is that by virtue of using TC we have a path to a proven offload approach.
I'm arguing P4 is in a big part about programmable HW. If we merge a P4 into the kernel all the way down to the p4 types and don't consider how it works with hardware that is a non starter for me.
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
3) Operational usability
By maintaining the TC control plane (even in presence of eBPF datapath) runtime aspects remain unchanged. So for our target audience of folks who have deployed tc including offloads - the comfort zone is unchanged. There is also the comfort zone of continuing to use the true-and-tried netlink interfacing.
Quoted 4 lines
Quoted 2 lines
The P4 control plane should be P4Runtime.
And be my guest and write it on top of netlink.
But I would prefer it was a BPF map and gave my reasons above.
Quoted 3 lines
cheers,
jamal
Jiri Pirko
maintainerQuoted 6 lines · Fri, Nov 17, 2023 at 09:46:11PM CET, [email protected] wrote:
Quoted 5 lines · John Fastabend
Quoted 3 lines · Jamal Hadi Salim
Quoted 2 lines · John Fastabend
Jamal Hadi Salim wrote:
[...]
Quoted 11 lines
Quoted 10 lines
I think I'm judging the technical work here. Bullet points.
1. p4c-tc implementation looks like it should be slower than a in terms of pkts/sec than a bpf implementation. Meaning I suspect pipeline and objects laid out like this will lose to a BPF program with an parser and single lookup. The p4c-ebpf compiler should look to create optimized EBPF code not some emulated switch topology.
Quoted 9 lines
The parser is ebpf based. The other objects which require control plane interaction are not - those interact via netlink.
We published perf data a while back - presented at the P4 workshop back in April (was in the cover letter)
https://github.com/p4tc-dev/docs/blob/main/p4-conference-2023/2023P4WorkshopP4TC.pdf
But do note: the correct abstraction is the first priority. Optimization is something we can teach the compiler over time. But even with the minimalist code generation you can see that our approach always beats ebpf in LPM and ternary. The other ones I am pretty sure
Any idea why? Perhaps the existing eBPF maps are not that suitable for this kinds of lookups? I mean in theory, eBPF should be always faster.
Quoted 13 lines
we can optimize over time.
Your view of "single lookup" is true for simple programs but if you have 10 tables trying to model a 5G function then it doesnt make sense (and i think the data we published was clear that you gain no advantage using ebpf - as a matter of fact there was no perf difference between XDP and tc in such cases).Quoted 5 lines
2. p4c-tc control plan looks slower than a directly mmaped bpf map. Doing a simple update vs a netlink msg. The argument that BPF can't do CRUD (which we had offlist) seems incorrect to me. Correct me if I'm wrong with details about why.
Quoted 5 lines
So let me see....
you want me to replace netlink and all its features and rewrite it using the ebpf system calls? Congestion control, event handling, arbitrary message crafting, etc and the years of work that went into netlink? NO to the HELL.
Wait, I don't think John suggests anything like that. He just suggests to have the tables as eBPF maps. Honestly, I don't understand the fixation on netlink. Its socket messaging, memcpies, processing overhead, etc can't keep up with mmaped memory access at scale. Measure that and I bet you'll get drastically different results.
I mean, netlink is good for a lot of things, but does not mean it is an universal answer to userspace<->kernel data passing.
Quoted 11 lines
I should note: that there was an interesting talk at netdevconf
0x17where the speaker showed the challenges of dealing with ebpf on "day two" - slides or videos are not up yet, but link is:
https://netdevconf.info/0x17/sessions/talk/is-scaling-ebpf-easy-yet-a-small-step-to-one-server-but-giant-leap-to-distributed-network.html
The point the speaker was making is it's always easy to whip an ebpf program that can slice and dice packets and maybe even flush LEDs but the real work and challenge is in the control plane. I agree with the speaker based on my experiences. This discussion of replacing netlink with ebpf system calls is absolutely a non-starter. Let's just end the discussion and agree to disagree if you are going to keep insisting on that.
[...]
Jamal Hadi Salim
maintainerQuoted 33 lines · Jiri Pirko
Quoted 6 lines · Fri, Nov 17, 2023 at 09:46:11PM CET, [email protected] wrote:
Quoted 5 lines · John Fastabend
Quoted 3 lines · Jamal Hadi Salim
Quoted 2 lines · John Fastabend
Jamal Hadi Salim wrote:
[...]
Quoted 11 lines
Quoted 10 lines
I think I'm judging the technical work here. Bullet points.
1. p4c-tc implementation looks like it should be slower than a in terms of pkts/sec than a bpf implementation. Meaning I suspect pipeline and objects laid out like this will lose to a BPF program with an parser and single lookup. The p4c-ebpf compiler should look to create optimized EBPF code not some emulated switch topology.
Quoted 9 lines
The parser is ebpf based. The other objects which require control plane interaction are not - those interact via netlink.
We published perf data a while back - presented at the P4 workshop back in April (was in the cover letter)
https://github.com/p4tc-dev/docs/blob/main/p4-conference-2023/2023P4WorkshopP4TC.pdf
But do note: the correct abstraction is the first priority. Optimization is something we can teach the compiler over time. But even with the minimalist code generation you can see that our approach always beats ebpf in LPM and ternary. The other ones I am pretty sure
Quoted 2 lines
Any idea why? Perhaps the existing eBPF maps are not that suitable for this kinds of lookups? I mean in theory, eBPF should be always faster.
We didnt look closely; however, that is not the point - the point is the perf difference if there is one, is not big with the big win being proper P4 abstraction. For LPM for sure our algorithmic approach is better. For ternary the compute intensity in looping is better done in C. And for exact i believe that ebpf uses better hashing.
Again, that is not the point we were trying to validate in those experiments..
On your point of "maps are not that suitable" P4 tables tend to have very specific attributes (examples associated meters, counters, default hit and miss actions, etc).
Quoted 13 lines
Quoted 13 lines
we can optimize over time.
Your view of "single lookup" is true for simple programs but if you have 10 tables trying to model a 5G function then it doesnt make sense (and i think the data we published was clear that you gain no advantage using ebpf - as a matter of fact there was no perf difference between XDP and tc in such cases).Quoted 5 lines
2. p4c-tc control plan looks slower than a directly mmaped bpf map. Doing a simple update vs a netlink msg. The argument that BPF can't do CRUD (which we had offlist) seems incorrect to me. Correct me if I'm wrong with details about why.
Quoted 8 lines
Quoted 5 lines
So let me see....
you want me to replace netlink and all its features and rewrite it using the ebpf system calls? Congestion control, event handling, arbitrary message crafting, etc and the years of work that went into netlink? NO to the HELL.Wait, I don't think John suggests anything like that. He just suggests to have the tables as eBPF maps.
What's the difference? Unless maps can do netlink.
Quoted 7 lines
Honestly, I don't understand the
fixation on netlink. Its socket messaging, memcpies, processing overhead, etc can't keep up with mmaped memory access at scale. Measure that and I bet you'll get drastically different results.I mean, netlink is good for a lot of things, but does not mean it is an universal answer to userspace<->kernel data passing.
Here's a small sample of our requirements that are satisfied by netlink for P4 object hierarchy[1]:
1. Msg construction/parsing
2. Multi-user request/response messaging
3. Multi-user event subscribe/publish messaging
I dont think i need to provide an explanation on the differences here visavis what ebpf system calls provide vs what netlink provides and how netlink is a clear fit. If it is not clear i can give more breakdown. And of course there's more but above is a good sample.
The part that is taken for granted is the control plane code and interaction which is an extremely important detail. P4 Abstraction requires hierarchies with different compiler generated encoded path ids etc. This ID mapping gets exacerbated by having multitudes of P4 programs which have different requirements. Netlink is a natural fit for this P4 abstraction. Not to mention the netlink/tc path (and in particular the ID mapping) provides a conduit for offload when that is needed.
eBPF is just a tool - and the objects are intended to be generic - and i dont see how any of this could be achieved without retooling to make it more specific to P4.
cheers,
jamal
Quoted 15 lines
Quoted 12 lines
I should note: that there was an interesting talk at netdevconf
0x17where the speaker showed the challenges of dealing with ebpf on "day two" - slides or videos are not up yet, but link is:
https://netdevconf.info/0x17/sessions/talk/is-scaling-ebpf-easy-yet-a-small-step-to-one-server-but-giant-leap-to-distributed-network.html
The point the speaker was making is it's always easy to whip an ebpf program that can slice and dice packets and maybe even flush LEDs but the real work and challenge is in the control plane. I agree with the speaker based on my experiences. This discussion of replacing netlink with ebpf system calls is absolutely a non-starter. Let's just end the discussion and agree to disagree if you are going to keep insisting on that.[...]
Jiri Pirko
maintainerQuoted 77 lines · Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:
Quoted 33 lines · Jiri Pirko
Quoted 6 lines · Fri, Nov 17, 2023 at 09:46:11PM CET, [email protected] wrote:
Quoted 5 lines · John Fastabend
Quoted 3 lines · Jamal Hadi Salim
Quoted 2 lines · John Fastabend
Jamal Hadi Salim wrote:
[...]
Quoted 11 lines
Quoted 10 lines
I think I'm judging the technical work here. Bullet points.
1. p4c-tc implementation looks like it should be slower than a in terms of pkts/sec than a bpf implementation. Meaning I suspect pipeline and objects laid out like this will lose to a BPF program with an parser and single lookup. The p4c-ebpf compiler should look to create optimized EBPF code not some emulated switch topology.
Quoted 9 lines
The parser is ebpf based. The other objects which require control plane interaction are not - those interact via netlink.
We published perf data a while back - presented at the P4 workshop back in April (was in the cover letter)
https://github.com/p4tc-dev/docs/blob/main/p4-conference-2023/2023P4WorkshopP4TC.pdf
But do note: the correct abstraction is the first priority. Optimization is something we can teach the compiler over time. But even with the minimalist code generation you can see that our approach always beats ebpf in LPM and ternary. The other ones I am pretty sureQuoted 2 lines
Any idea why? Perhaps the existing eBPF maps are not that suitable for this kinds of lookups? I mean in theory, eBPF should be always faster.
We didnt look closely; however, that is not the point - the point is the perf difference if there is one, is not big with the big win being proper P4 abstraction. For LPM for sure our algorithmic approach is better. For ternary the compute intensity in looping is better done in C. And for exact i believe that ebpf uses better hashing.
Again, that is not the point we were trying to validate in those experiments..On your point of "maps are not that suitable" P4 tables tend to have very specific attributes (examples associated meters, counters, default hit and miss actions, etc).
Quoted 13 lines
Quoted 13 lines
we can optimize over time.
Your view of "single lookup" is true for simple programs but if you have 10 tables trying to model a 5G function then it doesnt make sense (and i think the data we published was clear that you gain no advantage using ebpf - as a matter of fact there was no perf difference between XDP and tc in such cases).Quoted 5 lines
2. p4c-tc control plan looks slower than a directly mmaped bpf map. Doing a simple update vs a netlink msg. The argument that BPF can't do CRUD (which we had offlist) seems incorrect to me. Correct me if I'm wrong with details about why.
Quoted 8 lines
Quoted 5 lines
So let me see....
you want me to replace netlink and all its features and rewrite it using the ebpf system calls? Congestion control, event handling, arbitrary message crafting, etc and the years of work that went into netlink? NO to the HELL.Wait, I don't think John suggests anything like that. He just suggests to have the tables as eBPF maps.
What's the difference? Unless maps can do netlink.
Quoted 5 lines
Honestly, I don't understand the
fixation on netlink. Its socket messaging, memcpies, processing overhead, etc can't keep up with mmaped memory access at scale. Measure that and I bet you'll get drastically different results.
Quoted 7 lines
Quoted 2 lines
I mean, netlink is good for a lot of things, but does not mean it is an universal answer to userspace<->kernel data passing.
Here's a small sample of our requirements that are satisfied by netlink for P4 object hierarchy[1]:
1. Msg construction/parsing
2. Multi-user request/response messaging
What is actually a usecase for having multiple users program p4 pipeline in parallel?
Quoted 1 line
3. Multi-user event subscribe/publish messaging
Same here. What is the usecase for multiple users receiving p4 events?
Quoted 4 lines
I dont think i need to provide an explanation on the differences here visavis what ebpf system calls provide vs what netlink provides and how netlink is a clear fit. If it is not clear i can give more
It is not :/
Quoted 6 lines
breakdown. And of course there's more but above is a good sample.
The part that is taken for granted is the control plane code and interaction which is an extremely important detail. P4 Abstraction requires hierarchies with different compiler generated encoded path ids etc. This ID mapping gets exacerbated by having multitudes of P4
Why the actual eBFP mapping does not serve the same purpose as ID? ID:mapping
1 :1
?
Quoted 28 lines
programs which have different requirements. Netlink is a natural fit for this P4 abstraction. Not to mention the netlink/tc path (and in particular the ID mapping) provides a conduit for offload when that is needed.
eBPF is just a tool - and the objects are intended to be generic - and i dont see how any of this could be achieved without retooling to make it more specific to P4.cheers,
jamalQuoted 15 lines
Quoted 12 lines
I should note: that there was an interesting talk at netdevconf
0x17where the speaker showed the challenges of dealing with ebpf on "day two" - slides or videos are not up yet, but link is:
https://netdevconf.info/0x17/sessions/talk/is-scaling-ebpf-easy-yet-a-small-step-to-one-server-but-giant-leap-to-distributed-network.html
The point the speaker was making is it's always easy to whip an ebpf program that can slice and dice packets and maybe even flush LEDs but the real work and challenge is in the control plane. I agree with the speaker based on my experiences. This discussion of replacing netlink with ebpf system calls is absolutely a non-starter. Let's just end the discussion and agree to disagree if you are going to keep insisting on that.[...]
Jamal Hadi Salim
maintainerQuoted 82 lines · Jiri Pirko
Quoted 80 lines · Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:
Quoted 33 lines · Jiri Pirko
Quoted 6 lines · Fri, Nov 17, 2023 at 09:46:11PM CET, [email protected] wrote:
Quoted 5 lines · John Fastabend
Quoted 3 lines · Jamal Hadi Salim
Quoted 2 lines · John Fastabend
Jamal Hadi Salim wrote:
[...]
Quoted 11 lines
Quoted 10 lines
I think I'm judging the technical work here. Bullet points.
1. p4c-tc implementation looks like it should be slower than a in terms of pkts/sec than a bpf implementation. Meaning I suspect pipeline and objects laid out like this will lose to a BPF program with an parser and single lookup. The p4c-ebpf compiler should look to create optimized EBPF code not some emulated switch topology.
Quoted 9 lines
The parser is ebpf based. The other objects which require control plane interaction are not - those interact via netlink.
We published perf data a while back - presented at the P4 workshop back in April (was in the cover letter)
https://github.com/p4tc-dev/docs/blob/main/p4-conference-2023/2023P4WorkshopP4TC.pdf
But do note: the correct abstraction is the first priority. Optimization is something we can teach the compiler over time. But even with the minimalist code generation you can see that our approach always beats ebpf in LPM and ternary. The other ones I am pretty sureQuoted 2 lines
Any idea why? Perhaps the existing eBPF maps are not that suitable for this kinds of lookups? I mean in theory, eBPF should be always faster.
We didnt look closely; however, that is not the point - the point is the perf difference if there is one, is not big with the big win being proper P4 abstraction. For LPM for sure our algorithmic approach is better. For ternary the compute intensity in looping is better done in C. And for exact i believe that ebpf uses better hashing.
Again, that is not the point we were trying to validate in those experiments..On your point of "maps are not that suitable" P4 tables tend to have very specific attributes (examples associated meters, counters, default hit and miss actions, etc).
Quoted 13 lines
Quoted 13 lines
we can optimize over time.
Your view of "single lookup" is true for simple programs but if you have 10 tables trying to model a 5G function then it doesnt make sense (and i think the data we published was clear that you gain no advantage using ebpf - as a matter of fact there was no perf difference between XDP and tc in such cases).Quoted 5 lines
2. p4c-tc control plan looks slower than a directly mmaped bpf map. Doing a simple update vs a netlink msg. The argument that BPF can't do CRUD (which we had offlist) seems incorrect to me. Correct me if I'm wrong with details about why.
Quoted 8 lines
Quoted 5 lines
So let me see....
you want me to replace netlink and all its features and rewrite it using the ebpf system calls? Congestion control, event handling, arbitrary message crafting, etc and the years of work that went into netlink? NO to the HELL.Wait, I don't think John suggests anything like that. He just suggests to have the tables as eBPF maps.
What's the difference? Unless maps can do netlink.
Quoted 7 lines
Honestly, I don't understand the
fixation on netlink. Its socket messaging, memcpies, processing overhead, etc can't keep up with mmaped memory access at scale. Measure that and I bet you'll get drastically different results.I mean, netlink is good for a lot of things, but does not mean it is an universal answer to userspace<->kernel data passing.
Quoted 7 lines
Quoted 4 lines
Here's a small sample of our requirements that are satisfied by netlink for P4 object hierarchy[1]:
1. Msg construction/parsing
2. Multi-user request/response messagingWhat is actually a usecase for having multiple users program p4 pipeline in parallel?
First of all - this is Linux, multiple users is a way of life, you shouldnt have to ask that question unless you are trying to be socratic. Meaning multiple control plane apps can be allowed to program different parts and even different tables - think multi-tier pipeline.
Quoted 3 lines
Quoted 1 line
3. Multi-user event subscribe/publish messaging
Same here. What is the usecase for multiple users receiving p4 events?
Same thing.
Note: Events are really not part of P4 but we added them for flexibility - and as you well know they are useful.
Quoted 7 lines
Quoted 5 lines
I dont think i need to provide an explanation on the differences here visavis what ebpf system calls provide vs what netlink provides and how netlink is a clear fit. If it is not clear i can give more
It is not :/
I thought it was obvious for someone like you, but fine - here goes for those 3:
1. Msg construction/parsing: A lot of infra for sending attributes back and forth is already built into netlink. I would have to create mine from scratch for ebpf. This will include not just the construction/parsing but all the detailed attribute content policy validations(even in the presence of hierarchies) that comes with it. And not to forget the state transform between kernel and user space.
2. Multi-user request/response messaging
If you can write all the code for #1 above then this should work fine for ebpf
3. Event publish subscribe
You would have to create mechanisms for ebpf which either are non trivial or non complete: Example 1: you can put surgeries in the ebpf code to look at map manipulations and then interface it to some event management scheme which checks for subscribed users. Example 2: It may also be feasible to create your own map for subscription vs something like perf ring for event publication(something i have done in the past), but that is also limited in many ways.
Quoted 10 lines
Quoted 7 lines
breakdown. And of course there's more but above is a good sample.
The part that is taken for granted is the control plane code and interaction which is an extremely important detail. P4 Abstraction requires hierarchies with different compiler generated encoded path ids etc. This ID mapping gets exacerbated by having multitudes of P4
Why the actual eBFP mapping does not serve the same purpose as ID? ID:mapping 1 :1
An identification of an object requires hierarchical IDs: A pipeline/program ID, A table id, a table entry Identification, an action identification and for each individual action content parameter, an ID etc. These same IDs would be what hardware would recognize as well (in case of offload). Given the dynamic nature of these IDs it is essentially up to the compiler to define them. These hierarchies are much easier to validate in netlink.
We dont want to be constrained to a generic infra like eBPF for these objects. Again eBPF is a means to an end (and not the goal here!).
cheers,
jamal
Quoted 30 lines
Quoted 30 lines
programs which have different requirements. Netlink is a natural fit for this P4 abstraction. Not to mention the netlink/tc path (and in particular the ID mapping) provides a conduit for offload when that is needed.
eBPF is just a tool - and the objects are intended to be generic - and i dont see how any of this could be achieved without retooling to make it more specific to P4.cheers,
jamalQuoted 15 lines
Quoted 12 lines
I should note: that there was an interesting talk at netdevconf
0x17where the speaker showed the challenges of dealing with ebpf on "day two" - slides or videos are not up yet, but link is:
https://netdevconf.info/0x17/sessions/talk/is-scaling-ebpf-easy-yet-a-small-step-to-one-server-but-giant-leap-to-distributed-network.html
The point the speaker was making is it's always easy to whip an ebpf program that can slice and dice packets and maybe even flush LEDs but the real work and challenge is in the control plane. I agree with the speaker based on my experiences. This discussion of replacing netlink with ebpf system calls is absolutely a non-starter. Let's just end the discussion and agree to disagree if you are going to keep insisting on that.[...]
Quoted 40 lines · Jamal Hadi Salim
Quoted 39 lines · Jiri Pirko
Quoted 37 lines · Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:
Quoted 35 lines · Jiri Pirko
Quoted 6 lines · Fri, Nov 17, 2023 at 09:46:11PM CET, [email protected] wrote:
Quoted 5 lines · John Fastabend
Quoted 3 lines · Jamal Hadi Salim
Quoted 2 lines · John Fastabend
Jamal Hadi Salim wrote:
[...]
Quoted 11 lines
Quoted 10 lines
I think I'm judging the technical work here. Bullet points.
1. p4c-tc implementation looks like it should be slower than a in terms of pkts/sec than a bpf implementation. Meaning I suspect pipeline and objects laid out like this will lose to a BPF program with an parser and single lookup. The p4c-ebpf compiler should look to create optimized EBPF code not some emulated switch topology.
Quoted 9 lines
The parser is ebpf based. The other objects which require control plane interaction are not - those interact via netlink.
We published perf data a while back - presented at the P4 workshop back in April (was in the cover letter)
https://github.com/p4tc-dev/docs/blob/main/p4-conference-2023/2023P4WorkshopP4TC.pdf
But do note: the correct abstraction is the first priority. Optimization is something we can teach the compiler over time. But even with the minimalist code generation you can see that our approach always beats ebpf in LPM and ternary. The other ones I am pretty sureAny idea why? Perhaps the existing eBPF maps are not that suitable for this kinds of lookups? I mean in theory, eBPF should be always faster.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
We didnt look closely; however, that is not the point - the point is the perf difference if there is one, is not big with the big win being proper P4 abstraction. For LPM for sure our algorithmic approach is better. For ternary the compute intensity in looping is better done in C. And for exact i believe that ebpf uses better hashing.
Again, that is not the point we were trying to validate in those experiments..
If you compared your implementation to the bpf lpm_trie its a bit misleading. The data structure is a rhashtable vs a Trie doing LPM.
Also I can't see how __p4tc_table_entry_lookup() is going to scale? That looks like a bucket per key? If so that wont scale well with 1000's of entries and lots of duplicate masks. I did a quick scan of code, but would be nice to detail the algorithm in the commit msg so we can disect it.
This doesn't look what we would want though for an LPM unless I've dropped this out of context.
+static struct p4tc_table_entry *
+__p4tc_entry_lookup(struct p4tc_table *table, struct p4tc_table_entry_key *key)
+ __must_hold(RCU)
+{
+ struct p4tc_table_entry *entry = NULL; + struct rhlist_head *tmp, *bucket_list; + struct p4tc_table_entry *entry_curr; + u32 smallest_prio = U32_MAX;
+
+ bucket_list =
+ rhltable_lookup(&table->tbl_entries, key, entry_hlt_params);
+ if (!bucket_list)
+ return NULL;
+
+ rhl_for_each_entry_rcu(entry_curr, tmp, bucket_list, ht_node) {
+ struct p4tc_table_entry_value *value =
+ p4tc_table_entry_value(entry_curr);
+ if (value->prio <= smallest_prio) {
+ smallest_prio = value->prio;
+ entry = entry_curr;
+ }
+ }
+
+ return entry;
+}
Also I don't know what 'better done in C' matters the TCAM data structure can be written in C and used as a BPF map. At least that is how we would normally approach it from BPF side.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
On your point of "maps are not that suitable" P4 tables tend to have very specific attributes (examples associated meters, counters, default hit and miss actions, etc).
The typical way we handle this from BPF is to either use the 0 entry for stats, annotations, etc. or create a blob of memory (another map, variables, global struct, ...) and stash the info there. If we care about performance we make those per cpu and deal with it in user land.
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
we can optimize over time.
Your view of "single lookup" is true for simple programs but if you have 10 tables trying to model a 5G function then it doesnt make sense (and i think the data we published was clear that you gain no advantage using ebpf - as a matter of fact there was no perf difference between XDP and tc in such cases).Quoted 5 lines
2. p4c-tc control plan looks slower than a directly mmaped bpf map. Doing a simple update vs a netlink msg. The argument that BPF can't do CRUD (which we had offlist) seems incorrect to me. Correct me if I'm wrong with details about why.
So let me see....
you want me to replace netlink and all its features and rewrite it using the ebpf system calls? Congestion control, event handling, arbitrary message crafting, etc and the years of work that went into netlink? NO to the HELL.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Wait, I don't think John suggests anything like that. He just suggests to have the tables as eBPF maps.
What's the difference? Unless maps can do netlink.
I'm going to argue map update time matters and we should use the fastest updates possible. If it complicates user space side some I would prefer that to slow updates. I don't think you can get much faster than a mmaped block of memory. Or even syscall updates are probably faster than netlink msgs.
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 7 lines
Honestly, I don't understand the
fixation on netlink. Its socket messaging, memcpies, processing overhead, etc can't keep up with mmaped memory access at scale. Measure that and I bet you'll get drastically different results.I mean, netlink is good for a lot of things, but does not mean it is an universal answer to userspace<->kernel data passing.
Here's a small sample of our requirements that are satisfied by netlink for P4 object hierarchy[1]:
1. Msg construction/parsing
2. Multi-user request/response messaging
Quoted 8 lines
Quoted 2 lines
What is actually a usecase for having multiple users program p4 pipeline in parallel?
First of all - this is Linux, multiple users is a way of life, you shouldnt have to ask that question unless you are trying to be socratic. Meaning multiple control plane apps can be allowed to program different parts and even different tables - think multi-tier pipeline.
Linux is always been opinionated and rejects code all the time because its not the "right" way. I've been on the reject your stuff side before.
Partitioning ownershiip of the pipeline is different than multiple users of the same elements. From BPF side (to show its doable) is done by pinning maps to files and giving that file to different programs. The DDOS thing can own the DDOS map and the router can own its router tables. BPF handles this using the file systems mostly.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
3. Multi-user event subscribe/publish messaging
Same here. What is the usecase for multiple users receiving p4 events?
Same thing.
Note: Events are really not part of P4 but we added them for flexibility - and as you well know they are useful.
Per above I wouldn't sacrafice update perf for this. Also its doable from userspace if you need to. Other thing I've come to dislike a bit is teaching the kernel a specific DSL. P4 is my favorte, but still going so far as to encode a specific P4 spec into the kernel seems unnecessary. Also now will we have to have kernel X supports P4.16 and kernel X+N supports P4.18 it seems like a pain.
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
I dont think i need to provide an explanation on the differences here visavis what ebpf system calls provide vs what netlink provides and how netlink is a clear fit. If it is not clear i can give more
It is not :/
Quoted 8 lines
I thought it was obvious for someone like you, but fine - here goes for those 3:
1. Msg construction/parsing: A lot of infra for sending attributes back and forth is already built into netlink. I would have to create mine from scratch for ebpf. This will include not just the construction/parsing but all the detailed attribute content policy validations(even in the presence of hierarchies) that comes with it. And not to forget the state transform between kernel and user space.
But the series here does that as well probably could reuse that on top of BPF. We have lots of libraries to deal with ebpf to help. I don't see anything problematic here for BPF.
Quoted 4 lines
2. Multi-user request/response messaging
If you can write all the code for #1 above then this should work fine for ebpf
Quoted 8 lines
3. Event publish subscribe
You would have to create mechanisms for ebpf which either are non trivial or non complete: Example 1: you can put surgeries in the ebpf code to look at map manipulations and then interface it to some event management scheme which checks for subscribed users. Example 2: It may also be feasible to create your own map for subscription vs something like perf ring for event publication(something i have done in the past), but that is also limited in many ways.
I would just push them out over a single perf ring and build the subscription on top of GRPC (pick your protocol of choice).
Quoted 12 lines
Quoted 11 lines
Quoted 8 lines
breakdown. And of course there's more but above is a good sample.
The part that is taken for granted is the control plane code and interaction which is an extremely important detail. P4 Abstraction requires hierarchies with different compiler generated encoded path ids etc. This ID mapping gets exacerbated by having multitudes of P4
Why the actual eBFP mapping does not serve the same purpose as ID? ID:mapping 1 :1
Quoted 7 lines
An identification of an object requires hierarchical IDs: A pipeline/program ID, A table id, a table entry Identification, an action identification and for each individual action content parameter, an ID etc. These same IDs would be what hardware would recognize as well (in case of offload). Given the dynamic nature of these IDs it is essentially up to the compiler to define them. These hierarchies are much easier to validate in netlink.
I'm on board for offloads, but this series says no offloads and we have no one with hardware in Linux for offloads yet. If we have a series with a P4 driver and NIC I can get my hands on now we have an entirely different conversation.
None of this above is a problem in eBPF. Its just mapping ids around.
Quoted 3 lines
We dont want to be constrained to a generic infra like eBPF for these objects. Again eBPF is a means to an end (and not the goal here!).
I don't see any constraints from eBPF above just a list of things that of course you would have to code up. But none of that doesn't already exist in other projects.
Quoted 33 lines
cheers,
jamalQuoted 30 lines
Quoted 30 lines
programs which have different requirements. Netlink is a natural fit for this P4 abstraction. Not to mention the netlink/tc path (and in particular the ID mapping) provides a conduit for offload when that is needed.
eBPF is just a tool - and the objects are intended to be generic - and i dont see how any of this could be achieved without retooling to make it more specific to P4.cheers,
jamalQuoted 15 lines
Quoted 12 lines
I should note: that there was an interesting talk at netdevconf
0x17where the speaker showed the challenges of dealing with ebpf on "day two" - slides or videos are not up yet, but link is:
https://netdevconf.info/0x17/sessions/talk/is-scaling-ebpf-easy-yet-a-small-step-to-one-server-but-giant-leap-to-distributed-network.html
The point the speaker was making is it's always easy to whip an ebpf program that can slice and dice packets and maybe even flush LEDs but the real work and challenge is in the control plane. I agree with the speaker based on my experiences. This discussion of replacing netlink with ebpf system calls is absolutely a non-starter. Let's just end the discussion and agree to disagree if you are going to keep insisting on that.[...]
Jamal Hadi Salim
maintainerQuoted 49 lines · John Fastabend
Quoted 40 lines · Jamal Hadi Salim
Quoted 39 lines · Jiri Pirko
Quoted 37 lines · Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:
Quoted 35 lines · Jiri Pirko
Quoted 6 lines · Fri, Nov 17, 2023 at 09:46:11PM CET, [email protected] wrote:
Quoted 5 lines · John Fastabend
Quoted 3 lines · Jamal Hadi Salim
Quoted 2 lines · John Fastabend
Jamal Hadi Salim wrote:
[...]
Quoted 11 lines
Quoted 10 lines
I think I'm judging the technical work here. Bullet points.
1. p4c-tc implementation looks like it should be slower than a in terms of pkts/sec than a bpf implementation. Meaning I suspect pipeline and objects laid out like this will lose to a BPF program with an parser and single lookup. The p4c-ebpf compiler should look to create optimized EBPF code not some emulated switch topology.
Quoted 9 lines
The parser is ebpf based. The other objects which require control plane interaction are not - those interact via netlink.
We published perf data a while back - presented at the P4 workshop back in April (was in the cover letter)
https://github.com/p4tc-dev/docs/blob/main/p4-conference-2023/2023P4WorkshopP4TC.pdf
But do note: the correct abstraction is the first priority. Optimization is something we can teach the compiler over time. But even with the minimalist code generation you can see that our approach always beats ebpf in LPM and ternary. The other ones I am pretty sureAny idea why? Perhaps the existing eBPF maps are not that suitable for this kinds of lookups? I mean in theory, eBPF should be always faster.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
We didnt look closely; however, that is not the point - the point is the perf difference if there is one, is not big with the big win being proper P4 abstraction. For LPM for sure our algorithmic approach is better. For ternary the compute intensity in looping is better done in C. And for exact i believe that ebpf uses better hashing.
Again, that is not the point we were trying to validate in those experiments..
Quoted 6 lines
If you compared your implementation to the bpf
lpm_trieits a bit misleading. The data structure is a rhashtable vs a Trie doing LPM.Also I can't see how
__p4tc_table_entry_lookup()is going to scale? That looks like a bucket per key? If so that wont scale well with 1000's of entries and lots of duplicate masks.
I think you are misreading the code - there are no duplicate masks; iiuc, by scale you mean performance of lookup and the numbers we got show very different results (the more entries and masks the better numbers we showed).
Again - i dont want to make this a topic. The issue is not whether we beat you or you beat us in numbers is not relevant to begin with.
Quoted 22 lines
I did a quick scan
of code, but would be nice to detail the algorithm in the commit msg so we can disect it.This doesn't look what we would want though for an LPM unless I've dropped this out of context.
(quoted diff) +15
-0+static struct p4tc_table_entry * +__p4tc_entry_lookup(struct p4tc_table *table, struct p4tc_table_entry_key *key) + __must_hold(RCU) +{ + struct p4tc_table_entry *entry = NULL; + struct rhlist_head *tmp, *bucket_list; + struct p4tc_table_entry *entry_curr; + u32 smallest_prio = U32_MAX; + + bucket_list = + rhltable_lookup(&table->tbl_entries, key, entry_hlt_params); + if (!bucket_list) + return NULL; + + rhl_for_each_entry_rcu(entry_curr, tmp, bucket_list, ht_node) {
Review
Quoted 10 lines
(quoted diff) +10
-0+ struct p4tc_table_entry_value *value = + p4tc_table_entry_value(entry_curr); + if (value->prio <= smallest_prio) { + smallest_prio = value->prio; + entry = entry_curr; + } + } + + return entry; +}
You are quoting the ternary (not LPM) matching code. It iterates all entries (we could only do ~190 when we tested in plain ebpf, thats why our test was restricted to that number).
Quoted 3 lines
Also I don't know what 'better done in C' matters the TCAM data structure can be written in C and used as a BPF map. At least that is how we would normally approach it from BPF side.
See the code you quoted - you have to loop and pick the best of N matches, where N could be arbitrarily large.
Quoted 11 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
On your point of "maps are not that suitable" P4 tables tend to have very specific attributes (examples associated meters, counters, default hit and miss actions, etc).
The typical way we handle this from BPF is to either use the 0 entry for stats, annotations, etc. or create a blob of memory (another map, variables, global struct, ...) and stash the info there. If we care about performance we make those per cpu and deal with it in user land.
Back to the abstraction overhead in user space being high. The whole point is to minimize all that..
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 22 lines
Quoted 14 lines
we can optimize over time.
Your view of "single lookup" is true for simple programs but if you have 10 tables trying to model a 5G function then it doesnt make sense (and i think the data we published was clear that you gain no advantage using ebpf - as a matter of fact there was no perf difference between XDP and tc in such cases).Quoted 5 lines
2. p4c-tc control plan looks slower than a directly mmaped bpf map. Doing a simple update vs a netlink msg. The argument that BPF can't do CRUD (which we had offlist) seems incorrect to me. Correct me if I'm wrong with details about why.
Quoted 5 lines
So let me see....
you want me to replace netlink and all its features and rewrite it using the ebpf system calls? Congestion control, event handling, arbitrary message crafting, etc and the years of work that went into netlink? NO to the HELL.Wait, I don't think John suggests anything like that. He just suggests to have the tables as eBPF maps.
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
What's the difference? Unless maps can do netlink.
I'm going to argue map update time matters and we should use the fastest updates possible. If it complicates user space side some I would prefer that to slow updates. I don't think you can get much faster than a mmaped block of memory. Or even syscall updates are probably faster than netlink msgs.
So lets put this to rest:
It's about the P4 abstraction first (as i mentioned earlier) - i am sure mmaping would be faster, but that is secondary - correct abstraction first.
I am ok with some level of abstraction wrangling (example match-action in P4 to match-value in ebpf) but there is a limit.
Quoted 22 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 7 lines
Honestly, I don't understand the
fixation on netlink. Its socket messaging, memcpies, processing overhead, etc can't keep up with mmaped memory access at scale. Measure that and I bet you'll get drastically different results.I mean, netlink is good for a lot of things, but does not mean it is an universal answer to userspace<->kernel data passing.
Here's a small sample of our requirements that are satisfied by netlink for P4 object hierarchy[1]:
1. Msg construction/parsing
2. Multi-user request/response messagingQuoted 8 lines
Quoted 2 lines
What is actually a usecase for having multiple users program p4 pipeline in parallel?
First of all - this is Linux, multiple users is a way of life, you shouldnt have to ask that question unless you are trying to be socratic. Meaning multiple control plane apps can be allowed to program different parts and even different tables - think multi-tier pipeline.
Quoted 9 lines
Linux is always been opinionated and rejects code all the time because its not the "right" way. I've been on the reject your stuff side before.
Partitioning ownershiip of the pipeline is different than multiple users of the same elements. From BPF side (to show its doable) is done by pinning maps to files and giving that file to different programs. The DDOS thing can own the DDOS map and the router can own its router tables. BPF handles this using the file systems mostly.
And with tc it just fits right in without any of those tricks...
Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
3. Multi-user event subscribe/publish messaging
Same here. What is the usecase for multiple users receiving p4 events?
Same thing.
Note: Events are really not part of P4 but we added them for flexibility - and as you well know they are useful.
Quoted 7 lines
Per above I wouldn't sacrafice update perf for this. Also its doable from userspace if you need to. Other thing I've come to dislike a bit is teaching the kernel a specific DSL. P4 is my favorte, but still going so far as to encode a specific P4 spec into the kernel seems unnecessary. Also now will we have to have kernel X supports P4.16 and kernel X+N supports P4.18 it seems like a pain.
I believe you are misunderstanding, let me explain. While our focus is on PNA:
There is no change in the kernel infra (upstream code) for PNA or PSA or PXXXX. The compiler may end up generating different code depending on the architecture selected at the compile command line. The control constructs are very static with their hierarchy IDs.
In regards to what you prophesize above when the language goes from P4.16 to P4.18 - i dont mean to be rude, but: kettle look at pot much?;-> i.e what happens when eBPF ISA gets extended? The safety feature we have for P4TC is externs - most of these will be implemented as self-fulfilling kfuncs.
Quoted 18 lines
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
I dont think i need to provide an explanation on the differences here visavis what ebpf system calls provide vs what netlink provides and how netlink is a clear fit. If it is not clear i can give more
It is not :/
Quoted 8 lines
I thought it was obvious for someone like you, but fine - here goes for those 3:
1. Msg construction/parsing: A lot of infra for sending attributes back and forth is already built into netlink. I would have to create mine from scratch for ebpf. This will include not just the construction/parsing but all the detailed attribute content policy validations(even in the presence of hierarchies) that comes with it. And not to forget the state transform between kernel and user space.
Quoted 3 lines
But the series here does that as well probably could reuse that on top of BPF. We have lots of libraries to deal with ebpf to help. I don't see anything problematic here for BPF.
Which library does all these (netlink features) in eBPF and has something matching it in the kernel? We did try to write our own but it was a huge waste of time.
Quoted 13 lines
Quoted 4 lines
2. Multi-user request/response messaging
If you can write all the code for #1 above then this should work fine for ebpfQuoted 8 lines
3. Event publish subscribe
You would have to create mechanisms for ebpf which either are non trivial or non complete: Example 1: you can put surgeries in the ebpf code to look at map manipulations and then interface it to some event management scheme which checks for subscribed users. Example 2: It may also be feasible to create your own map for subscription vs something like perf ring for event publication(something i have done in the past), but that is also limited in many ways.
Quoted 3 lines
I would just push them out over a single perf ring and build the subscription on top of GRPC (pick your protocol of choice).
Why - just so i could use ebpf? Ive never understood that single user mode perf ring thing.
Quoted 20 lines
Quoted 12 lines
Quoted 11 lines
Quoted 8 lines
breakdown. And of course there's more but above is a good sample.
The part that is taken for granted is the control plane code and interaction which is an extremely important detail. P4 Abstraction requires hierarchies with different compiler generated encoded path ids etc. This ID mapping gets exacerbated by having multitudes of P4
Why the actual eBFP mapping does not serve the same purpose as ID? ID:mapping 1 :1
Quoted 7 lines
An identification of an object requires hierarchical IDs: A pipeline/program ID, A table id, a table entry Identification, an action identification and for each individual action content parameter, an ID etc. These same IDs would be what hardware would recognize as well (in case of offload). Given the dynamic nature of these IDs it is essentially up to the compiler to define them. These hierarchies are much easier to validate in netlink.
Quoted 4 lines
I'm on board for offloads, but this series says no offloads and we have no one with hardware in Linux for offloads yet. If we have a series with a P4 driver and NIC I can get my hands on now we have an entirely different conversation.
The argument made is that P4 s/w stands on its own merit regardless of presence of hardware offload (there are s/w versions of DPDK and rust that I believe are used in production). As an example, the DASH project quoted in the cover letter uses P4 as a datapath specification language. The datapath is then verified to be working in s/w. So let's not argue that there is no merit to a s/w P4 version without h/w offload.
I do have a NIC(Intel e2000) that does P4 offloads but i am afraid I can't give it to you. Folks who are doing offloads will present drivers when they are ready and when/if those patches show there will be extensions to deal with ndo_tc. But i know you already know and are on the p4tc mailing list and are quite aware of these developments - I am not sure I understand your motivation for bringing this up a few times now. I read it as some sort of insinuation that there is some secret vendor hardware that is going to benefit from all this secret trojan we are doing here. Again P4 s/w stands on its own.
Quoted 10 lines
None of this above is a problem in eBPF. Its just mapping ids around.
Quoted 3 lines
We dont want to be constrained to a generic infra like eBPF for these objects. Again eBPF is a means to an end (and not the goal here!).
I don't see any constraints from eBPF above just a list of things that of course you would have to code up. But none of that doesn't already exist in other projects.
And we can agree to disagree.
cheers,
jamal
Quoted 35 lines
Quoted 33 lines
cheers,
jamalQuoted 30 lines
Quoted 30 lines
programs which have different requirements. Netlink is a natural fit for this P4 abstraction. Not to mention the netlink/tc path (and in particular the ID mapping) provides a conduit for offload when that is needed.
eBPF is just a tool - and the objects are intended to be generic - and i dont see how any of this could be achieved without retooling to make it more specific to P4.cheers,
jamalQuoted 15 lines
Quoted 12 lines
I should note: that there was an interesting talk at netdevconf
0x17where the speaker showed the challenges of dealing with ebpf on "day two" - slides or videos are not up yet, but link is:
https://netdevconf.info/0x17/sessions/talk/is-scaling-ebpf-easy-yet-a-small-step-to-one-server-but-giant-leap-to-distributed-network.html
The point the speaker was making is it's always easy to whip an ebpf program that can slice and dice packets and maybe even flush LEDs but the real work and challenge is in the control plane. I agree with the speaker based on my experiences. This discussion of replacing netlink with ebpf system calls is absolutely a non-starter. Let's just end the discussion and agree to disagree if you are going to keep insisting on that.[...]
Daniel Borkmann
maintainerQuoted 115 lines · Jamal Hadi Salim
Quoted 74 lines · Jiri Pirko
Quoted 73 lines · Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:
Quoted 27 lines · Jiri Pirko
Quoted 4 lines · Fri, Nov 17, 2023 at 09:46:11PM CET, [email protected] wrote:
Quoted 3 lines · John Fastabend
Quoted 2 lines · Jamal Hadi Salim
Quoted 1 line · John Fastabend
Jamal Hadi Salim wrote:
[...]
Quoted 9 lines
Quoted 8 lines
I think I'm judging the technical work here. Bullet points.
1. p4c-tc implementation looks like it should be slower than a in terms of pkts/sec than a bpf implementation. Meaning I suspect pipeline and objects laid out like this will lose to a BPF program with an parser and single lookup. The p4c-ebpf compiler should look to create optimized EBPF code not some emulated switch topology.
Quoted 9 lines
The parser is ebpf based. The other objects which require control plane interaction are not - those interact via netlink.
We published perf data a while back - presented at the P4 workshop back in April (was in the cover letter)
https://github.com/p4tc-dev/docs/blob/main/p4-conference-2023/2023P4WorkshopP4TC.pdf
But do note: the correct abstraction is the first priority. Optimization is something we can teach the compiler over time. But even with the minimalist code generation you can see that our approach always beats ebpf in LPM and ternary. The other ones I am pretty sureQuoted 2 lines
Any idea why? Perhaps the existing eBPF maps are not that suitable for this kinds of lookups? I mean in theory, eBPF should be always faster.
We didnt look closely; however, that is not the point - the point is the perf difference if there is one, is not big with the big win being proper P4 abstraction. For LPM for sure our algorithmic approach is better. For ternary the compute intensity in looping is better done in C. And for exact i believe that ebpf uses better hashing.
Again, that is not the point we were trying to validate in those experiments..On your point of "maps are not that suitable" P4 tables tend to have very specific attributes (examples associated meters, counters, default hit and miss actions, etc).
Quoted 12 lines
Quoted 12 lines
we can optimize over time.
Your view of "single lookup" is true for simple programs but if you have 10 tables trying to model a 5G function then it doesnt make sense (and i think the data we published was clear that you gain no advantage using ebpf - as a matter of fact there was no perf difference between XDP and tc in such cases).Quoted 4 lines
2. p4c-tc control plan looks slower than a directly mmaped bpf map. Doing a simple update vs a netlink msg. The argument that BPF can't do CRUD (which we had offlist) seems incorrect to me. Correct me if I'm wrong with details about why.
Quoted 8 lines
Quoted 5 lines
So let me see....
you want me to replace netlink and all its features and rewrite it using the ebpf system calls? Congestion control, event handling, arbitrary message crafting, etc and the years of work that went into netlink? NO to the HELL.Wait, I don't think John suggests anything like that. He just suggests to have the tables as eBPF maps.
What's the difference? Unless maps can do netlink.
Quoted 7 lines
Honestly, I don't understand the
fixation on netlink. Its socket messaging, memcpies, processing overhead, etc can't keep up with mmaped memory access at scale. Measure that and I bet you'll get drastically different results.I mean, netlink is good for a lot of things, but does not mean it is an universal answer to userspace<->kernel data passing.
Quoted 7 lines
Quoted 4 lines
Here's a small sample of our requirements that are satisfied by netlink for P4 object hierarchy[1]:
1. Msg construction/parsing
2. Multi-user request/response messagingWhat is actually a usecase for having multiple users program p4 pipeline in parallel?
First of all - this is Linux, multiple users is a way of life, you shouldnt have to ask that question unless you are trying to be socratic. Meaning multiple control plane apps can be allowed to program different parts and even different tables - think multi-tier pipeline.
Quoted 3 lines
Quoted 1 line
3. Multi-user event subscribe/publish messaging
Same here. What is the usecase for multiple users receiving p4 events?
Same thing.
Note: Events are really not part of P4 but we added them for flexibility - and as you well know they are useful.Quoted 5 lines
Quoted 3 lines
I dont think i need to provide an explanation on the differences here visavis what ebpf system calls provide vs what netlink provides and how netlink is a clear fit. If it is not clear i can give more
It is not :/
I thought it was obvious for someone like you, but fine - here goes for those 3:
1. Msg construction/parsing: A lot of infra for sending attributes back and forth is already built into netlink. I would have to create mine from scratch for ebpf. This will include not just the construction/parsing but all the detailed attribute content policy validations(even in the presence of hierarchies) that comes with it. And not to forget the state transform between kernel and user space.
2. Multi-user request/response messaging
If you can write all the code for #1 above then this should work fine for ebpf
Quoted 8 lines
3. Event publish subscribe
You would have to create mechanisms for ebpf which either are non trivial or non complete: Example 1: you can put surgeries in the ebpf code to look at map manipulations and then interface it to some event management scheme which checks for subscribed users. Example 2: It may also be feasible to create your own map for subscription vs something like perf ring for event publication(something i have done in the past), but that is also limited in many ways.
I still don't think this answers all the questions on why the netlink shim layer. The kfuncs are essentially available to all of tc BPF and I don't think there was a discussion why they cannot be done generic in a way that they could benefit all tc/XDP BPF users. With the patch 14 you are more or less copying what is existing with {cls,act}_bpf just that you also allow XDP loading from tc(?). We do have existing interfaces for XDP program management.
tc BPF and XDP already have widely used infrastructure and can be developed against libbpf or other user space libraries for a user space control plane. With 'control plane' you refer here to the tc / netlink shim you've built, but looking at the tc command line examples, this doesn't really provide a good user experience (you call it p4 but people load bpf obj files). If the expectation is that an operator should run tc commands, then neither it's a nice experience for p4 nor for BPF folks. From a BPF PoV, we moved over to bpf_mprog and plan to also extend this for XDP to have a common look and feel wrt networking for developers. Why can't this be reused?
I don't quite follow why not most of this could be implemented entirely in user space without the detour of this and you would provide a developer library which could then be integrated into a p4 runtime/frontend? This way users never interface with ebpf parts nor tc given they also shouldn't have to - it's an implementation detail. This is what John was also pointing out earlier.
If you need notifications/subscribe mechanism for map updates, then this could be extended.. same way like BPF internals got extended along with the sched_ext work, making the core pieces more useful also outside of the latter.
The link to below slides are not public, so it's hard to see what is really meant here, but I have also never seen an email from the speaker on the BPF mailing list providing concrete feedback(?). People do build control planes around BPF in the wild, I'm not sure where you take 'flush LEDs' from, to me this all sounds rather hand-wavy and trying to brute-force the fixation on netlink you went with that is raising questions. I don't think there was objection on going with eBPF but rather all this infra for the former for a SW-only extension.
[...]
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
I should note: that there was an interesting talk at netdevconf
0x17where the speaker showed the challenges of dealing with ebpf on "day two" - slides or videos are not up yet, but link is:
https://netdevconf.info/0x17/sessions/talk/is-scaling-ebpf-easy-yet-a-small-step-to-one-server-but-giant-leap-to-distributed-network.html
The point the speaker was making is it's always easy to whip an ebpf program that can slice and dice packets and maybe even flush LEDs but the real work and challenge is in the control plane. I agree with the speaker based on my experiences. This discussion of replacing netlink with ebpf system calls is absolutely a non-starter. Let's just end the discussion and agree to disagree if you are going to keep insisting on that.
Jamal Hadi Salim
maintainerQuoted 126 lines · Daniel Borkmann
Quoted 115 lines · Jamal Hadi Salim
Quoted 74 lines · Jiri Pirko
Quoted 73 lines · Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:
Quoted 27 lines · Jiri Pirko
Quoted 4 lines · Fri, Nov 17, 2023 at 09:46:11PM CET, [email protected] wrote:
Quoted 3 lines · John Fastabend
Quoted 2 lines · Jamal Hadi Salim
Quoted 1 line · John Fastabend
Jamal Hadi Salim wrote:
[...]
Quoted 9 lines
Quoted 8 lines
I think I'm judging the technical work here. Bullet points.
1. p4c-tc implementation looks like it should be slower than a in terms of pkts/sec than a bpf implementation. Meaning I suspect pipeline and objects laid out like this will lose to a BPF program with an parser and single lookup. The p4c-ebpf compiler should look to create optimized EBPF code not some emulated switch topology.
Quoted 9 lines
The parser is ebpf based. The other objects which require control plane interaction are not - those interact via netlink.
We published perf data a while back - presented at the P4 workshop back in April (was in the cover letter)
https://github.com/p4tc-dev/docs/blob/main/p4-conference-2023/2023P4WorkshopP4TC.pdf
But do note: the correct abstraction is the first priority. Optimization is something we can teach the compiler over time. But even with the minimalist code generation you can see that our approach always beats ebpf in LPM and ternary. The other ones I am pretty sureQuoted 2 lines
Any idea why? Perhaps the existing eBPF maps are not that suitable for this kinds of lookups? I mean in theory, eBPF should be always faster.
We didnt look closely; however, that is not the point - the point is the perf difference if there is one, is not big with the big win being proper P4 abstraction. For LPM for sure our algorithmic approach is better. For ternary the compute intensity in looping is better done in C. And for exact i believe that ebpf uses better hashing.
Again, that is not the point we were trying to validate in those experiments..On your point of "maps are not that suitable" P4 tables tend to have very specific attributes (examples associated meters, counters, default hit and miss actions, etc).
Quoted 12 lines
Quoted 12 lines
we can optimize over time.
Your view of "single lookup" is true for simple programs but if you have 10 tables trying to model a 5G function then it doesnt make sense (and i think the data we published was clear that you gain no advantage using ebpf - as a matter of fact there was no perf difference between XDP and tc in such cases).Quoted 4 lines
2. p4c-tc control plan looks slower than a directly mmaped bpf map. Doing a simple update vs a netlink msg. The argument that BPF can't do CRUD (which we had offlist) seems incorrect to me. Correct me if I'm wrong with details about why.
Quoted 8 lines
Quoted 5 lines
So let me see....
you want me to replace netlink and all its features and rewrite it using the ebpf system calls? Congestion control, event handling, arbitrary message crafting, etc and the years of work that went into netlink? NO to the HELL.Wait, I don't think John suggests anything like that. He just suggests to have the tables as eBPF maps.
What's the difference? Unless maps can do netlink.
Quoted 7 lines
Honestly, I don't understand the
fixation on netlink. Its socket messaging, memcpies, processing overhead, etc can't keep up with mmaped memory access at scale. Measure that and I bet you'll get drastically different results.I mean, netlink is good for a lot of things, but does not mean it is an universal answer to userspace<->kernel data passing.
Quoted 7 lines
Quoted 4 lines
Here's a small sample of our requirements that are satisfied by netlink for P4 object hierarchy[1]:
1. Msg construction/parsing
2. Multi-user request/response messagingWhat is actually a usecase for having multiple users program p4 pipeline in parallel?
First of all - this is Linux, multiple users is a way of life, you shouldnt have to ask that question unless you are trying to be socratic. Meaning multiple control plane apps can be allowed to program different parts and even different tables - think multi-tier pipeline.
Quoted 3 lines
Quoted 1 line
3. Multi-user event subscribe/publish messaging
Same here. What is the usecase for multiple users receiving p4 events?
Same thing.
Note: Events are really not part of P4 but we added them for flexibility - and as you well know they are useful.Quoted 5 lines
Quoted 3 lines
I dont think i need to provide an explanation on the differences here visavis what ebpf system calls provide vs what netlink provides and how netlink is a clear fit. If it is not clear i can give more
It is not :/
I thought it was obvious for someone like you, but fine - here goes for those 3:
1. Msg construction/parsing: A lot of infra for sending attributes back and forth is already built into netlink. I would have to create mine from scratch for ebpf. This will include not just the construction/parsing but all the detailed attribute content policy validations(even in the presence of hierarchies) that comes with it. And not to forget the state transform between kernel and user space.
2. Multi-user request/response messaging
If you can write all the code for #1 above then this should work fine for ebpfQuoted 8 lines
3. Event publish subscribe
You would have to create mechanisms for ebpf which either are non trivial or non complete: Example 1: you can put surgeries in the ebpf code to look at map manipulations and then interface it to some event management scheme which checks for subscribed users. Example 2: It may also be feasible to create your own map for subscription vs something like perf ring for event publication(something i have done in the past), but that is also limited in many ways.
Quoted 8 lines
I still don't think this answers all the questions on why the netlink shim layer. The kfuncs are essentially available to all of tc BPF and I don't think there was a discussion why they cannot be done generic in a way that they could benefit all tc/XDP BPF users. With the patch 14 you are more or less copying what is existing with {cls,act}_bpf just that you also allow XDP loading from tc(?). We do have existing interfaces for XDP program management.
I am not sure i followed - but we are open to suggestions to improve operation usability.
Quoted 9 lines
tc BPF and XDP already have widely used infrastructure and can be developed against libbpf or other user space libraries for a user space control plane. With 'control plane' you refer here to the tc / netlink shim you've built, but looking at the tc command line examples, this doesn't really provide a good user experience (you call it p4 but people load bpf obj files). If the expectation is that an operator should run tc commands, then neither it's a nice experience for p4 nor for BPF folks. From a BPF PoV, we moved over to
bpf_mprogand plan to also extend this for XDP to have a common look and feel wrt networking for developers. Why can't this be reused?
The filter loading which loads the program is considered pipeline instantiation - consider it as "provisioning" more than "control" which runs at runtime. "control" is purely netlink based. The iproute2 code we use links libbpf for example for the filter. If we can achieve the same with bpf_mprog then sure - we just dont want to loose functionality though. off top of my head, some sample space:
- we could have multiple pipelines with different priorities (which tc provides to us) - and each pipeline may have its own logic with many tables etc (and the choice to iterate the next one is essentially encoded in the tc action codes)
- we use tc block to map groups of ports (which i dont think bpf has internal access of)
In regards to usability: no i dont expect someone doing things at scale to use command line tc. The APIs are via netlink. But the tc cli is must for the rest of the masses per our traditions. Also i really didnt even want to use ebpf at all for operator experience reasons - it requires a compilation of the code and an extra loading compared to what our original u32/pedit code offered.
Quoted 7 lines
I don't quite follow why not most of this could be implemented entirely in user space without the detour of this and you would provide a developer library which could then be integrated into a p4 runtime/frontend? This way users never interface with ebpf parts nor tc given they also shouldn't have to - it's an implementation detail. This is what John was also pointing out earlier.
Netlink is the API. We will provide a library for object manipulation which abstracts away the need to know netlink. Someone who for their own reasons wants to use p4runtime or TDI could write on top of this. I would not design a kernel interface to just meet p4runtime (we already have TDI which came later which does things differently). So i expect us to support both those two. And if i was to do something on SDN that was more robust i would write my own that still uses these netlink interfaces.
Quoted 4 lines
If you need notifications/subscribe mechanism for map updates, then this could be extended.. same way like BPF internals got extended along with the
sched_extwork, making the core pieces more useful also outside of the latter.
Why? I already have this working great right now with netlink.
Quoted 8 lines
The link to below slides are not public, so it's hard to see what is really meant here, but I have also never seen an email from the speaker on the BPF mailing list providing concrete feedback(?). People do build control planes around BPF in the wild, I'm not sure where you take 'flush LEDs' from, to me this all sounds rather hand-wavy and trying to brute-force the fixation on netlink you went with that is raising questions. I don't think there was objection on going with eBPF but rather all this infra for the former for a SW-only extension.
There are a handful of people who are holding the slides being released (will go and chase them after this).
BTW, our experience in regards to usability for eBPF control plane is the same as Ivan. I was listening to the talk and just nodding along. You focused too much on the datapath and did a good job there but i am afraid not so much on usability of the control path. My view is: to create a back and forth with the kernel for something as complex as we have using the ebpf system calls vs netlink, you would need to spend a lot more developer resources in the ebpf case. If you want to call what i have a "the fixation on netlink" maybe you are fixated on ebpf syscall?;->
cheers,
jamal
Quoted 12 lines
[...]
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
I should note: that there was an interesting talk at netdevconf
0x17where the speaker showed the challenges of dealing with ebpf on "day two" - slides or videos are not up yet, but link is:
https://netdevconf.info/0x17/sessions/talk/is-scaling-ebpf-easy-yet-a-small-step-to-one-server-but-giant-leap-to-distributed-network.html
The point the speaker was making is it's always easy to whip an ebpf program that can slice and dice packets and maybe even flush LEDs but the real work and challenge is in the control plane. I agree with the speaker based on my experiences. This discussion of replacing netlink with ebpf system calls is absolutely a non-starter. Let's just end the discussion and agree to disagree if you are going to keep insisting on that.
Jiri Pirko
maintainerQuoted 5 lines · Mon, Nov 20, 2023 at 11:56:50PM CET, [email protected] wrote:
Quoted 4 lines · Daniel Borkmann
Quoted 2 lines · Jamal Hadi Salim
Quoted 1 line · Jiri Pirko
Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:
[...]
Quoted 24 lines
Quoted 10 lines
tc BPF and XDP already have widely used infrastructure and can be developed against libbpf or other user space libraries for a user space control plane. With 'control plane' you refer here to the tc / netlink shim you've built, but looking at the tc command line examples, this doesn't really provide a good user experience (you call it p4 but people load bpf obj files). If the expectation is that an operator should run tc commands, then neither it's a nice experience for p4 nor for BPF folks. From a BPF PoV, we moved over to
bpf_mprogand plan to also extend this for XDP to have a common look and feel wrt networking for developers. Why can't this be reused?The filter loading which loads the program is considered pipeline instantiation - consider it as "provisioning" more than "control" which runs at runtime. "control" is purely netlink based. The iproute2 code we use links libbpf for example for the filter. If we can achieve the same with
bpf_mprogthen sure - we just dont want to loose functionality though. off top of my head, some sample space:
- we could have multiple pipelines with different priorities (which tc provides to us) - and each pipeline may have its own logic with many tables etc (and the choice to iterate the next one is essentially encoded in the tc action codes)
- we use tc block to map groups of ports (which i dont think bpf has internal access of)
Quoted 3 lines
In regards to usability: no i dont expect someone doing things at scale to use command line tc. The APIs are via netlink. But the tc cli is must for the rest of the masses per our traditions. Also i really
I don't follow. You repeatedly mention "the must of the traditional tc cli", but what of the existing traditional cli you use for p4tc? If I look at the examples, pretty much everything looks new to me. Example:
tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \
action send_to_port param port eno1This is just TC/RTnetlink used as a channel to pass new things over. If that is the case, what's traditional here?
Quoted 12 lines
didnt even want to use ebpf at all for operator experience reasons - it requires a compilation of the code and an extra loading compared to what our original u32/pedit code offered.
Quoted 7 lines
I don't quite follow why not most of this could be implemented entirely in user space without the detour of this and you would provide a developer library which could then be integrated into a p4 runtime/frontend? This way users never interface with ebpf parts nor tc given they also shouldn't have to - it's an implementation detail. This is what John was also pointing out earlier.
Quoted 8 lines
Netlink is the API. We will provide a library for object manipulation which abstracts away the need to know netlink. Someone who for their own reasons wants to use p4runtime or TDI could write on top of this. I would not design a kernel interface to just meet p4runtime (we already have TDI which came later which does things differently). So i expect us to support both those two. And if i was to do something on SDN that was more robust i would write my own that still uses these netlink interfaces.
Actually, what Daniel says about the p4 library used as a backend to p4 frontend is pretty much aligned what I claimed on the p4 calls couple of times. If you have this p4 userspace tooling, it is easy for offloads to replace the backed by vendor-specific library which allows p4 offload suitable for all vendors (your plan of p4tc offload does not work well for our hw, as we repeatedly claimed).
As I also said on the p4 call couple of times, I don't see the kernel as the correct place to do the p4 abstractions. Why don't you do it in userspace and give vendors possiblity to have p4 backends with compilers, runtime optimizations etc in userspace, talking to the HW in the vendor-suitable way too. Then the SW implementation could be easily eBPF and the main reason (I believe) why you need to have this is TC (offload) is then void.
The "everyone wants to use TC/netlink" claim does not seem correct to me. Why not to have one Linux p4 solution that fits everyones needs?
[...]
Jamal Hadi Salim
maintainerQuoted 43 lines · Jiri Pirko
Quoted 5 lines · Mon, Nov 20, 2023 at 11:56:50PM CET, [email protected] wrote:
Quoted 4 lines · Daniel Borkmann
Quoted 2 lines · Jamal Hadi Salim
Quoted 1 line · Jiri Pirko
Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:
[...]
Quoted 24 lines
Quoted 10 lines
tc BPF and XDP already have widely used infrastructure and can be developed against libbpf or other user space libraries for a user space control plane. With 'control plane' you refer here to the tc / netlink shim you've built, but looking at the tc command line examples, this doesn't really provide a good user experience (you call it p4 but people load bpf obj files). If the expectation is that an operator should run tc commands, then neither it's a nice experience for p4 nor for BPF folks. From a BPF PoV, we moved over to
bpf_mprogand plan to also extend this for XDP to have a common look and feel wrt networking for developers. Why can't this be reused?The filter loading which loads the program is considered pipeline instantiation - consider it as "provisioning" more than "control" which runs at runtime. "control" is purely netlink based. The iproute2 code we use links libbpf for example for the filter. If we can achieve the same with
bpf_mprogthen sure - we just dont want to loose functionality though. off top of my head, some sample space:
- we could have multiple pipelines with different priorities (which tc provides to us) - and each pipeline may have its own logic with many tables etc (and the choice to iterate the next one is essentially encoded in the tc action codes)
- we use tc block to map groups of ports (which i dont think bpf has internal access of)Quoted 3 lines
In regards to usability: no i dont expect someone doing things at scale to use command line tc. The APIs are via netlink. But the tc cli is must for the rest of the masses per our traditions. Also i really
I don't follow. You repeatedly mention "the must of the traditional tc cli", but what of the existing traditional cli you use for p4tc? If I look at the examples, pretty much everything looks new to me. Example:
Quoted 6 lines
tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1This is just TC/RTnetlink used as a channel to pass new things over. If that is the case, what's traditional here?
What is not traditional about it?
Quoted 22 lines
Quoted 13 lines
didnt even want to use ebpf at all for operator experience reasons - it requires a compilation of the code and an extra loading compared to what our original u32/pedit code offered.
Quoted 7 lines
I don't quite follow why not most of this could be implemented entirely in user space without the detour of this and you would provide a developer library which could then be integrated into a p4 runtime/frontend? This way users never interface with ebpf parts nor tc given they also shouldn't have to - it's an implementation detail. This is what John was also pointing out earlier.
Quoted 8 lines
Netlink is the API. We will provide a library for object manipulation which abstracts away the need to know netlink. Someone who for their own reasons wants to use p4runtime or TDI could write on top of this. I would not design a kernel interface to just meet p4runtime (we already have TDI which came later which does things differently). So i expect us to support both those two. And if i was to do something on SDN that was more robust i would write my own that still uses these netlink interfaces.
Quoted 7 lines
Actually, what Daniel says about the p4 library used as a backend to p4 frontend is pretty much aligned what I claimed on the p4 calls couple of times. If you have this p4 userspace tooling, it is easy for offloads to replace the backed by vendor-specific library which allows p4 offload suitable for all vendors (your plan of p4tc offload does not work well for our hw, as we repeatedly claimed).
That's you - NVIDIA. You have chosen a path away from the kernel towards DOCA. I understand NVIDIA's frustration with dealing with upstream process (which has been cited to me as a good reason for DOCA) but please dont impose these values and your politics on other vendors(Intel, AMD for example) who are more than willing to invest into making the kernel interfaces the path forward. Your choice. Nobody is stopping you from offering your customers proprietary solutions which include a specific ebpf approach alongside DOCA. We believe that a singular interface regardless of the vendor is the right way forward. IMHO, this siloing that unfortunately is also added by eBPF being a double edged sword is not good for the community.
Quoted 10 lines
As I also said on the p4 call couple of times, I don't see the kernel as the correct place to do the p4 abstractions. Why don't you do it in userspace and give vendors possiblity to have p4 backends with compilers, runtime optimizations etc in userspace, talking to the HW in the vendor-suitable way too. Then the SW implementation could be easily eBPF and the main reason (I believe) why you need to have this is TC (offload) is then void.
The "everyone wants to use TC/netlink" claim does not seem correct to me. Why not to have one Linux p4 solution that fits everyones needs?
You mean more fitting to the DOCA world? no, because iam a kernel first person and kernel interfaces are good for everyone.
cheers,
jamal
Jiri Pirko
maintainerQuoted 47 lines · Tue, Nov 21, 2023 at 02:47:40PM CET, [email protected] wrote:
Quoted 46 lines · Jiri Pirko
Quoted 5 lines · Mon, Nov 20, 2023 at 11:56:50PM CET, [email protected] wrote:
Quoted 4 lines · Daniel Borkmann
Quoted 2 lines · Jamal Hadi Salim
Quoted 1 line · Jiri Pirko
Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:
[...]
Quoted 24 lines
Quoted 10 lines
tc BPF and XDP already have widely used infrastructure and can be developed against libbpf or other user space libraries for a user space control plane. With 'control plane' you refer here to the tc / netlink shim you've built, but looking at the tc command line examples, this doesn't really provide a good user experience (you call it p4 but people load bpf obj files). If the expectation is that an operator should run tc commands, then neither it's a nice experience for p4 nor for BPF folks. From a BPF PoV, we moved over to
bpf_mprogand plan to also extend this for XDP to have a common look and feel wrt networking for developers. Why can't this be reused?The filter loading which loads the program is considered pipeline instantiation - consider it as "provisioning" more than "control" which runs at runtime. "control" is purely netlink based. The iproute2 code we use links libbpf for example for the filter. If we can achieve the same with
bpf_mprogthen sure - we just dont want to loose functionality though. off top of my head, some sample space:
- we could have multiple pipelines with different priorities (which tc provides to us) - and each pipeline may have its own logic with many tables etc (and the choice to iterate the next one is essentially encoded in the tc action codes)
- we use tc block to map groups of ports (which i dont think bpf has internal access of)Quoted 3 lines
In regards to usability: no i dont expect someone doing things at scale to use command line tc. The APIs are via netlink. But the tc cli is must for the rest of the masses per our traditions. Also i really
I don't follow. You repeatedly mention "the must of the traditional tc cli", but what of the existing traditional cli you use for p4tc? If I look at the examples, pretty much everything looks new to me. Example:
tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1
Quoted 6 lines
Quoted 3 lines
This is just TC/RTnetlink used as a channel to pass new things over. If that is the case, what's traditional here?
What is not traditional about it?
Okay, so in that case, the following example communitating with userspace deamon using imaginary "p4ctrl" app is equally traditional:
$ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \
action send_to_port param port eno1Quoted 31 lines
Quoted 23 lines
Quoted 14 lines
didnt even want to use ebpf at all for operator experience reasons - it requires a compilation of the code and an extra loading compared to what our original u32/pedit code offered.
Quoted 7 lines
I don't quite follow why not most of this could be implemented entirely in user space without the detour of this and you would provide a developer library which could then be integrated into a p4 runtime/frontend? This way users never interface with ebpf parts nor tc given they also shouldn't have to - it's an implementation detail. This is what John was also pointing out earlier.
Quoted 8 lines
Netlink is the API. We will provide a library for object manipulation which abstracts away the need to know netlink. Someone who for their own reasons wants to use p4runtime or TDI could write on top of this. I would not design a kernel interface to just meet p4runtime (we already have TDI which came later which does things differently). So i expect us to support both those two. And if i was to do something on SDN that was more robust i would write my own that still uses these netlink interfaces.
Quoted 7 lines
Actually, what Daniel says about the p4 library used as a backend to p4 frontend is pretty much aligned what I claimed on the p4 calls couple of times. If you have this p4 userspace tooling, it is easy for offloads to replace the backed by vendor-specific library which allows p4 offload suitable for all vendors (your plan of p4tc offload does not work well for our hw, as we repeatedly claimed).
Quoted 6 lines
That's you - NVIDIA. You have chosen a path away from the kernel towards DOCA. I understand NVIDIA's frustration with dealing with upstream process (which has been cited to me as a good reason for DOCA) but please dont impose these values and your politics on other
vendors(Intel, AMD for example)who are more than willing to invest into making the kernel interfaces the path forward. Your choice.
No, you are missing the point. This has nothing to do with DOCA. This has to do with the simple limitation of your offload assuming there are no runtime changes in the compiled pipeline. For Intel, maybe they aren't, and it's a good fit for them. All I say is, that it is not the good fit for everyone.
Quoted 14 lines
Nobody is stopping you from offering your customers proprietary solutions which include a specific ebpf approach alongside DOCA. We believe that a singular interface regardless of the vendor is the right way forward. IMHO, this siloing that unfortunately is also added by eBPF being a double edged sword is not good for the community.
Quoted 8 lines
As I also said on the p4 call couple of times, I don't see the kernel as the correct place to do the p4 abstractions. Why don't you do it in userspace and give vendors possiblity to have p4 backends with compilers, runtime optimizations etc in userspace, talking to the HW in the vendor-suitable way too. Then the SW implementation could be easily eBPF and the main reason (I believe) why you need to have this is TC (offload) is then void.
Quoted 4 lines
Quoted 2 lines
The "everyone wants to use TC/netlink" claim does not seem correct to me. Why not to have one Linux p4 solution that fits everyones needs?
You mean more fitting to the DOCA world? no, because iam a kernel
Again, this has 0 relation to DOCA.
Quoted 1 line
first person and kernel interfaces are good for everyone.
Yeah, not really. Not always the kernel is the right answer. Your/Intel plan to handle the offload by:
1) abuse devlink to flash p4 binary
2) parse the binary in kernel to match to the table ids of rules coming from p4tc ndo_setup_tc
3) abuse devlink to flash p4 binary for tc-flower
4) parse the binary in kernel to match to the table ids of rules coming from tc-flower ndo_setup_tc
is really something that is making me a little bit nauseous.
If you don't have a feasible plan to do the offload, p4tc does not make sense to me to be honest.
Quoted 3 lines
cheers,
jamal
Jamal Hadi Salim
maintainerQuoted 54 lines · Jiri Pirko
Quoted 52 lines · Tue, Nov 21, 2023 at 02:47:40PM CET, [email protected] wrote:
Quoted 49 lines · Jiri Pirko
Quoted 5 lines · Mon, Nov 20, 2023 at 11:56:50PM CET, [email protected] wrote:
Quoted 4 lines · Daniel Borkmann
Quoted 2 lines · Jamal Hadi Salim
Quoted 1 line · Jiri Pirko
Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:
[...]
Quoted 24 lines
Quoted 10 lines
tc BPF and XDP already have widely used infrastructure and can be developed against libbpf or other user space libraries for a user space control plane. With 'control plane' you refer here to the tc / netlink shim you've built, but looking at the tc command line examples, this doesn't really provide a good user experience (you call it p4 but people load bpf obj files). If the expectation is that an operator should run tc commands, then neither it's a nice experience for p4 nor for BPF folks. From a BPF PoV, we moved over to
bpf_mprogand plan to also extend this for XDP to have a common look and feel wrt networking for developers. Why can't this be reused?The filter loading which loads the program is considered pipeline instantiation - consider it as "provisioning" more than "control" which runs at runtime. "control" is purely netlink based. The iproute2 code we use links libbpf for example for the filter. If we can achieve the same with
bpf_mprogthen sure - we just dont want to loose functionality though. off top of my head, some sample space:
- we could have multiple pipelines with different priorities (which tc provides to us) - and each pipeline may have its own logic with many tables etc (and the choice to iterate the next one is essentially encoded in the tc action codes)
- we use tc block to map groups of ports (which i dont think bpf has internal access of)Quoted 3 lines
In regards to usability: no i dont expect someone doing things at scale to use command line tc. The APIs are via netlink. But the tc cli is must for the rest of the masses per our traditions. Also i really
I don't follow. You repeatedly mention "the must of the traditional tc cli", but what of the existing traditional cli you use for p4tc? If I look at the examples, pretty much everything looks new to me. Example:
tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1This is just TC/RTnetlink used as a channel to pass new things over. If that is the case, what's traditional here?
Quoted 6 lines
Quoted 1 line
What is not traditional about it?
Okay, so in that case, the following example communitating with userspace deamon using imaginary "p4ctrl" app is equally traditional:
$ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1
Huh? Thats just an application - classical tc which part of iproute2 that is sending to the kernel, no different than "tc flower.." Where do you get the "userspace" daemon part? Yes, you can write a daemon but it will use the same APIs as tc.
Quoted 32 lines
Quoted 32 lines
Quoted 31 lines
Quoted 15 lines
didnt even want to use ebpf at all for operator experience reasons - it requires a compilation of the code and an extra loading compared to what our original u32/pedit code offered.
Quoted 7 lines
I don't quite follow why not most of this could be implemented entirely in user space without the detour of this and you would provide a developer library which could then be integrated into a p4 runtime/frontend? This way users never interface with ebpf parts nor tc given they also shouldn't have to - it's an implementation detail. This is what John was also pointing out earlier.
Quoted 8 lines
Netlink is the API. We will provide a library for object manipulation which abstracts away the need to know netlink. Someone who for their own reasons wants to use p4runtime or TDI could write on top of this. I would not design a kernel interface to just meet p4runtime (we already have TDI which came later which does things differently). So i expect us to support both those two. And if i was to do something on SDN that was more robust i would write my own that still uses these netlink interfaces.
Actually, what Daniel says about the p4 library used as a backend to p4 frontend is pretty much aligned what I claimed on the p4 calls couple of times. If you have this p4 userspace tooling, it is easy for offloads to replace the backed by vendor-specific library which allows p4 offload suitable for all vendors (your plan of p4tc offload does not work well for our hw, as we repeatedly claimed).
Quoted 8 lines
Quoted 6 lines
That's you - NVIDIA. You have chosen a path away from the kernel towards DOCA. I understand NVIDIA's frustration with dealing with upstream process (which has been cited to me as a good reason for DOCA) but please dont impose these values and your politics on other
vendors(Intel, AMD for example)who are more than willing to invest into making the kernel interfaces the path forward. Your choice.No, you are missing the point. This has nothing to do with DOCA.
Right Jiri ;->
Quoted 5 lines
This
has to do with the simple limitation of your offload assuming there are no runtime changes in the compiled pipeline. For Intel, maybe they aren't, and it's a good fit for them. All I say is, that it is not the good fit for everyone.
a) it is not part of the P4 spec to dynamically make changes to the
datapath pipeline after it is create and we are discussing a P4 implementation not an extension that would add more value b) We are more than happy to add extensions in the future to accomodate for features but first _P4 spec_ must be met c) we had longer discussions with Matty, Khalid and the Rice folks who wrote a paper on that topic which you probably didnt attend and everything that needs to be done can be from user space today for all those optimizations.
Conclusion is: For what you need to do (which i dont believe is a limitation in your hardware rather a design decision on your part) run your user space daemon, do optimizations and update the datapath. Everybody is happy.
Quoted 35 lines
Quoted 15 lines
Nobody is stopping you from offering your customers proprietary solutions which include a specific ebpf approach alongside DOCA. We believe that a singular interface regardless of the vendor is the right way forward. IMHO, this siloing that unfortunately is also added by eBPF being a double edged sword is not good for the community.
Quoted 8 lines
As I also said on the p4 call couple of times, I don't see the kernel as the correct place to do the p4 abstractions. Why don't you do it in userspace and give vendors possiblity to have p4 backends with compilers, runtime optimizations etc in userspace, talking to the HW in the vendor-suitable way too. Then the SW implementation could be easily eBPF and the main reason (I believe) why you need to have this is TC (offload) is then void.
Quoted 4 lines
Quoted 2 lines
The "everyone wants to use TC/netlink" claim does not seem correct to me. Why not to have one Linux p4 solution that fits everyones needs?
You mean more fitting to the DOCA world? no, because iam a kernel
Again, this has 0 relation to DOCA.
Quoted 1 line
first person and kernel interfaces are good for everyone.
Yeah, not really. Not always the kernel is the right answer. Your/Intel plan to handle the offload by:
1) abuse devlink to flash p4 binary
2) parse the binary in kernel to match to the table ids of rules coming from p4tcndo_setup_tc
3) abuse devlink to flash p4 binary for tc-flower
4) parse the binary in kernel to match to the table ids of rules coming from tc-flowerndo_setup_tc
is really something that is making me a little bit nauseous.
Quoted 2 lines
If you don't have a feasible plan to do the offload, p4tc does not make sense to me to be honest.
You mean if there's no plan to match your (NVIDIA?) point of view. For #1 - how's this different from DDP? Wasnt that your suggestion to begin with? For #2 Nobody is proposing to do anything of the sort. The ndo is passed IDs for the objects and associated contents. For #3+#4 tc flower thing has nothing to do with P4TC that was just some random proposal someone made seeing if they could ride on top of P4TC.
Besides this nobody really has to satisfy your point of view - like i said earlier feel free to provide proprietary solutions. From a consumer perspective I would not want to deal with 4 different vendors with 4 different proprietary approaches. The kernel is the unifying part. You seemed happier with tc flower just not with the kernel process - which is ironically the same thing we are going through here ;->
cheers,
jamal
Quoted 4 lines
Quoted 4 lines
cheers,
jamal
Jiri Pirko
maintainerQuoted 62 lines · Tue, Nov 21, 2023 at 04:21:44PM CET, [email protected] wrote:
Quoted 54 lines · Jiri Pirko
Quoted 52 lines · Tue, Nov 21, 2023 at 02:47:40PM CET, [email protected] wrote:
Quoted 49 lines · Jiri Pirko
Quoted 5 lines · Mon, Nov 20, 2023 at 11:56:50PM CET, [email protected] wrote:
Quoted 4 lines · Daniel Borkmann
Quoted 2 lines · Jamal Hadi Salim
Quoted 1 line · Jiri Pirko
Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:
[...]
Quoted 24 lines
Quoted 10 lines
tc BPF and XDP already have widely used infrastructure and can be developed against libbpf or other user space libraries for a user space control plane. With 'control plane' you refer here to the tc / netlink shim you've built, but looking at the tc command line examples, this doesn't really provide a good user experience (you call it p4 but people load bpf obj files). If the expectation is that an operator should run tc commands, then neither it's a nice experience for p4 nor for BPF folks. From a BPF PoV, we moved over to
bpf_mprogand plan to also extend this for XDP to have a common look and feel wrt networking for developers. Why can't this be reused?The filter loading which loads the program is considered pipeline instantiation - consider it as "provisioning" more than "control" which runs at runtime. "control" is purely netlink based. The iproute2 code we use links libbpf for example for the filter. If we can achieve the same with
bpf_mprogthen sure - we just dont want to loose functionality though. off top of my head, some sample space:
- we could have multiple pipelines with different priorities (which tc provides to us) - and each pipeline may have its own logic with many tables etc (and the choice to iterate the next one is essentially encoded in the tc action codes)
- we use tc block to map groups of ports (which i dont think bpf has internal access of)Quoted 3 lines
In regards to usability: no i dont expect someone doing things at scale to use command line tc. The APIs are via netlink. But the tc cli is must for the rest of the masses per our traditions. Also i really
I don't follow. You repeatedly mention "the must of the traditional tc cli", but what of the existing traditional cli you use for p4tc? If I look at the examples, pretty much everything looks new to me. Example:
tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1This is just TC/RTnetlink used as a channel to pass new things over. If that is the case, what's traditional here?
Quoted 6 lines
Quoted 1 line
What is not traditional about it?
Okay, so in that case, the following example communitating with userspace deamon using imaginary "p4ctrl" app is equally traditional:
$ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1
Quoted 4 lines
Huh? Thats just an application - classical tc which part of iproute2 that is sending to the kernel, no different than "tc flower.." Where do you get the "userspace" daemon part? Yes, you can write a daemon but it will use the same APIs as tc.
Okay, so which part is the "tradition"?
Quoted 44 lines
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines
Quoted 16 lines
didnt even want to use ebpf at all for operator experience reasons - it requires a compilation of the code and an extra loading compared to what our original u32/pedit code offered.
Quoted 7 lines
I don't quite follow why not most of this could be implemented entirely in user space without the detour of this and you would provide a developer library which could then be integrated into a p4 runtime/frontend? This way users never interface with ebpf parts nor tc given they also shouldn't have to - it's an implementation detail. This is what John was also pointing out earlier.
Quoted 8 lines
Netlink is the API. We will provide a library for object manipulation which abstracts away the need to know netlink. Someone who for their own reasons wants to use p4runtime or TDI could write on top of this. I would not design a kernel interface to just meet p4runtime (we already have TDI which came later which does things differently). So i expect us to support both those two. And if i was to do something on SDN that was more robust i would write my own that still uses these netlink interfaces.
Actually, what Daniel says about the p4 library used as a backend to p4 frontend is pretty much aligned what I claimed on the p4 calls couple of times. If you have this p4 userspace tooling, it is easy for offloads to replace the backed by vendor-specific library which allows p4 offload suitable for all vendors (your plan of p4tc offload does not work well for our hw, as we repeatedly claimed).
Quoted 8 lines
Quoted 6 lines
That's you - NVIDIA. You have chosen a path away from the kernel towards DOCA. I understand NVIDIA's frustration with dealing with upstream process (which has been cited to me as a good reason for DOCA) but please dont impose these values and your politics on other
vendors(Intel, AMD for example)who are more than willing to invest into making the kernel interfaces the path forward. Your choice.No, you are missing the point. This has nothing to do with DOCA.
Right Jiri ;->
Quoted 8 lines
Quoted 5 lines
This
has to do with the simple limitation of your offload assuming there are no runtime changes in the compiled pipeline. For Intel, maybe they aren't, and it's a good fit for them. All I say is, that it is not the good fit for everyone.a) it is not part of the P4 spec to dynamically make changes to the datapath pipeline after it is create and we are discussing a P4
Isn't this up to the implementation? I mean from the p4 perspective, everything is static. Hw might need to reshuffle the pipeline internally during rule insertion/remove in order to optimize the layout.
Quoted 11 lines
implementation not an extension that would add more value b) We are more than happy to add extensions in the future to accomodate for features but first
_P4spec_must be met c) we had longer discussions with Matty, Khalid and the Rice folks who wrote a paper on that topic which you probably didnt attend and everything that needs to be done can be from user space today for all those optimizations.Conclusion is: For what you need to do (which i dont believe is a limitation in your hardware rather a design decision on your part) run your user space daemon, do optimizations and update the datapath. Everybody is happy.
Should the userspace daemon listen on inserted rules to be offloade over netlink?
Quoted 36 lines
Quoted 36 lines
Quoted 16 lines
Nobody is stopping you from offering your customers proprietary solutions which include a specific ebpf approach alongside DOCA. We believe that a singular interface regardless of the vendor is the right way forward. IMHO, this siloing that unfortunately is also added by eBPF being a double edged sword is not good for the community.
Quoted 8 lines
As I also said on the p4 call couple of times, I don't see the kernel as the correct place to do the p4 abstractions. Why don't you do it in userspace and give vendors possiblity to have p4 backends with compilers, runtime optimizations etc in userspace, talking to the HW in the vendor-suitable way too. Then the SW implementation could be easily eBPF and the main reason (I believe) why you need to have this is TC (offload) is then void.
Quoted 4 lines
Quoted 2 lines
The "everyone wants to use TC/netlink" claim does not seem correct to me. Why not to have one Linux p4 solution that fits everyones needs?
You mean more fitting to the DOCA world? no, because iam a kernel
Again, this has 0 relation to DOCA.
Quoted 1 line
first person and kernel interfaces are good for everyone.
Yeah, not really. Not always the kernel is the right answer. Your/Intel plan to handle the offload by:
1) abuse devlink to flash p4 binary
2) parse the binary in kernel to match to the table ids of rules coming from p4tcndo_setup_tc
3) abuse devlink to flash p4 binary for tc-flower
4) parse the binary in kernel to match to the table ids of rules coming from tc-flowerndo_setup_tc
is really something that is making me a little bit nauseous.
Quoted 5 lines
Quoted 2 lines
If you don't have a feasible plan to do the offload, p4tc does not make sense to me to be honest.
You mean if there's no plan to match your (NVIDIA?) point of view. For #1 - how's this different from DDP? Wasnt that your suggestion to
I doubt that. Any flashing-blob-parsing-in-kernel is something I'm opposed to from day 1.
Quoted 2 lines
begin with? For #2 Nobody is proposing to do anything of the sort. The ndo is passed IDs for the objects and associated contents. For #3+#4
During offload, you need to parse the blob in driver to be able to match the ids with blob entities. That was presented by you/Intel in the past IIRC.
Quoted 2 lines
tc flower thing has nothing to do with P4TC that was just some random proposal someone made seeing if they could ride on top of P4TC.
Yeah, it's not yet merged and already mentally used for abuse. I love that :)
Quoted 6 lines
Besides this nobody really has to satisfy your point of view - like i said earlier feel free to provide proprietary solutions. From a consumer perspective I would not want to deal with 4 different vendors with 4 different proprietary approaches. The kernel is the unifying part. You seemed happier with tc flower just not with the
Yeah, that is my point, why the unifying part can't be a userspace daemon/library with multiple backends (p4tc, bpf, vendorX, vendorY, ..)?
I just don't see the kernel as a good fit for abstraction here, given the fact that the vendor compilers does not run in kernel. That is breaking your model.
Quoted 10 lines
kernel process - which is ironically the same thing we are going through here ;->
cheers,
jamalQuoted 4 lines
Quoted 4 lines
cheers,
jamal
Jamal Hadi Salim
maintainerQuoted 64 lines · Jiri Pirko
Quoted 62 lines · Tue, Nov 21, 2023 at 04:21:44PM CET, [email protected] wrote:
Quoted 60 lines · Jiri Pirko
Quoted 47 lines · Tue, Nov 21, 2023 at 02:47:40PM CET, [email protected] wrote:
Quoted 46 lines · Jiri Pirko
Quoted 5 lines · Mon, Nov 20, 2023 at 11:56:50PM CET, [email protected] wrote:
Quoted 4 lines · Daniel Borkmann
Quoted 2 lines · Jamal Hadi Salim
Quoted 1 line · Jiri Pirko
Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:
[...]
Quoted 24 lines
Quoted 10 lines
tc BPF and XDP already have widely used infrastructure and can be developed against libbpf or other user space libraries for a user space control plane. With 'control plane' you refer here to the tc / netlink shim you've built, but looking at the tc command line examples, this doesn't really provide a good user experience (you call it p4 but people load bpf obj files). If the expectation is that an operator should run tc commands, then neither it's a nice experience for p4 nor for BPF folks. From a BPF PoV, we moved over to
bpf_mprogand plan to also extend this for XDP to have a common look and feel wrt networking for developers. Why can't this be reused?The filter loading which loads the program is considered pipeline instantiation - consider it as "provisioning" more than "control" which runs at runtime. "control" is purely netlink based. The iproute2 code we use links libbpf for example for the filter. If we can achieve the same with
bpf_mprogthen sure - we just dont want to loose functionality though. off top of my head, some sample space:
- we could have multiple pipelines with different priorities (which tc provides to us) - and each pipeline may have its own logic with many tables etc (and the choice to iterate the next one is essentially encoded in the tc action codes)
- we use tc block to map groups of ports (which i dont think bpf has internal access of)Quoted 3 lines
In regards to usability: no i dont expect someone doing things at scale to use command line tc. The APIs are via netlink. But the tc cli is must for the rest of the masses per our traditions. Also i really
I don't follow. You repeatedly mention "the must of the traditional tc cli", but what of the existing traditional cli you use for p4tc? If I look at the examples, pretty much everything looks new to me. Example:
tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1Quoted 6 lines
Quoted 3 lines
This is just TC/RTnetlink used as a channel to pass new things over. If that is the case, what's traditional here?
What is not traditional about it?
Okay, so in that case, the following example communitating with userspace deamon using imaginary "p4ctrl" app is equally traditional:
$ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1
Quoted 7 lines
Quoted 4 lines
Huh? Thats just an application - classical tc which part of iproute2 that is sending to the kernel, no different than "tc flower.." Where do you get the "userspace" daemon part? Yes, you can write a daemon but it will use the same APIs as tc.
Okay, so which part is the "tradition"?
Provides tooling via tc cli that _everyone_ in the tc world is familiar with - which uses the same syntax as other tc extensions do, same expectations (eg events, request responses, familiar commands for dumping, flushing etc). Basically someone familiar with tc will pick this up and operate it very quickly and would have an easier time debugging it.
There are caveats - as will be with all new classifiers - but those are within reason.
Quoted 49 lines
Quoted 49 lines
Quoted 32 lines
Quoted 32 lines
Quoted 31 lines
Quoted 15 lines
didnt even want to use ebpf at all for operator experience reasons - it requires a compilation of the code and an extra loading compared to what our original u32/pedit code offered.
Quoted 7 lines
I don't quite follow why not most of this could be implemented entirely in user space without the detour of this and you would provide a developer library which could then be integrated into a p4 runtime/frontend? This way users never interface with ebpf parts nor tc given they also shouldn't have to - it's an implementation detail. This is what John was also pointing out earlier.
Quoted 8 lines
Netlink is the API. We will provide a library for object manipulation which abstracts away the need to know netlink. Someone who for their own reasons wants to use p4runtime or TDI could write on top of this. I would not design a kernel interface to just meet p4runtime (we already have TDI which came later which does things differently). So i expect us to support both those two. And if i was to do something on SDN that was more robust i would write my own that still uses these netlink interfaces.
Actually, what Daniel says about the p4 library used as a backend to p4 frontend is pretty much aligned what I claimed on the p4 calls couple of times. If you have this p4 userspace tooling, it is easy for offloads to replace the backed by vendor-specific library which allows p4 offload suitable for all vendors (your plan of p4tc offload does not work well for our hw, as we repeatedly claimed).
Quoted 8 lines
Quoted 6 lines
That's you - NVIDIA. You have chosen a path away from the kernel towards DOCA. I understand NVIDIA's frustration with dealing with upstream process (which has been cited to me as a good reason for DOCA) but please dont impose these values and your politics on other
vendors(Intel, AMD for example)who are more than willing to invest into making the kernel interfaces the path forward. Your choice.No, you are missing the point. This has nothing to do with DOCA.
Right Jiri ;->
Quoted 5 lines
This
has to do with the simple limitation of your offload assuming there are no runtime changes in the compiled pipeline. For Intel, maybe they aren't, and it's a good fit for them. All I say is, that it is not the good fit for everyone.
Quoted 7 lines
Quoted 2 lines
a) it is not part of the P4 spec to dynamically make changes to the datapath pipeline after it is create and we are discussing a P4
Isn't this up to the implementation? I mean from the p4 perspective, everything is static. Hw might need to reshuffle the pipeline internally during rule insertion/remove in order to optimize the layout.
But do note: the focus here is on P4 (hence the name P4TC).
Quoted 7 lines
Quoted 7 lines
implementation not an extension that would add more value b) We are more than happy to add extensions in the future to accomodate for features but first
_P4spec_must be met c) we had longer discussions with Matty, Khalid and the Rice folks who wrote a paper on that topic which you probably didnt attend and everything that needs to be done can be from user space today for all those optimizations.
Quoted 8 lines
Quoted 4 lines
Conclusion is: For what you need to do (which i dont believe is a limitation in your hardware rather a design decision on your part) run your user space daemon, do optimizations and update the datapath. Everybody is happy.
Should the userspace daemon listen on inserted rules to be offloade over netlink?
I mean you could if you wanted to given this is just traditional netlink which emits events (with some filtering when we integrate the filter approach). But why?
Quoted 36 lines
Quoted 36 lines
Quoted 36 lines
Quoted 16 lines
Nobody is stopping you from offering your customers proprietary solutions which include a specific ebpf approach alongside DOCA. We believe that a singular interface regardless of the vendor is the right way forward. IMHO, this siloing that unfortunately is also added by eBPF being a double edged sword is not good for the community.
Quoted 8 lines
As I also said on the p4 call couple of times, I don't see the kernel as the correct place to do the p4 abstractions. Why don't you do it in userspace and give vendors possiblity to have p4 backends with compilers, runtime optimizations etc in userspace, talking to the HW in the vendor-suitable way too. Then the SW implementation could be easily eBPF and the main reason (I believe) why you need to have this is TC (offload) is then void.
Quoted 4 lines
Quoted 2 lines
The "everyone wants to use TC/netlink" claim does not seem correct to me. Why not to have one Linux p4 solution that fits everyones needs?
You mean more fitting to the DOCA world? no, because iam a kernel
Again, this has 0 relation to DOCA.
Quoted 1 line
first person and kernel interfaces are good for everyone.
Yeah, not really. Not always the kernel is the right answer. Your/Intel plan to handle the offload by:
1) abuse devlink to flash p4 binary
2) parse the binary in kernel to match to the table ids of rules coming from p4tcndo_setup_tc
3) abuse devlink to flash p4 binary for tc-flower
4) parse the binary in kernel to match to the table ids of rules coming from tc-flowerndo_setup_tc
is really something that is making me a little bit nauseous.
Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
If you don't have a feasible plan to do the offload, p4tc does not make sense to me to be honest.
You mean if there's no plan to match your (NVIDIA?) point of view. For #1 - how's this different from DDP? Wasnt that your suggestion to
I doubt that. Any flashing-blob-parsing-in-kernel is something I'm opposed to from day 1.
Oh well - it is in the kernel and it works fine tbh.
Quoted 7 lines
Quoted 2 lines
begin with? For #2 Nobody is proposing to do anything of the sort. The ndo is passed IDs for the objects and associated contents. For #3+#4
During offload, you need to parse the blob in driver to be able to match the ids with blob entities. That was presented by you/Intel in the past IIRC.
You are correct - in case of offload the netlink IDs will have to be authenticated against what the hardware can accept, but the devlink flash use i believe was from you as a compromise.
Quoted 14 lines
Quoted 3 lines
tc flower thing has nothing to do with P4TC that was just some random proposal someone made seeing if they could ride on top of P4TC.
Yeah, it's not yet merged and already mentally used for abuse. I love that :)
Quoted 6 lines
Besides this nobody really has to satisfy your point of view - like i said earlier feel free to provide proprietary solutions. From a consumer perspective I would not want to deal with 4 different vendors with 4 different proprietary approaches. The kernel is the unifying part. You seemed happier with tc flower just not with the
Quoted 7 lines
Yeah, that is my point, why the unifying part can't be a userspace daemon/library with multiple backends (p4tc, bpf, vendorX, vendorY, ..)?
I just don't see the kernel as a good fit for abstraction here, given the fact that the vendor compilers does not run in kernel. That is breaking your model.
Jiri - we want to support P4, first. Like you said the P4 pipeline, once installed is static.
P4 doesnt allow dynamic update of the pipeline. For example, once you say "here are my 14 tables and their associated actions and here's how the pipeline main control (on how to iterate the tables etc) is going to be" and after you instantiate/activate that pipeline, you dont go back 5 minutes later and say "sorry, please introduce table 15, which i want you to walk to after you visit table 3 if metadata foo is 5" or "shoot, let's change that table 5 to be exact instead of LPM". It's not anywhere in the spec.
That doesnt mean it is not useful thing to have - but it is an invention that has _nothing to do with the P4 spec_; so saying a P4 implementation must support it is a bit out of scope and there are vendors with hardware who support P4 today that dont need any of this. In my opinion that is a feature that could be added later out of necessity (there is some good niche value in being able to add some "dynamicism" to any pipeline) and influence the P4 standards on why it is needed.
It should be doable today in a brute force way (this is just one suggestion that came to me when Rice University/Nvidia presented[1]); i am sure there are other approaches and the idea is by no means proven.
1) User space Creates/compiles/Adds/activate your program that has 14 tables at tc prio X chain Y
2) a) 5 minutes later user space decides it wants to change and add table 3 after table 15, visited when metadata foo=5
b) your compiler in user space compiles a brand new program which
satisfies #2a (how this program was authored is out of scope of discussion)
c) user space adds the new program at tc prio X+1 chain Y or another chain Z
d) user space delete tc prio X chain Y (and make sure your packets
entry point is whatever #c is)
cheers,
jamal
[1] https://www.cs.rice.edu/~eugeneng/papers/SIGCOMM23-Pipeleon.pdf
Quoted 11 lines
Quoted 11 lines
kernel process - which is ironically the same thing we are going through here ;->
cheers,
jamalQuoted 4 lines
Quoted 4 lines
cheers,
jamal
Jiri Pirko
maintainerQuoted 73 lines · Wed, Nov 22, 2023 at 04:14:02PM CET, [email protected] wrote:
Quoted 64 lines · Jiri Pirko
Quoted 62 lines · Tue, Nov 21, 2023 at 04:21:44PM CET, [email protected] wrote:
Quoted 60 lines · Jiri Pirko
Quoted 47 lines · Tue, Nov 21, 2023 at 02:47:40PM CET, [email protected] wrote:
Quoted 46 lines · Jiri Pirko
Quoted 5 lines · Mon, Nov 20, 2023 at 11:56:50PM CET, [email protected] wrote:
Quoted 4 lines · Daniel Borkmann
Quoted 2 lines · Jamal Hadi Salim
Quoted 1 line · Jiri Pirko
Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:
[...]
Quoted 24 lines
Quoted 10 lines
tc BPF and XDP already have widely used infrastructure and can be developed against libbpf or other user space libraries for a user space control plane. With 'control plane' you refer here to the tc / netlink shim you've built, but looking at the tc command line examples, this doesn't really provide a good user experience (you call it p4 but people load bpf obj files). If the expectation is that an operator should run tc commands, then neither it's a nice experience for p4 nor for BPF folks. From a BPF PoV, we moved over to
bpf_mprogand plan to also extend this for XDP to have a common look and feel wrt networking for developers. Why can't this be reused?The filter loading which loads the program is considered pipeline instantiation - consider it as "provisioning" more than "control" which runs at runtime. "control" is purely netlink based. The iproute2 code we use links libbpf for example for the filter. If we can achieve the same with
bpf_mprogthen sure - we just dont want to loose functionality though. off top of my head, some sample space:
- we could have multiple pipelines with different priorities (which tc provides to us) - and each pipeline may have its own logic with many tables etc (and the choice to iterate the next one is essentially encoded in the tc action codes)
- we use tc block to map groups of ports (which i dont think bpf has internal access of)Quoted 3 lines
In regards to usability: no i dont expect someone doing things at scale to use command line tc. The APIs are via netlink. But the tc cli is must for the rest of the masses per our traditions. Also i really
I don't follow. You repeatedly mention "the must of the traditional tc cli", but what of the existing traditional cli you use for p4tc? If I look at the examples, pretty much everything looks new to me. Example:
tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1Quoted 6 lines
Quoted 3 lines
This is just TC/RTnetlink used as a channel to pass new things over. If that is the case, what's traditional here?
What is not traditional about it?
Okay, so in that case, the following example communitating with userspace deamon using imaginary "p4ctrl" app is equally traditional:
$ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1Quoted 7 lines
Quoted 4 lines
Huh? Thats just an application - classical tc which part of iproute2 that is sending to the kernel, no different than "tc flower.." Where do you get the "userspace" daemon part? Yes, you can write a daemon but it will use the same APIs as tc.
Okay, so which part is the "tradition"?
Quoted 8 lines
Provides tooling via tc cli that _everyone_ in the tc world is familiar with - which uses the same syntax as other tc extensions do, same expectations (eg events, request responses, familiar commands for dumping, flushing etc). Basically someone familiar with tc will pick this up and operate it very quickly and would have an easier time debugging it.
There are caveats - as will be with all new classifiers - but those are within reason.
Okay, so syntax familiarity wise, what's the difference between following 2 approaches:
$ tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \
action send_to_port param port eno1
$ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \
action send_to_port param port eno1
?Quoted 72 lines
Quoted 50 lines
Quoted 50 lines
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines
Quoted 16 lines
didnt even want to use ebpf at all for operator experience reasons - it requires a compilation of the code and an extra loading compared to what our original u32/pedit code offered.
Quoted 7 lines
I don't quite follow why not most of this could be implemented entirely in user space without the detour of this and you would provide a developer library which could then be integrated into a p4 runtime/frontend? This way users never interface with ebpf parts nor tc given they also shouldn't have to - it's an implementation detail. This is what John was also pointing out earlier.
Quoted 8 lines
Netlink is the API. We will provide a library for object manipulation which abstracts away the need to know netlink. Someone who for their own reasons wants to use p4runtime or TDI could write on top of this. I would not design a kernel interface to just meet p4runtime (we already have TDI which came later which does things differently). So i expect us to support both those two. And if i was to do something on SDN that was more robust i would write my own that still uses these netlink interfaces.
Actually, what Daniel says about the p4 library used as a backend to p4 frontend is pretty much aligned what I claimed on the p4 calls couple of times. If you have this p4 userspace tooling, it is easy for offloads to replace the backed by vendor-specific library which allows p4 offload suitable for all vendors (your plan of p4tc offload does not work well for our hw, as we repeatedly claimed).
Quoted 8 lines
Quoted 6 lines
That's you - NVIDIA. You have chosen a path away from the kernel towards DOCA. I understand NVIDIA's frustration with dealing with upstream process (which has been cited to me as a good reason for DOCA) but please dont impose these values and your politics on other
vendors(Intel, AMD for example)who are more than willing to invest into making the kernel interfaces the path forward. Your choice.No, you are missing the point. This has nothing to do with DOCA.
Right Jiri ;->
Quoted 5 lines
This
has to do with the simple limitation of your offload assuming there are no runtime changes in the compiled pipeline. For Intel, maybe they aren't, and it's a good fit for them. All I say is, that it is not the good fit for everyone.Quoted 7 lines
Quoted 2 lines
a) it is not part of the P4 spec to dynamically make changes to the datapath pipeline after it is create and we are discussing a P4
Isn't this up to the implementation? I mean from the p4 perspective, everything is static. Hw might need to reshuffle the pipeline internally during rule insertion/remove in order to optimize the layout.
But do note: the focus here is on P4 (hence the name P4TC).
Quoted 12 lines
Quoted 11 lines
implementation not an extension that would add more value b) We are more than happy to add extensions in the future to accomodate for features but first
_P4spec_must be met c) we had longer discussions with Matty, Khalid and the Rice folks who wrote a paper on that topic which you probably didnt attend and everything that needs to be done can be from user space today for all those optimizations.Conclusion is: For what you need to do (which i dont believe is a limitation in your hardware rather a design decision on your part) run your user space daemon, do optimizations and update the datapath. Everybody is happy.
Quoted 7 lines
Quoted 3 lines
Should the userspace daemon listen on inserted rules to be offloade over netlink?
I mean you could if you wanted to given this is just traditional netlink which emits events (with some filtering when we integrate the filter approach). But why?
Nevermind.
Quoted 53 lines
Quoted 37 lines
Quoted 37 lines
Quoted 37 lines
Quoted 17 lines
Nobody is stopping you from offering your customers proprietary solutions which include a specific ebpf approach alongside DOCA. We believe that a singular interface regardless of the vendor is the right way forward. IMHO, this siloing that unfortunately is also added by eBPF being a double edged sword is not good for the community.
Quoted 8 lines
As I also said on the p4 call couple of times, I don't see the kernel as the correct place to do the p4 abstractions. Why don't you do it in userspace and give vendors possiblity to have p4 backends with compilers, runtime optimizations etc in userspace, talking to the HW in the vendor-suitable way too. Then the SW implementation could be easily eBPF and the main reason (I believe) why you need to have this is TC (offload) is then void.
Quoted 4 lines
Quoted 2 lines
The "everyone wants to use TC/netlink" claim does not seem correct to me. Why not to have one Linux p4 solution that fits everyones needs?
You mean more fitting to the DOCA world? no, because iam a kernel
Again, this has 0 relation to DOCA.
Quoted 1 line
first person and kernel interfaces are good for everyone.
Yeah, not really. Not always the kernel is the right answer. Your/Intel plan to handle the offload by:
1) abuse devlink to flash p4 binary
2) parse the binary in kernel to match to the table ids of rules coming from p4tcndo_setup_tc
3) abuse devlink to flash p4 binary for tc-flower
4) parse the binary in kernel to match to the table ids of rules coming from tc-flowerndo_setup_tc
is really something that is making me a little bit nauseous.Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
If you don't have a feasible plan to do the offload, p4tc does not make sense to me to be honest.
You mean if there's no plan to match your (NVIDIA?) point of view. For #1 - how's this different from DDP? Wasnt that your suggestion to
I doubt that. Any flashing-blob-parsing-in-kernel is something I'm opposed to from day 1.
Oh well - it is in the kernel and it works fine tbh.
Quoted 3 lines
Quoted 2 lines
begin with? For #2 Nobody is proposing to do anything of the sort. The ndo is passed IDs for the objects and associated contents. For #3+#4
Quoted 8 lines
Quoted 4 lines
During offload, you need to parse the blob in driver to be able to match the ids with blob entities. That was presented by you/Intel in the past IIRC.
You are correct - in case of offload the netlink IDs will have to be authenticated against what the hardware can accept, but the devlink flash use i believe was from you as a compromise.
Definitelly not. I'm against devlink abuse for this from day 1.
Quoted 23 lines
Quoted 15 lines
Quoted 4 lines
tc flower thing has nothing to do with P4TC that was just some random proposal someone made seeing if they could ride on top of P4TC.
Yeah, it's not yet merged and already mentally used for abuse. I love that :)
Quoted 6 lines
Besides this nobody really has to satisfy your point of view - like i said earlier feel free to provide proprietary solutions. From a consumer perspective I would not want to deal with 4 different vendors with 4 different proprietary approaches. The kernel is the unifying part. You seemed happier with tc flower just not with the
Quoted 7 lines
Yeah, that is my point, why the unifying part can't be a userspace daemon/library with multiple backends (p4tc, bpf, vendorX, vendorY, ..)?
I just don't see the kernel as a good fit for abstraction here, given the fact that the vendor compilers does not run in kernel. That is breaking your model.
Quoted 14 lines
Jiri - we want to support P4, first. Like you said the P4 pipeline, once installed is static.
P4 doesnt allow dynamic update of the pipeline. For example, once you say "here are my 14 tables and their associated actions and here's how the pipeline main control (on how to iterate the tables etc) is going to be" and after you instantiate/activate that pipeline, you dont go back 5 minutes later and say "sorry, please introduce table 15, which i want you to walk to after you visit table 3 if metadata foo is 5" or "shoot, let's change that table 5 to be exact instead of LPM". It's not anywhere in the spec.
That doesnt mean it is not useful thing to have - but it is an invention that has_nothingto do with the P4spec_; so saying a P4 implementation must support it is a bit out of scope and there are vendors with hardware who support P4 today that dont need any of this.
I'm not talking about the spec. I'm talking about the offload implemetation, the offload compiler the offload runtime manager. You don't have those in kernel. That is the issue. The runtime manager is the one to decide and reshuffle the hw internals. Again, this has nothing to do with p4 frontend. This is offload implementation.
And that is why I believe your p4 kernel implementation is unoffloadable. And if it is unoffloadable, do we really need it? IDK.
Quoted 9 lines
In my opinion that is a feature that could be added later out of necessity (there is some good niche value in being able to add some "dynamicism" to any pipeline) and influence the P4 standards on why it is needed.
It should be doable today in a brute force way (this is just one suggestion that came to me when Rice University/Nvidia presented[1]); i am sure there are other approaches and the idea is by no means proven.
Quoted 10 lines
1) User space Creates/compiles/Adds/activate your program that has 14 tables at tc prio X chain Y
2) a) 5 minutes later user space decides it wants to change and add table 3 after table 15, visited when metadata foo=5
b) your compiler in user space compiles a brand new program which
satisfies #2a (how this program was authored is out of scope of discussion)
c) user space adds the new program at tc prio X+1 chain Y or another chain Z
d) user space delete tc prio X chain Y (and make sure your packets
entry point is whatever #c is)
I never suggested anything like what you describe. I'm not sure why you think so.
Quoted 17 lines
cheers,
jamal[1] https://www.cs.rice.edu/~eugeneng/papers/SIGCOMM23-Pipeleon.pdf
Quoted 11 lines
Quoted 11 lines
kernel process - which is ironically the same thing we are going through here ;->
cheers,
jamalQuoted 4 lines
Quoted 4 lines
cheers,
jamal
Quoted 278 lines · Jiri Pirko
Quoted 73 lines · Wed, Nov 22, 2023 at 04:14:02PM CET, [email protected] wrote:
Quoted 64 lines · Jiri Pirko
Quoted 62 lines · Tue, Nov 21, 2023 at 04:21:44PM CET, [email protected] wrote:
Quoted 60 lines · Jiri Pirko
Quoted 47 lines · Tue, Nov 21, 2023 at 02:47:40PM CET, [email protected] wrote:
Quoted 46 lines · Jiri Pirko
Quoted 5 lines · Mon, Nov 20, 2023 at 11:56:50PM CET, [email protected] wrote:
Quoted 4 lines · Daniel Borkmann
Quoted 2 lines · Jamal Hadi Salim
Quoted 1 line · Jiri Pirko
Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:
[...]
Quoted 24 lines
Quoted 10 lines
tc BPF and XDP already have widely used infrastructure and can be developed against libbpf or other user space libraries for a user space control plane. With 'control plane' you refer here to the tc / netlink shim you've built, but looking at the tc command line examples, this doesn't really provide a good user experience (you call it p4 but people load bpf obj files). If the expectation is that an operator should run tc commands, then neither it's a nice experience for p4 nor for BPF folks. From a BPF PoV, we moved over to
bpf_mprogand plan to also extend this for XDP to have a common look and feel wrt networking for developers. Why can't this be reused?The filter loading which loads the program is considered pipeline instantiation - consider it as "provisioning" more than "control" which runs at runtime. "control" is purely netlink based. The iproute2 code we use links libbpf for example for the filter. If we can achieve the same with
bpf_mprogthen sure - we just dont want to loose functionality though. off top of my head, some sample space:
- we could have multiple pipelines with different priorities (which tc provides to us) - and each pipeline may have its own logic with many tables etc (and the choice to iterate the next one is essentially encoded in the tc action codes)
- we use tc block to map groups of ports (which i dont think bpf has internal access of)Quoted 3 lines
In regards to usability: no i dont expect someone doing things at scale to use command line tc. The APIs are via netlink. But the tc cli is must for the rest of the masses per our traditions. Also i really
I don't follow. You repeatedly mention "the must of the traditional tc cli", but what of the existing traditional cli you use for p4tc? If I look at the examples, pretty much everything looks new to me. Example:
tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1Quoted 6 lines
Quoted 3 lines
This is just TC/RTnetlink used as a channel to pass new things over. If that is the case, what's traditional here?
What is not traditional about it?
Okay, so in that case, the following example communitating with userspace deamon using imaginary "p4ctrl" app is equally traditional:
$ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1Quoted 7 lines
Quoted 4 lines
Huh? Thats just an application - classical tc which part of iproute2 that is sending to the kernel, no different than "tc flower.." Where do you get the "userspace" daemon part? Yes, you can write a daemon but it will use the same APIs as tc.
Okay, so which part is the "tradition"?
Quoted 8 lines
Provides tooling via tc cli that _everyone_ in the tc world is familiar with - which uses the same syntax as other tc extensions do, same expectations (eg events, request responses, familiar commands for dumping, flushing etc). Basically someone familiar with tc will pick this up and operate it very quickly and would have an easier time debugging it.
There are caveats - as will be with all new classifiers - but those are within reason.Okay, so syntax familiarity wise, what's the difference between following 2 approaches:
$ tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1 $ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1 ?Quoted 72 lines
Quoted 50 lines
Quoted 50 lines
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines
Quoted 16 lines
didnt even want to use ebpf at all for operator experience reasons - it requires a compilation of the code and an extra loading compared to what our original u32/pedit code offered.
Quoted 7 lines
I don't quite follow why not most of this could be implemented entirely in user space without the detour of this and you would provide a developer library which could then be integrated into a p4 runtime/frontend? This way users never interface with ebpf parts nor tc given they also shouldn't have to - it's an implementation detail. This is what John was also pointing out earlier.
Quoted 8 lines
Netlink is the API. We will provide a library for object manipulation which abstracts away the need to know netlink. Someone who for their own reasons wants to use p4runtime or TDI could write on top of this. I would not design a kernel interface to just meet p4runtime (we already have TDI which came later which does things differently). So i expect us to support both those two. And if i was to do something on SDN that was more robust i would write my own that still uses these netlink interfaces.
Actually, what Daniel says about the p4 library used as a backend to p4 frontend is pretty much aligned what I claimed on the p4 calls couple of times. If you have this p4 userspace tooling, it is easy for offloads to replace the backed by vendor-specific library which allows p4 offload suitable for all vendors (your plan of p4tc offload does not work well for our hw, as we repeatedly claimed).
Quoted 8 lines
Quoted 6 lines
That's you - NVIDIA. You have chosen a path away from the kernel towards DOCA. I understand NVIDIA's frustration with dealing with upstream process (which has been cited to me as a good reason for DOCA) but please dont impose these values and your politics on other
vendors(Intel, AMD for example)who are more than willing to invest into making the kernel interfaces the path forward. Your choice.No, you are missing the point. This has nothing to do with DOCA.
Right Jiri ;->
Quoted 5 lines
This
has to do with the simple limitation of your offload assuming there are no runtime changes in the compiled pipeline. For Intel, maybe they aren't, and it's a good fit for them. All I say is, that it is not the good fit for everyone.Quoted 7 lines
Quoted 2 lines
a) it is not part of the P4 spec to dynamically make changes to the datapath pipeline after it is create and we are discussing a P4
Isn't this up to the implementation? I mean from the p4 perspective, everything is static. Hw might need to reshuffle the pipeline internally during rule insertion/remove in order to optimize the layout.
But do note: the focus here is on P4 (hence the name P4TC).
Quoted 12 lines
Quoted 11 lines
implementation not an extension that would add more value b) We are more than happy to add extensions in the future to accomodate for features but first
_P4spec_must be met c) we had longer discussions with Matty, Khalid and the Rice folks who wrote a paper on that topic which you probably didnt attend and everything that needs to be done can be from user space today for all those optimizations.Conclusion is: For what you need to do (which i dont believe is a limitation in your hardware rather a design decision on your part) run your user space daemon, do optimizations and update the datapath. Everybody is happy.
Quoted 7 lines
Quoted 3 lines
Should the userspace daemon listen on inserted rules to be offloade over netlink?
I mean you could if you wanted to given this is just traditional netlink which emits events (with some filtering when we integrate the filter approach). But why?
Nevermind.
Quoted 53 lines
Quoted 37 lines
Quoted 37 lines
Quoted 37 lines
Quoted 17 lines
Nobody is stopping you from offering your customers proprietary solutions which include a specific ebpf approach alongside DOCA. We believe that a singular interface regardless of the vendor is the right way forward. IMHO, this siloing that unfortunately is also added by eBPF being a double edged sword is not good for the community.
Quoted 8 lines
As I also said on the p4 call couple of times, I don't see the kernel as the correct place to do the p4 abstractions. Why don't you do it in userspace and give vendors possiblity to have p4 backends with compilers, runtime optimizations etc in userspace, talking to the HW in the vendor-suitable way too. Then the SW implementation could be easily eBPF and the main reason (I believe) why you need to have this is TC (offload) is then void.
Quoted 4 lines
Quoted 2 lines
The "everyone wants to use TC/netlink" claim does not seem correct to me. Why not to have one Linux p4 solution that fits everyones needs?
You mean more fitting to the DOCA world? no, because iam a kernel
Again, this has 0 relation to DOCA.
Quoted 1 line
first person and kernel interfaces are good for everyone.
Yeah, not really. Not always the kernel is the right answer. Your/Intel plan to handle the offload by:
1) abuse devlink to flash p4 binary
2) parse the binary in kernel to match to the table ids of rules coming from p4tcndo_setup_tc
3) abuse devlink to flash p4 binary for tc-flower
4) parse the binary in kernel to match to the table ids of rules coming from tc-flowerndo_setup_tc
is really something that is making me a little bit nauseous.Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
If you don't have a feasible plan to do the offload, p4tc does not make sense to me to be honest.
You mean if there's no plan to match your (NVIDIA?) point of view. For #1 - how's this different from DDP? Wasnt that your suggestion to
I doubt that. Any flashing-blob-parsing-in-kernel is something I'm opposed to from day 1.
Oh well - it is in the kernel and it works fine tbh.
Quoted 3 lines
Quoted 2 lines
begin with? For #2 Nobody is proposing to do anything of the sort. The ndo is passed IDs for the objects and associated contents. For #3+#4
Quoted 8 lines
Quoted 4 lines
During offload, you need to parse the blob in driver to be able to match the ids with blob entities. That was presented by you/Intel in the past IIRC.
You are correct - in case of offload the netlink IDs will have to be authenticated against what the hardware can accept, but the devlink flash use i believe was from you as a compromise.
Definitelly not. I'm against devlink abuse for this from day 1.
Quoted 23 lines
Quoted 15 lines
Quoted 4 lines
tc flower thing has nothing to do with P4TC that was just some random proposal someone made seeing if they could ride on top of P4TC.
Yeah, it's not yet merged and already mentally used for abuse. I love that :)
Quoted 6 lines
Besides this nobody really has to satisfy your point of view - like i said earlier feel free to provide proprietary solutions. From a consumer perspective I would not want to deal with 4 different vendors with 4 different proprietary approaches. The kernel is the unifying part. You seemed happier with tc flower just not with the
Quoted 7 lines
Yeah, that is my point, why the unifying part can't be a userspace daemon/library with multiple backends (p4tc, bpf, vendorX, vendorY, ..)?
I just don't see the kernel as a good fit for abstraction here, given the fact that the vendor compilers does not run in kernel. That is breaking your model.
Quoted 14 lines
Jiri - we want to support P4, first. Like you said the P4 pipeline, once installed is static.
P4 doesnt allow dynamic update of the pipeline. For example, once you say "here are my 14 tables and their associated actions and here's how the pipeline main control (on how to iterate the tables etc) is going to be" and after you instantiate/activate that pipeline, you dont go back 5 minutes later and say "sorry, please introduce table 15, which i want you to walk to after you visit table 3 if metadata foo is 5" or "shoot, let's change that table 5 to be exact instead of LPM". It's not anywhere in the spec.
That doesnt mean it is not useful thing to have - but it is an invention that has_nothingto do with the P4spec_; so saying a P4 implementation must support it is a bit out of scope and there are vendors with hardware who support P4 today that dont need any of this.
Quoted 8 lines
I'm not talking about the spec. I'm talking about the offload implemetation, the offload compiler the offload runtime manager. You don't have those in kernel. That is the issue. The runtime manager is the one to decide and reshuffle the hw internals. Again, this has nothing to do with p4 frontend. This is offload implementation.
And that is why I believe your p4 kernel implementation is unoffloadable. And if it is unoffloadable, do we really need it? IDK.
And my point is we already have a way to do software P4 implementation in BPF so I don't see the need for yet another mechanism. And if P4tc is not amenable to hardware offload then when we need a P4 hardware offload then what? We write another P4TC-HW?
My opinion if we push a DSL into the kernel (which I also sort of think is not a great idea) then it should at least support offloads from the start. I know P4 can be used for software, but really its main value is hardware offlaod here. Even the name PNA, Portable NIC Architecture, implies its about NICs. If it was software focused portability wouldn't matter a general purpose CPU can emulate almost any architecture you would like.
Quoted 43 lines
Quoted 11 lines
In my opinion that is a feature that could be added later out of necessity (there is some good niche value in being able to add some "dynamicism" to any pipeline) and influence the P4 standards on why it is needed.
It should be doable today in a brute force way (this is just one suggestion that came to me when Rice University/Nvidia presented[1]); i am sure there are other approaches and the idea is by no means proven.Quoted 10 lines
1) User space Creates/compiles/Adds/activate your program that has 14 tables at tc prio X chain Y
2) a) 5 minutes later user space decides it wants to change and add table 3 after table 15, visited when metadata foo=5
b) your compiler in user space compiles a brand new program which
satisfies #2a (how this program was authored is out of scope of discussion)
c) user space adds the new program at tc prio X+1 chain Y or another chain Z
d) user space delete tc prio X chain Y (and make sure your packets
entry point is whatever #c is)I never suggested anything like what you describe. I'm not sure why you think so.
Quoted 17 lines
cheers,
jamal[1] https://www.cs.rice.edu/~eugeneng/papers/SIGCOMM23-Pipeleon.pdf
Quoted 11 lines
Quoted 11 lines
kernel process - which is ironically the same thing we are going through here ;->
cheers,
jamalQuoted 4 lines
Quoted 4 lines
cheers,
jamal
Jamal Hadi Salim
maintainerQuoted 279 lines · Jiri Pirko
Quoted 73 lines · Wed, Nov 22, 2023 at 04:14:02PM CET, [email protected] wrote:
Quoted 64 lines · Jiri Pirko
Quoted 62 lines · Tue, Nov 21, 2023 at 04:21:44PM CET, [email protected] wrote:
Quoted 60 lines · Jiri Pirko
Quoted 47 lines · Tue, Nov 21, 2023 at 02:47:40PM CET, [email protected] wrote:
Quoted 46 lines · Jiri Pirko
Quoted 5 lines · Mon, Nov 20, 2023 at 11:56:50PM CET, [email protected] wrote:
Quoted 4 lines · Daniel Borkmann
Quoted 2 lines · Jamal Hadi Salim
Quoted 1 line · Jiri Pirko
Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:
[...]
Quoted 24 lines
Quoted 10 lines
tc BPF and XDP already have widely used infrastructure and can be developed against libbpf or other user space libraries for a user space control plane. With 'control plane' you refer here to the tc / netlink shim you've built, but looking at the tc command line examples, this doesn't really provide a good user experience (you call it p4 but people load bpf obj files). If the expectation is that an operator should run tc commands, then neither it's a nice experience for p4 nor for BPF folks. From a BPF PoV, we moved over to
bpf_mprogand plan to also extend this for XDP to have a common look and feel wrt networking for developers. Why can't this be reused?The filter loading which loads the program is considered pipeline instantiation - consider it as "provisioning" more than "control" which runs at runtime. "control" is purely netlink based. The iproute2 code we use links libbpf for example for the filter. If we can achieve the same with
bpf_mprogthen sure - we just dont want to loose functionality though. off top of my head, some sample space:
- we could have multiple pipelines with different priorities (which tc provides to us) - and each pipeline may have its own logic with many tables etc (and the choice to iterate the next one is essentially encoded in the tc action codes)
- we use tc block to map groups of ports (which i dont think bpf has internal access of)Quoted 3 lines
In regards to usability: no i dont expect someone doing things at scale to use command line tc. The APIs are via netlink. But the tc cli is must for the rest of the masses per our traditions. Also i really
I don't follow. You repeatedly mention "the must of the traditional tc cli", but what of the existing traditional cli you use for p4tc? If I look at the examples, pretty much everything looks new to me. Example:
tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1Quoted 6 lines
Quoted 3 lines
This is just TC/RTnetlink used as a channel to pass new things over. If that is the case, what's traditional here?
What is not traditional about it?
Okay, so in that case, the following example communitating with userspace deamon using imaginary "p4ctrl" app is equally traditional:
$ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1Quoted 7 lines
Quoted 4 lines
Huh? Thats just an application - classical tc which part of iproute2 that is sending to the kernel, no different than "tc flower.." Where do you get the "userspace" daemon part? Yes, you can write a daemon but it will use the same APIs as tc.
Okay, so which part is the "tradition"?
Quoted 8 lines
Provides tooling via tc cli that _everyone_ in the tc world is familiar with - which uses the same syntax as other tc extensions do, same expectations (eg events, request responses, familiar commands for dumping, flushing etc). Basically someone familiar with tc will pick this up and operate it very quickly and would have an easier time debugging it.
There are caveats - as will be with all new classifiers - but those are within reason.Okay, so syntax familiarity wise, what's the difference between following 2 approaches:
$ tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1 $ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1 ?Quoted 72 lines
Quoted 50 lines
Quoted 50 lines
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines
Quoted 16 lines
didnt even want to use ebpf at all for operator experience reasons - it requires a compilation of the code and an extra loading compared to what our original u32/pedit code offered.
Quoted 7 lines
I don't quite follow why not most of this could be implemented entirely in user space without the detour of this and you would provide a developer library which could then be integrated into a p4 runtime/frontend? This way users never interface with ebpf parts nor tc given they also shouldn't have to - it's an implementation detail. This is what John was also pointing out earlier.
Quoted 8 lines
Netlink is the API. We will provide a library for object manipulation which abstracts away the need to know netlink. Someone who for their own reasons wants to use p4runtime or TDI could write on top of this. I would not design a kernel interface to just meet p4runtime (we already have TDI which came later which does things differently). So i expect us to support both those two. And if i was to do something on SDN that was more robust i would write my own that still uses these netlink interfaces.
Actually, what Daniel says about the p4 library used as a backend to p4 frontend is pretty much aligned what I claimed on the p4 calls couple of times. If you have this p4 userspace tooling, it is easy for offloads to replace the backed by vendor-specific library which allows p4 offload suitable for all vendors (your plan of p4tc offload does not work well for our hw, as we repeatedly claimed).
Quoted 8 lines
Quoted 6 lines
That's you - NVIDIA. You have chosen a path away from the kernel towards DOCA. I understand NVIDIA's frustration with dealing with upstream process (which has been cited to me as a good reason for DOCA) but please dont impose these values and your politics on other
vendors(Intel, AMD for example)who are more than willing to invest into making the kernel interfaces the path forward. Your choice.No, you are missing the point. This has nothing to do with DOCA.
Right Jiri ;->
Quoted 5 lines
This
has to do with the simple limitation of your offload assuming there are no runtime changes in the compiled pipeline. For Intel, maybe they aren't, and it's a good fit for them. All I say is, that it is not the good fit for everyone.Quoted 7 lines
Quoted 2 lines
a) it is not part of the P4 spec to dynamically make changes to the datapath pipeline after it is create and we are discussing a P4
Isn't this up to the implementation? I mean from the p4 perspective, everything is static. Hw might need to reshuffle the pipeline internally during rule insertion/remove in order to optimize the layout.
But do note: the focus here is on P4 (hence the name P4TC).
Quoted 12 lines
Quoted 11 lines
implementation not an extension that would add more value b) We are more than happy to add extensions in the future to accomodate for features but first
_P4spec_must be met c) we had longer discussions with Matty, Khalid and the Rice folks who wrote a paper on that topic which you probably didnt attend and everything that needs to be done can be from user space today for all those optimizations.Conclusion is: For what you need to do (which i dont believe is a limitation in your hardware rather a design decision on your part) run your user space daemon, do optimizations and update the datapath. Everybody is happy.
Quoted 7 lines
Quoted 3 lines
Should the userspace daemon listen on inserted rules to be offloade over netlink?
I mean you could if you wanted to given this is just traditional netlink which emits events (with some filtering when we integrate the filter approach). But why?
Nevermind.
Quoted 53 lines
Quoted 37 lines
Quoted 37 lines
Quoted 37 lines
Quoted 17 lines
Nobody is stopping you from offering your customers proprietary solutions which include a specific ebpf approach alongside DOCA. We believe that a singular interface regardless of the vendor is the right way forward. IMHO, this siloing that unfortunately is also added by eBPF being a double edged sword is not good for the community.
Quoted 8 lines
As I also said on the p4 call couple of times, I don't see the kernel as the correct place to do the p4 abstractions. Why don't you do it in userspace and give vendors possiblity to have p4 backends with compilers, runtime optimizations etc in userspace, talking to the HW in the vendor-suitable way too. Then the SW implementation could be easily eBPF and the main reason (I believe) why you need to have this is TC (offload) is then void.
Quoted 4 lines
Quoted 2 lines
The "everyone wants to use TC/netlink" claim does not seem correct to me. Why not to have one Linux p4 solution that fits everyones needs?
You mean more fitting to the DOCA world? no, because iam a kernel
Again, this has 0 relation to DOCA.
Quoted 1 line
first person and kernel interfaces are good for everyone.
Yeah, not really. Not always the kernel is the right answer. Your/Intel plan to handle the offload by:
1) abuse devlink to flash p4 binary
2) parse the binary in kernel to match to the table ids of rules coming from p4tcndo_setup_tc
3) abuse devlink to flash p4 binary for tc-flower
4) parse the binary in kernel to match to the table ids of rules coming from tc-flowerndo_setup_tc
is really something that is making me a little bit nauseous.Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
If you don't have a feasible plan to do the offload, p4tc does not make sense to me to be honest.
You mean if there's no plan to match your (NVIDIA?) point of view. For #1 - how's this different from DDP? Wasnt that your suggestion to
I doubt that. Any flashing-blob-parsing-in-kernel is something I'm opposed to from day 1.
Oh well - it is in the kernel and it works fine tbh.
Quoted 3 lines
Quoted 2 lines
begin with? For #2 Nobody is proposing to do anything of the sort. The ndo is passed IDs for the objects and associated contents. For #3+#4
Quoted 8 lines
Quoted 4 lines
During offload, you need to parse the blob in driver to be able to match the ids with blob entities. That was presented by you/Intel in the past IIRC.
You are correct - in case of offload the netlink IDs will have to be authenticated against what the hardware can accept, but the devlink flash use i believe was from you as a compromise.
Definitelly not. I'm against devlink abuse for this from day 1.
Quoted 23 lines
Quoted 15 lines
Quoted 4 lines
tc flower thing has nothing to do with P4TC that was just some random proposal someone made seeing if they could ride on top of P4TC.
Yeah, it's not yet merged and already mentally used for abuse. I love that :)
Quoted 6 lines
Besides this nobody really has to satisfy your point of view - like i said earlier feel free to provide proprietary solutions. From a consumer perspective I would not want to deal with 4 different vendors with 4 different proprietary approaches. The kernel is the unifying part. You seemed happier with tc flower just not with the
Quoted 7 lines
Yeah, that is my point, why the unifying part can't be a userspace daemon/library with multiple backends (p4tc, bpf, vendorX, vendorY, ..)?
I just don't see the kernel as a good fit for abstraction here, given the fact that the vendor compilers does not run in kernel. That is breaking your model.
Quoted 14 lines
Jiri - we want to support P4, first. Like you said the P4 pipeline, once installed is static.
P4 doesnt allow dynamic update of the pipeline. For example, once you say "here are my 14 tables and their associated actions and here's how the pipeline main control (on how to iterate the tables etc) is going to be" and after you instantiate/activate that pipeline, you dont go back 5 minutes later and say "sorry, please introduce table 15, which i want you to walk to after you visit table 3 if metadata foo is 5" or "shoot, let's change that table 5 to be exact instead of LPM". It's not anywhere in the spec.
That doesnt mean it is not useful thing to have - but it is an invention that has_nothingto do with the P4spec_; so saying a P4 implementation must support it is a bit out of scope and there are vendors with hardware who support P4 today that dont need any of this.
Quoted 9 lines
I'm not talking about the spec. I'm talking about the offload implemetation, the offload compiler the offload runtime manager. You don't have those in kernel. That is the issue. The runtime manager is the one to decide and reshuffle the hw internals. Again, this has nothing to do with p4 frontend. This is offload implementation.
And that is why I believe your p4 kernel implementation is unoffloadable. And if it is unoffloadable, do we really need it? IDK.
Say what?
It's not offloadable in your hardware, you mean? Because i have beside me here an intel e2000 which offloads just fine (and the AMD folks seem fine too).
If your view is that all these runtime optimization surmount to a compiler in the kernel/driver that is your, well, your view. In my view (and others have said this to you already) the P4C compiler is responsible for resource optimizations. The hardware supports P4, you give it constraints and it knows what to do. At runtime, anything a driver needs to do for resource optimization (resorting, reshuffling etc), that is not a P4 problem - sorry if you have issues in your architecture approach.
Quoted 20 lines
Quoted 9 lines
In my opinion that is a feature that could be added later out of necessity (there is some good niche value in being able to add some "dynamicism" to any pipeline) and influence the P4 standards on why it is needed.
It should be doable today in a brute force way (this is just one suggestion that came to me when Rice University/Nvidia presented[1]); i am sure there are other approaches and the idea is by no means proven.Quoted 10 lines
1) User space Creates/compiles/Adds/activate your program that has 14 tables at tc prio X chain Y
2) a) 5 minutes later user space decides it wants to change and add table 3 after table 15, visited when metadata foo=5
b) your compiler in user space compiles a brand new program which
satisfies #2a (how this program was authored is out of scope of discussion)
c) user space adds the new program at tc prio X+1 chain Y or another chain Z
d) user space delete tc prio X chain Y (and make sure your packets
entry point is whatever #c is)
Quoted 2 lines
I never suggested anything like what you describe. I'm not sure why you think so.
It's the same class of problems - the paper i pointed to (coauthored by Matty and others) has runtime resource optimizations which are tantamount to changing the nature of the pipeline. We may need to profile in the kernel but all those optimizations can be derived in user space using the approach I described.
cheers,
jamal
Quoted 13 lines
Quoted 13 lines
[1] https://www.cs.rice.edu/~eugeneng/papers/SIGCOMM23-Pipeleon.pdf
Quoted 11 lines
Quoted 11 lines
kernel process - which is ironically the same thing we are going through here ;->
cheers,
jamalQuoted 4 lines
Quoted 4 lines
cheers,
jamal
Jiri Pirko
maintainerQuoted 286 lines · Wed, Nov 22, 2023 at 08:35:21PM CET, [email protected] wrote:
Quoted 285 lines · Jiri Pirko
Quoted 73 lines · Wed, Nov 22, 2023 at 04:14:02PM CET, [email protected] wrote:
Quoted 64 lines · Jiri Pirko
Quoted 62 lines · Tue, Nov 21, 2023 at 04:21:44PM CET, [email protected] wrote:
Quoted 60 lines · Jiri Pirko
Quoted 47 lines · Tue, Nov 21, 2023 at 02:47:40PM CET, [email protected] wrote:
Quoted 46 lines · Jiri Pirko
Quoted 5 lines · Mon, Nov 20, 2023 at 11:56:50PM CET, [email protected] wrote:
Quoted 4 lines · Daniel Borkmann
Quoted 2 lines · Jamal Hadi Salim
Quoted 1 line · Jiri Pirko
Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:
[...]
Quoted 24 lines
Quoted 10 lines
tc BPF and XDP already have widely used infrastructure and can be developed against libbpf or other user space libraries for a user space control plane. With 'control plane' you refer here to the tc / netlink shim you've built, but looking at the tc command line examples, this doesn't really provide a good user experience (you call it p4 but people load bpf obj files). If the expectation is that an operator should run tc commands, then neither it's a nice experience for p4 nor for BPF folks. From a BPF PoV, we moved over to
bpf_mprogand plan to also extend this for XDP to have a common look and feel wrt networking for developers. Why can't this be reused?The filter loading which loads the program is considered pipeline instantiation - consider it as "provisioning" more than "control" which runs at runtime. "control" is purely netlink based. The iproute2 code we use links libbpf for example for the filter. If we can achieve the same with
bpf_mprogthen sure - we just dont want to loose functionality though. off top of my head, some sample space:
- we could have multiple pipelines with different priorities (which tc provides to us) - and each pipeline may have its own logic with many tables etc (and the choice to iterate the next one is essentially encoded in the tc action codes)
- we use tc block to map groups of ports (which i dont think bpf has internal access of)Quoted 3 lines
In regards to usability: no i dont expect someone doing things at scale to use command line tc. The APIs are via netlink. But the tc cli is must for the rest of the masses per our traditions. Also i really
I don't follow. You repeatedly mention "the must of the traditional tc cli", but what of the existing traditional cli you use for p4tc? If I look at the examples, pretty much everything looks new to me. Example:
tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1Quoted 6 lines
Quoted 3 lines
This is just TC/RTnetlink used as a channel to pass new things over. If that is the case, what's traditional here?
What is not traditional about it?
Okay, so in that case, the following example communitating with userspace deamon using imaginary "p4ctrl" app is equally traditional:
$ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1Quoted 7 lines
Quoted 4 lines
Huh? Thats just an application - classical tc which part of iproute2 that is sending to the kernel, no different than "tc flower.." Where do you get the "userspace" daemon part? Yes, you can write a daemon but it will use the same APIs as tc.
Okay, so which part is the "tradition"?
Quoted 8 lines
Provides tooling via tc cli that _everyone_ in the tc world is familiar with - which uses the same syntax as other tc extensions do, same expectations (eg events, request responses, familiar commands for dumping, flushing etc). Basically someone familiar with tc will pick this up and operate it very quickly and would have an easier time debugging it.
There are caveats - as will be with all new classifiers - but those are within reason.Okay, so syntax familiarity wise, what's the difference between following 2 approaches:
$ tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1 $ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1 ?Quoted 72 lines
Quoted 50 lines
Quoted 50 lines
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines
Quoted 16 lines
didnt even want to use ebpf at all for operator experience reasons - it requires a compilation of the code and an extra loading compared to what our original u32/pedit code offered.
Quoted 7 lines
I don't quite follow why not most of this could be implemented entirely in user space without the detour of this and you would provide a developer library which could then be integrated into a p4 runtime/frontend? This way users never interface with ebpf parts nor tc given they also shouldn't have to - it's an implementation detail. This is what John was also pointing out earlier.
Quoted 8 lines
Netlink is the API. We will provide a library for object manipulation which abstracts away the need to know netlink. Someone who for their own reasons wants to use p4runtime or TDI could write on top of this. I would not design a kernel interface to just meet p4runtime (we already have TDI which came later which does things differently). So i expect us to support both those two. And if i was to do something on SDN that was more robust i would write my own that still uses these netlink interfaces.
Actually, what Daniel says about the p4 library used as a backend to p4 frontend is pretty much aligned what I claimed on the p4 calls couple of times. If you have this p4 userspace tooling, it is easy for offloads to replace the backed by vendor-specific library which allows p4 offload suitable for all vendors (your plan of p4tc offload does not work well for our hw, as we repeatedly claimed).
Quoted 8 lines
Quoted 6 lines
That's you - NVIDIA. You have chosen a path away from the kernel towards DOCA. I understand NVIDIA's frustration with dealing with upstream process (which has been cited to me as a good reason for DOCA) but please dont impose these values and your politics on other
vendors(Intel, AMD for example)who are more than willing to invest into making the kernel interfaces the path forward. Your choice.No, you are missing the point. This has nothing to do with DOCA.
Right Jiri ;->
Quoted 5 lines
This
has to do with the simple limitation of your offload assuming there are no runtime changes in the compiled pipeline. For Intel, maybe they aren't, and it's a good fit for them. All I say is, that it is not the good fit for everyone.Quoted 7 lines
Quoted 2 lines
a) it is not part of the P4 spec to dynamically make changes to the datapath pipeline after it is create and we are discussing a P4
Isn't this up to the implementation? I mean from the p4 perspective, everything is static. Hw might need to reshuffle the pipeline internally during rule insertion/remove in order to optimize the layout.
But do note: the focus here is on P4 (hence the name P4TC).
Quoted 12 lines
Quoted 11 lines
implementation not an extension that would add more value b) We are more than happy to add extensions in the future to accomodate for features but first
_P4spec_must be met c) we had longer discussions with Matty, Khalid and the Rice folks who wrote a paper on that topic which you probably didnt attend and everything that needs to be done can be from user space today for all those optimizations.Conclusion is: For what you need to do (which i dont believe is a limitation in your hardware rather a design decision on your part) run your user space daemon, do optimizations and update the datapath. Everybody is happy.
Quoted 7 lines
Quoted 3 lines
Should the userspace daemon listen on inserted rules to be offloade over netlink?
I mean you could if you wanted to given this is just traditional netlink which emits events (with some filtering when we integrate the filter approach). But why?
Nevermind.
Quoted 53 lines
Quoted 37 lines
Quoted 37 lines
Quoted 37 lines
Quoted 17 lines
Nobody is stopping you from offering your customers proprietary solutions which include a specific ebpf approach alongside DOCA. We believe that a singular interface regardless of the vendor is the right way forward. IMHO, this siloing that unfortunately is also added by eBPF being a double edged sword is not good for the community.
Quoted 8 lines
As I also said on the p4 call couple of times, I don't see the kernel as the correct place to do the p4 abstractions. Why don't you do it in userspace and give vendors possiblity to have p4 backends with compilers, runtime optimizations etc in userspace, talking to the HW in the vendor-suitable way too. Then the SW implementation could be easily eBPF and the main reason (I believe) why you need to have this is TC (offload) is then void.
Quoted 4 lines
Quoted 2 lines
The "everyone wants to use TC/netlink" claim does not seem correct to me. Why not to have one Linux p4 solution that fits everyones needs?
You mean more fitting to the DOCA world? no, because iam a kernel
Again, this has 0 relation to DOCA.
Quoted 1 line
first person and kernel interfaces are good for everyone.
Yeah, not really. Not always the kernel is the right answer. Your/Intel plan to handle the offload by:
1) abuse devlink to flash p4 binary
2) parse the binary in kernel to match to the table ids of rules coming from p4tcndo_setup_tc
3) abuse devlink to flash p4 binary for tc-flower
4) parse the binary in kernel to match to the table ids of rules coming from tc-flowerndo_setup_tc
is really something that is making me a little bit nauseous.Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
If you don't have a feasible plan to do the offload, p4tc does not make sense to me to be honest.
You mean if there's no plan to match your (NVIDIA?) point of view. For #1 - how's this different from DDP? Wasnt that your suggestion to
I doubt that. Any flashing-blob-parsing-in-kernel is something I'm opposed to from day 1.
Oh well - it is in the kernel and it works fine tbh.
Quoted 3 lines
Quoted 2 lines
begin with? For #2 Nobody is proposing to do anything of the sort. The ndo is passed IDs for the objects and associated contents. For #3+#4
Quoted 8 lines
Quoted 4 lines
During offload, you need to parse the blob in driver to be able to match the ids with blob entities. That was presented by you/Intel in the past IIRC.
You are correct - in case of offload the netlink IDs will have to be authenticated against what the hardware can accept, but the devlink flash use i believe was from you as a compromise.
Definitelly not. I'm against devlink abuse for this from day 1.
Quoted 23 lines
Quoted 15 lines
Quoted 4 lines
tc flower thing has nothing to do with P4TC that was just some random proposal someone made seeing if they could ride on top of P4TC.
Yeah, it's not yet merged and already mentally used for abuse. I love that :)
Quoted 6 lines
Besides this nobody really has to satisfy your point of view - like i said earlier feel free to provide proprietary solutions. From a consumer perspective I would not want to deal with 4 different vendors with 4 different proprietary approaches. The kernel is the unifying part. You seemed happier with tc flower just not with the
Quoted 7 lines
Yeah, that is my point, why the unifying part can't be a userspace daemon/library with multiple backends (p4tc, bpf, vendorX, vendorY, ..)?
I just don't see the kernel as a good fit for abstraction here, given the fact that the vendor compilers does not run in kernel. That is breaking your model.
Quoted 14 lines
Jiri - we want to support P4, first. Like you said the P4 pipeline, once installed is static.
P4 doesnt allow dynamic update of the pipeline. For example, once you say "here are my 14 tables and their associated actions and here's how the pipeline main control (on how to iterate the tables etc) is going to be" and after you instantiate/activate that pipeline, you dont go back 5 minutes later and say "sorry, please introduce table 15, which i want you to walk to after you visit table 3 if metadata foo is 5" or "shoot, let's change that table 5 to be exact instead of LPM". It's not anywhere in the spec.
That doesnt mean it is not useful thing to have - but it is an invention that has_nothingto do with the P4spec_; so saying a P4 implementation must support it is a bit out of scope and there are vendors with hardware who support P4 today that dont need any of this.I'm not talking about the spec. I'm talking about the offload implemetation, the offload compiler the offload runtime manager. You don't have those in kernel. That is the issue. The runtime manager is the one to decide and reshuffle the hw internals. Again, this has nothing to do with p4 frontend. This is offload implementation.
Quoted 8 lines
Quoted 3 lines
And that is why I believe your p4 kernel implementation is unoffloadable. And if it is unoffloadable, do we really need it? IDK.
Say what?
It's not offloadable in your hardware, you mean? Because i have beside me here an intel e2000 which offloads just fine (and the AMD folks seem fine too).
Will Intel and AMD have compiler in kernel, so no blob transfer and parsing it in kernel wound not be needed? No.
Quoted 8 lines
If your view is that all these runtime optimization surmount to a compiler in the kernel/driver that is your, well, your view. In my view (and others have said this to you already) the P4C compiler is responsible for resource optimizations. The hardware supports P4, you give it constraints and it knows what to do. At runtime, anything a driver needs to do for resource optimization (resorting, reshuffling etc), that is not a P4 problem - sorry if you have issues in your architecture approach.
Sure, it is the offload implementation problem. And for them, you need to use userspace components. And that is the problem. This discussion leads nowhere, I don't know how differently should I describe this.
Quoted 47 lines
Quoted 21 lines
Quoted 10 lines
In my opinion that is a feature that could be added later out of necessity (there is some good niche value in being able to add some "dynamicism" to any pipeline) and influence the P4 standards on why it is needed.
It should be doable today in a brute force way (this is just one suggestion that came to me when Rice University/Nvidia presented[1]); i am sure there are other approaches and the idea is by no means proven.Quoted 10 lines
1) User space Creates/compiles/Adds/activate your program that has 14 tables at tc prio X chain Y
2) a) 5 minutes later user space decides it wants to change and add table 3 after table 15, visited when metadata foo=5
b) your compiler in user space compiles a brand new program which
satisfies #2a (how this program was authored is out of scope of discussion)
c) user space adds the new program at tc prio X+1 chain Y or another chain Z
d) user space delete tc prio X chain Y (and make sure your packets
entry point is whatever #c is)Quoted 2 lines
I never suggested anything like what you describe. I'm not sure why you think so.
It's the same class of problems - the paper i pointed to (coauthored by Matty and others) has runtime resource optimizations which are tantamount to changing the nature of the pipeline. We may need to profile in the kernel but all those optimizations can be derived in user space using the approach I described.
cheers,
jamalQuoted 13 lines
Quoted 13 lines
[1] https://www.cs.rice.edu/~eugeneng/papers/SIGCOMM23-Pipeleon.pdf
Quoted 11 lines
Quoted 11 lines
kernel process - which is ironically the same thing we are going through here ;->
cheers,
jamalQuoted 4 lines
Quoted 4 lines
cheers,
jamal
Jamal Hadi Salim
maintainerQuoted 292 lines · Jiri Pirko
Quoted 290 lines · Wed, Nov 22, 2023 at 08:35:21PM CET, [email protected] wrote:
Quoted 288 lines · Jiri Pirko
Quoted 73 lines · Wed, Nov 22, 2023 at 04:14:02PM CET, [email protected] wrote:
Quoted 64 lines · Jiri Pirko
Quoted 62 lines · Tue, Nov 21, 2023 at 04:21:44PM CET, [email protected] wrote:
Quoted 60 lines · Jiri Pirko
Quoted 47 lines · Tue, Nov 21, 2023 at 02:47:40PM CET, [email protected] wrote:
Quoted 46 lines · Jiri Pirko
Quoted 5 lines · Mon, Nov 20, 2023 at 11:56:50PM CET, [email protected] wrote:
Quoted 4 lines · Daniel Borkmann
Quoted 2 lines · Jamal Hadi Salim
Quoted 1 line · Jiri Pirko
Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:
[...]
Quoted 24 lines
Quoted 10 lines
tc BPF and XDP already have widely used infrastructure and can be developed against libbpf or other user space libraries for a user space control plane. With 'control plane' you refer here to the tc / netlink shim you've built, but looking at the tc command line examples, this doesn't really provide a good user experience (you call it p4 but people load bpf obj files). If the expectation is that an operator should run tc commands, then neither it's a nice experience for p4 nor for BPF folks. From a BPF PoV, we moved over to
bpf_mprogand plan to also extend this for XDP to have a common look and feel wrt networking for developers. Why can't this be reused?The filter loading which loads the program is considered pipeline instantiation - consider it as "provisioning" more than "control" which runs at runtime. "control" is purely netlink based. The iproute2 code we use links libbpf for example for the filter. If we can achieve the same with
bpf_mprogthen sure - we just dont want to loose functionality though. off top of my head, some sample space:
- we could have multiple pipelines with different priorities (which tc provides to us) - and each pipeline may have its own logic with many tables etc (and the choice to iterate the next one is essentially encoded in the tc action codes)
- we use tc block to map groups of ports (which i dont think bpf has internal access of)Quoted 3 lines
In regards to usability: no i dont expect someone doing things at scale to use command line tc. The APIs are via netlink. But the tc cli is must for the rest of the masses per our traditions. Also i really
I don't follow. You repeatedly mention "the must of the traditional tc cli", but what of the existing traditional cli you use for p4tc? If I look at the examples, pretty much everything looks new to me. Example:
tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1Quoted 6 lines
Quoted 3 lines
This is just TC/RTnetlink used as a channel to pass new things over. If that is the case, what's traditional here?
What is not traditional about it?
Okay, so in that case, the following example communitating with userspace deamon using imaginary "p4ctrl" app is equally traditional:
$ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1Quoted 7 lines
Quoted 4 lines
Huh? Thats just an application - classical tc which part of iproute2 that is sending to the kernel, no different than "tc flower.." Where do you get the "userspace" daemon part? Yes, you can write a daemon but it will use the same APIs as tc.
Okay, so which part is the "tradition"?
Quoted 8 lines
Provides tooling via tc cli that _everyone_ in the tc world is familiar with - which uses the same syntax as other tc extensions do, same expectations (eg events, request responses, familiar commands for dumping, flushing etc). Basically someone familiar with tc will pick this up and operate it very quickly and would have an easier time debugging it.
There are caveats - as will be with all new classifiers - but those are within reason.Okay, so syntax familiarity wise, what's the difference between following 2 approaches:
$ tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1 $ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1 ?Quoted 72 lines
Quoted 50 lines
Quoted 50 lines
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines
Quoted 16 lines
didnt even want to use ebpf at all for operator experience reasons - it requires a compilation of the code and an extra loading compared to what our original u32/pedit code offered.
Quoted 7 lines
I don't quite follow why not most of this could be implemented entirely in user space without the detour of this and you would provide a developer library which could then be integrated into a p4 runtime/frontend? This way users never interface with ebpf parts nor tc given they also shouldn't have to - it's an implementation detail. This is what John was also pointing out earlier.
Quoted 8 lines
Netlink is the API. We will provide a library for object manipulation which abstracts away the need to know netlink. Someone who for their own reasons wants to use p4runtime or TDI could write on top of this. I would not design a kernel interface to just meet p4runtime (we already have TDI which came later which does things differently). So i expect us to support both those two. And if i was to do something on SDN that was more robust i would write my own that still uses these netlink interfaces.
Actually, what Daniel says about the p4 library used as a backend to p4 frontend is pretty much aligned what I claimed on the p4 calls couple of times. If you have this p4 userspace tooling, it is easy for offloads to replace the backed by vendor-specific library which allows p4 offload suitable for all vendors (your plan of p4tc offload does not work well for our hw, as we repeatedly claimed).
Quoted 8 lines
Quoted 6 lines
That's you - NVIDIA. You have chosen a path away from the kernel towards DOCA. I understand NVIDIA's frustration with dealing with upstream process (which has been cited to me as a good reason for DOCA) but please dont impose these values and your politics on other
vendors(Intel, AMD for example)who are more than willing to invest into making the kernel interfaces the path forward. Your choice.No, you are missing the point. This has nothing to do with DOCA.
Right Jiri ;->
Quoted 5 lines
This
has to do with the simple limitation of your offload assuming there are no runtime changes in the compiled pipeline. For Intel, maybe they aren't, and it's a good fit for them. All I say is, that it is not the good fit for everyone.Quoted 7 lines
Quoted 2 lines
a) it is not part of the P4 spec to dynamically make changes to the datapath pipeline after it is create and we are discussing a P4
Isn't this up to the implementation? I mean from the p4 perspective, everything is static. Hw might need to reshuffle the pipeline internally during rule insertion/remove in order to optimize the layout.
But do note: the focus here is on P4 (hence the name P4TC).
Quoted 12 lines
Quoted 11 lines
implementation not an extension that would add more value b) We are more than happy to add extensions in the future to accomodate for features but first
_P4spec_must be met c) we had longer discussions with Matty, Khalid and the Rice folks who wrote a paper on that topic which you probably didnt attend and everything that needs to be done can be from user space today for all those optimizations.Conclusion is: For what you need to do (which i dont believe is a limitation in your hardware rather a design decision on your part) run your user space daemon, do optimizations and update the datapath. Everybody is happy.
Quoted 7 lines
Quoted 3 lines
Should the userspace daemon listen on inserted rules to be offloade over netlink?
I mean you could if you wanted to given this is just traditional netlink which emits events (with some filtering when we integrate the filter approach). But why?
Nevermind.
Quoted 53 lines
Quoted 37 lines
Quoted 37 lines
Quoted 37 lines
Quoted 17 lines
Nobody is stopping you from offering your customers proprietary solutions which include a specific ebpf approach alongside DOCA. We believe that a singular interface regardless of the vendor is the right way forward. IMHO, this siloing that unfortunately is also added by eBPF being a double edged sword is not good for the community.
Quoted 8 lines
As I also said on the p4 call couple of times, I don't see the kernel as the correct place to do the p4 abstractions. Why don't you do it in userspace and give vendors possiblity to have p4 backends with compilers, runtime optimizations etc in userspace, talking to the HW in the vendor-suitable way too. Then the SW implementation could be easily eBPF and the main reason (I believe) why you need to have this is TC (offload) is then void.
Quoted 4 lines
Quoted 2 lines
The "everyone wants to use TC/netlink" claim does not seem correct to me. Why not to have one Linux p4 solution that fits everyones needs?
You mean more fitting to the DOCA world? no, because iam a kernel
Again, this has 0 relation to DOCA.
Quoted 1 line
first person and kernel interfaces are good for everyone.
Yeah, not really. Not always the kernel is the right answer. Your/Intel plan to handle the offload by:
1) abuse devlink to flash p4 binary
2) parse the binary in kernel to match to the table ids of rules coming from p4tcndo_setup_tc
3) abuse devlink to flash p4 binary for tc-flower
4) parse the binary in kernel to match to the table ids of rules coming from tc-flowerndo_setup_tc
is really something that is making me a little bit nauseous.Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
If you don't have a feasible plan to do the offload, p4tc does not make sense to me to be honest.
You mean if there's no plan to match your (NVIDIA?) point of view. For #1 - how's this different from DDP? Wasnt that your suggestion to
I doubt that. Any flashing-blob-parsing-in-kernel is something I'm opposed to from day 1.
Oh well - it is in the kernel and it works fine tbh.
Quoted 3 lines
Quoted 2 lines
begin with? For #2 Nobody is proposing to do anything of the sort. The ndo is passed IDs for the objects and associated contents. For #3+#4
Quoted 8 lines
Quoted 4 lines
During offload, you need to parse the blob in driver to be able to match the ids with blob entities. That was presented by you/Intel in the past IIRC.
You are correct - in case of offload the netlink IDs will have to be authenticated against what the hardware can accept, but the devlink flash use i believe was from you as a compromise.
Definitelly not. I'm against devlink abuse for this from day 1.
Quoted 23 lines
Quoted 15 lines
Quoted 4 lines
tc flower thing has nothing to do with P4TC that was just some random proposal someone made seeing if they could ride on top of P4TC.
Yeah, it's not yet merged and already mentally used for abuse. I love that :)
Quoted 6 lines
Besides this nobody really has to satisfy your point of view - like i said earlier feel free to provide proprietary solutions. From a consumer perspective I would not want to deal with 4 different vendors with 4 different proprietary approaches. The kernel is the unifying part. You seemed happier with tc flower just not with the
Quoted 7 lines
Yeah, that is my point, why the unifying part can't be a userspace daemon/library with multiple backends (p4tc, bpf, vendorX, vendorY, ..)?
I just don't see the kernel as a good fit for abstraction here, given the fact that the vendor compilers does not run in kernel. That is breaking your model.
Quoted 14 lines
Jiri - we want to support P4, first. Like you said the P4 pipeline, once installed is static.
P4 doesnt allow dynamic update of the pipeline. For example, once you say "here are my 14 tables and their associated actions and here's how the pipeline main control (on how to iterate the tables etc) is going to be" and after you instantiate/activate that pipeline, you dont go back 5 minutes later and say "sorry, please introduce table 15, which i want you to walk to after you visit table 3 if metadata foo is 5" or "shoot, let's change that table 5 to be exact instead of LPM". It's not anywhere in the spec.
That doesnt mean it is not useful thing to have - but it is an invention that has_nothingto do with the P4spec_; so saying a P4 implementation must support it is a bit out of scope and there are vendors with hardware who support P4 today that dont need any of this.I'm not talking about the spec. I'm talking about the offload implemetation, the offload compiler the offload runtime manager. You don't have those in kernel. That is the issue. The runtime manager is the one to decide and reshuffle the hw internals. Again, this has nothing to do with p4 frontend. This is offload implementation.
And that is why I believe your p4 kernel implementation is unoffloadable. And if it is unoffloadable, do we really need it? IDK.
Quoted 7 lines
Quoted 4 lines
Say what?
It's not offloadable in your hardware, you mean? Because i have beside me here an intel e2000 which offloads just fine (and the AMD folks seem fine too).Will Intel and AMD have compiler in kernel, so no blob transfer and parsing it in kernel wound not be needed? No.
By that definition anything that parses anything is a compiler.
Quoted 10 lines
Quoted 9 lines
If your view is that all these runtime optimization surmount to a compiler in the kernel/driver that is your, well, your view. In my view (and others have said this to you already) the P4C compiler is responsible for resource optimizations. The hardware supports P4, you give it constraints and it knows what to do. At runtime, anything a driver needs to do for resource optimization (resorting, reshuffling etc), that is not a P4 problem - sorry if you have issues in your architecture approach.
Quoted 3 lines
Sure, it is the offload implementation problem. And for them, you need to use userspace components. And that is the problem. This discussion leads nowhere, I don't know how differently I should describe this.
Jiri's - that's your view based on whatever design you have in your mind. This has nothing to do with P4.
So let me repeat again:
1) A vendor's backend for P4 when it compiles ensures that resource constraints are taken care of.
2) The same program can run in s/w.
3) It makes *ZERO* sense to mix vendor specific constraint optimization(what you described as resorting, reshuffling etc) as part of P4TC or P4. Absolutely nothing to do with either. Write a background task, specific to you, if you feel you need to move things around at runtime.
We agree on one thing at least: This discussion is going nowhere.
cheers,
jamal
Quoted 47 lines
Quoted 47 lines
Quoted 21 lines
Quoted 10 lines
In my opinion that is a feature that could be added later out of necessity (there is some good niche value in being able to add some "dynamicism" to any pipeline) and influence the P4 standards on why it is needed.
It should be doable today in a brute force way (this is just one suggestion that came to me when Rice University/Nvidia presented[1]); i am sure there are other approaches and the idea is by no means proven.Quoted 10 lines
1) User space Creates/compiles/Adds/activate your program that has 14 tables at tc prio X chain Y
2) a) 5 minutes later user space decides it wants to change and add table 3 after table 15, visited when metadata foo=5
b) your compiler in user space compiles a brand new program which
satisfies #2a (how this program was authored is out of scope of discussion)
c) user space adds the new program at tc prio X+1 chain Y or another chain Z
d) user space delete tc prio X chain Y (and make sure your packets
entry point is whatever #c is)Quoted 2 lines
I never suggested anything like what you describe. I'm not sure why you think so.
It's the same class of problems - the paper i pointed to (coauthored by Matty and others) has runtime resource optimizations which are tantamount to changing the nature of the pipeline. We may need to profile in the kernel but all those optimizations can be derived in user space using the approach I described.
cheers,
jamalQuoted 13 lines
Quoted 13 lines
[1] https://www.cs.rice.edu/~eugeneng/papers/SIGCOMM23-Pipeleon.pdf
Quoted 11 lines
Quoted 11 lines
kernel process - which is ironically the same thing we are going through here ;->
cheers,
jamalQuoted 4 lines
Quoted 4 lines
cheers,
jamal
Jiri Pirko
maintainerQuoted 317 lines · Thu, Nov 23, 2023 at 02:22:11PM CET, [email protected] wrote:
Quoted 292 lines · Jiri Pirko
Quoted 290 lines · Wed, Nov 22, 2023 at 08:35:21PM CET, [email protected] wrote:
Quoted 288 lines · Jiri Pirko
Quoted 73 lines · Wed, Nov 22, 2023 at 04:14:02PM CET, [email protected] wrote:
Quoted 64 lines · Jiri Pirko
Quoted 62 lines · Tue, Nov 21, 2023 at 04:21:44PM CET, [email protected] wrote:
Quoted 60 lines · Jiri Pirko
Quoted 47 lines · Tue, Nov 21, 2023 at 02:47:40PM CET, [email protected] wrote:
Quoted 46 lines · Jiri Pirko
Quoted 5 lines · Mon, Nov 20, 2023 at 11:56:50PM CET, [email protected] wrote:
Quoted 4 lines · Daniel Borkmann
Quoted 2 lines · Jamal Hadi Salim
On Mon, Nov 20, 2023 at 1:10 PM Jiri Pirko <[email protected]> wrote:
Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:[...]
Quoted 24 lines
Quoted 10 lines
tc BPF and XDP already have widely used infrastructure and can be developed against libbpf or other user space libraries for a user space control plane. With 'control plane' you refer here to the tc / netlink shim you've built, but looking at the tc command line examples, this doesn't really provide a good user experience (you call it p4 but people load bpf obj files). If the expectation is that an operator should run tc commands, then neither it's a nice experience for p4 nor for BPF folks. From a BPF PoV, we moved over to
bpf_mprogand plan to also extend this for XDP to have a common look and feel wrt networking for developers. Why can't this be reused?The filter loading which loads the program is considered pipeline instantiation - consider it as "provisioning" more than "control" which runs at runtime. "control" is purely netlink based. The iproute2 code we use links libbpf for example for the filter. If we can achieve the same with
bpf_mprogthen sure - we just dont want to loose functionality though. off top of my head, some sample space:
- we could have multiple pipelines with different priorities (which tc provides to us) - and each pipeline may have its own logic with many tables etc (and the choice to iterate the next one is essentially encoded in the tc action codes)
- we use tc block to map groups of ports (which i dont think bpf has internal access of)Quoted 3 lines
In regards to usability: no i dont expect someone doing things at scale to use command line tc. The APIs are via netlink. But the tc cli is must for the rest of the masses per our traditions. Also i really
I don't follow. You repeatedly mention "the must of the traditional tc cli", but what of the existing traditional cli you use for p4tc? If I look at the examples, pretty much everything looks new to me. Example:
tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1Quoted 6 lines
Quoted 3 lines
This is just TC/RTnetlink used as a channel to pass new things over. If that is the case, what's traditional here?
What is not traditional about it?
Okay, so in that case, the following example communitating with userspace deamon using imaginary "p4ctrl" app is equally traditional:
$ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1Quoted 7 lines
Quoted 4 lines
Huh? Thats just an application - classical tc which part of iproute2 that is sending to the kernel, no different than "tc flower.." Where do you get the "userspace" daemon part? Yes, you can write a daemon but it will use the same APIs as tc.
Okay, so which part is the "tradition"?
Quoted 8 lines
Provides tooling via tc cli that _everyone_ in the tc world is familiar with - which uses the same syntax as other tc extensions do, same expectations (eg events, request responses, familiar commands for dumping, flushing etc). Basically someone familiar with tc will pick this up and operate it very quickly and would have an easier time debugging it.
There are caveats - as will be with all new classifiers - but those are within reason.Okay, so syntax familiarity wise, what's the difference between following 2 approaches:
$ tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1 $ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1 ?Quoted 72 lines
Quoted 50 lines
Quoted 50 lines
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines
Quoted 16 lines
didnt even want to use ebpf at all for operator experience reasons - it requires a compilation of the code and an extra loading compared to what our original u32/pedit code offered.
Quoted 7 lines
I don't quite follow why not most of this could be implemented entirely in user space without the detour of this and you would provide a developer library which could then be integrated into a p4 runtime/frontend? This way users never interface with ebpf parts nor tc given they also shouldn't have to - it's an implementation detail. This is what John was also pointing out earlier.
Quoted 8 lines
Netlink is the API. We will provide a library for object manipulation which abstracts away the need to know netlink. Someone who for their own reasons wants to use p4runtime or TDI could write on top of this. I would not design a kernel interface to just meet p4runtime (we already have TDI which came later which does things differently). So i expect us to support both those two. And if i was to do something on SDN that was more robust i would write my own that still uses these netlink interfaces.
Actually, what Daniel says about the p4 library used as a backend to p4 frontend is pretty much aligned what I claimed on the p4 calls couple of times. If you have this p4 userspace tooling, it is easy for offloads to replace the backed by vendor-specific library which allows p4 offload suitable for all vendors (your plan of p4tc offload does not work well for our hw, as we repeatedly claimed).
Quoted 8 lines
Quoted 6 lines
That's you - NVIDIA. You have chosen a path away from the kernel towards DOCA. I understand NVIDIA's frustration with dealing with upstream process (which has been cited to me as a good reason for DOCA) but please dont impose these values and your politics on other
vendors(Intel, AMD for example)who are more than willing to invest into making the kernel interfaces the path forward. Your choice.No, you are missing the point. This has nothing to do with DOCA.
Right Jiri ;->
Quoted 5 lines
This
has to do with the simple limitation of your offload assuming there are no runtime changes in the compiled pipeline. For Intel, maybe they aren't, and it's a good fit for them. All I say is, that it is not the good fit for everyone.Quoted 7 lines
Quoted 2 lines
a) it is not part of the P4 spec to dynamically make changes to the datapath pipeline after it is create and we are discussing a P4
Isn't this up to the implementation? I mean from the p4 perspective, everything is static. Hw might need to reshuffle the pipeline internally during rule insertion/remove in order to optimize the layout.
But do note: the focus here is on P4 (hence the name P4TC).
Quoted 12 lines
Quoted 11 lines
implementation not an extension that would add more value b) We are more than happy to add extensions in the future to accomodate for features but first
_P4spec_must be met c) we had longer discussions with Matty, Khalid and the Rice folks who wrote a paper on that topic which you probably didnt attend and everything that needs to be done can be from user space today for all those optimizations.Conclusion is: For what you need to do (which i dont believe is a limitation in your hardware rather a design decision on your part) run your user space daemon, do optimizations and update the datapath. Everybody is happy.
Quoted 7 lines
Quoted 3 lines
Should the userspace daemon listen on inserted rules to be offloade over netlink?
I mean you could if you wanted to given this is just traditional netlink which emits events (with some filtering when we integrate the filter approach). But why?
Nevermind.
Quoted 53 lines
Quoted 37 lines
Quoted 37 lines
Quoted 37 lines
Quoted 17 lines
Nobody is stopping you from offering your customers proprietary solutions which include a specific ebpf approach alongside DOCA. We believe that a singular interface regardless of the vendor is the right way forward. IMHO, this siloing that unfortunately is also added by eBPF being a double edged sword is not good for the community.
Quoted 8 lines
As I also said on the p4 call couple of times, I don't see the kernel as the correct place to do the p4 abstractions. Why don't you do it in userspace and give vendors possiblity to have p4 backends with compilers, runtime optimizations etc in userspace, talking to the HW in the vendor-suitable way too. Then the SW implementation could be easily eBPF and the main reason (I believe) why you need to have this is TC (offload) is then void.
Quoted 4 lines
Quoted 2 lines
The "everyone wants to use TC/netlink" claim does not seem correct to me. Why not to have one Linux p4 solution that fits everyones needs?
You mean more fitting to the DOCA world? no, because iam a kernel
Again, this has 0 relation to DOCA.
Quoted 1 line
first person and kernel interfaces are good for everyone.
Yeah, not really. Not always the kernel is the right answer. Your/Intel plan to handle the offload by:
1) abuse devlink to flash p4 binary
2) parse the binary in kernel to match to the table ids of rules coming from p4tcndo_setup_tc
3) abuse devlink to flash p4 binary for tc-flower
4) parse the binary in kernel to match to the table ids of rules coming from tc-flowerndo_setup_tc
is really something that is making me a little bit nauseous.Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
If you don't have a feasible plan to do the offload, p4tc does not make sense to me to be honest.
You mean if there's no plan to match your (NVIDIA?) point of view. For #1 - how's this different from DDP? Wasnt that your suggestion to
I doubt that. Any flashing-blob-parsing-in-kernel is something I'm opposed to from day 1.
Oh well - it is in the kernel and it works fine tbh.
Quoted 3 lines
Quoted 2 lines
begin with? For #2 Nobody is proposing to do anything of the sort. The ndo is passed IDs for the objects and associated contents. For #3+#4
Quoted 8 lines
Quoted 4 lines
During offload, you need to parse the blob in driver to be able to match the ids with blob entities. That was presented by you/Intel in the past IIRC.
You are correct - in case of offload the netlink IDs will have to be authenticated against what the hardware can accept, but the devlink flash use i believe was from you as a compromise.
Definitelly not. I'm against devlink abuse for this from day 1.
Quoted 23 lines
Quoted 15 lines
Quoted 4 lines
tc flower thing has nothing to do with P4TC that was just some random proposal someone made seeing if they could ride on top of P4TC.
Yeah, it's not yet merged and already mentally used for abuse. I love that :)
Quoted 6 lines
Besides this nobody really has to satisfy your point of view - like i said earlier feel free to provide proprietary solutions. From a consumer perspective I would not want to deal with 4 different vendors with 4 different proprietary approaches. The kernel is the unifying part. You seemed happier with tc flower just not with the
Quoted 7 lines
Yeah, that is my point, why the unifying part can't be a userspace daemon/library with multiple backends (p4tc, bpf, vendorX, vendorY, ..)?
I just don't see the kernel as a good fit for abstraction here, given the fact that the vendor compilers does not run in kernel. That is breaking your model.
Quoted 14 lines
Jiri - we want to support P4, first. Like you said the P4 pipeline, once installed is static.
P4 doesnt allow dynamic update of the pipeline. For example, once you say "here are my 14 tables and their associated actions and here's how the pipeline main control (on how to iterate the tables etc) is going to be" and after you instantiate/activate that pipeline, you dont go back 5 minutes later and say "sorry, please introduce table 15, which i want you to walk to after you visit table 3 if metadata foo is 5" or "shoot, let's change that table 5 to be exact instead of LPM". It's not anywhere in the spec.
That doesnt mean it is not useful thing to have - but it is an invention that has_nothingto do with the P4spec_; so saying a P4 implementation must support it is a bit out of scope and there are vendors with hardware who support P4 today that dont need any of this.I'm not talking about the spec. I'm talking about the offload implemetation, the offload compiler the offload runtime manager. You don't have those in kernel. That is the issue. The runtime manager is the one to decide and reshuffle the hw internals. Again, this has nothing to do with p4 frontend. This is offload implementation.
And that is why I believe your p4 kernel implementation is unoffloadable. And if it is unoffloadable, do we really need it? IDK.
Quoted 7 lines
Quoted 4 lines
Say what?
It's not offloadable in your hardware, you mean? Because i have beside me here an intel e2000 which offloads just fine (and the AMD folks seem fine too).Will Intel and AMD have compiler in kernel, so no blob transfer and parsing it in kernel wound not be needed? No.
By that definition anything that parses anything is a compiler.
Quoted 10 lines
Quoted 9 lines
If your view is that all these runtime optimization surmount to a compiler in the kernel/driver that is your, well, your view. In my view (and others have said this to you already) the P4C compiler is responsible for resource optimizations. The hardware supports P4, you give it constraints and it knows what to do. At runtime, anything a driver needs to do for resource optimization (resorting, reshuffling etc), that is not a P4 problem - sorry if you have issues in your architecture approach.
Quoted 3 lines
Sure, it is the offload implementation problem. And for them, you need to use userspace components. And that is the problem. This discussion leads nowhere, I don't know how differently I should describe this.
Quoted 9 lines
Jiri's - that's your view based on whatever design you have in your mind. This has nothing to do with P4.
So let me repeat again:
1) A vendor's backend for P4 when it compiles ensures that resource constraints are taken care of.
2) The same program can run in s/w.
3) It makes *ZERO* sense to mix vendor specific constraintoptimization(what you described as resorting, reshuffling etc)as part of P4TC or P4. Absolutely nothing to do with either. Write a
I never suggested for it to be part of P4tc of P4. I don't know why you think so.
Quoted 2 lines
background task, specific to you, if you feel you need to move things around at runtime.
Yeah, that backgroud task is in userspace.
Quoted 2 lines
We agree on one thing at least: This discussion is going nowhere.
Correct.
Quoted 53 lines
cheers,
jamalQuoted 47 lines
Quoted 47 lines
Quoted 21 lines
Quoted 10 lines
In my opinion that is a feature that could be added later out of necessity (there is some good niche value in being able to add some "dynamicism" to any pipeline) and influence the P4 standards on why it is needed.
It should be doable today in a brute force way (this is just one suggestion that came to me when Rice University/Nvidia presented[1]); i am sure there are other approaches and the idea is by no means proven.Quoted 10 lines
1) User space Creates/compiles/Adds/activate your program that has 14 tables at tc prio X chain Y
2) a) 5 minutes later user space decides it wants to change and add table 3 after table 15, visited when metadata foo=5
b) your compiler in user space compiles a brand new program which
satisfies #2a (how this program was authored is out of scope of discussion)
c) user space adds the new program at tc prio X+1 chain Y or another chain Z
d) user space delete tc prio X chain Y (and make sure your packets
entry point is whatever #c is)Quoted 2 lines
I never suggested anything like what you describe. I'm not sure why you think so.
It's the same class of problems - the paper i pointed to (coauthored by Matty and others) has runtime resource optimizations which are tantamount to changing the nature of the pipeline. We may need to profile in the kernel but all those optimizations can be derived in user space using the approach I described.
cheers,
jamalQuoted 13 lines
Quoted 13 lines
[1] https://www.cs.rice.edu/~eugeneng/papers/SIGCOMM23-Pipeleon.pdf
Quoted 11 lines
Quoted 11 lines
kernel process - which is ironically the same thing we are going through here ;->
cheers,
jamalQuoted 4 lines
Quoted 4 lines
cheers,
jamal
Jamal Hadi Salim
maintainerQuoted 329 lines · Jiri Pirko
Quoted 317 lines · Thu, Nov 23, 2023 at 02:22:11PM CET, [email protected] wrote:
Quoted 292 lines · Jiri Pirko
Quoted 290 lines · Wed, Nov 22, 2023 at 08:35:21PM CET, [email protected] wrote:
Quoted 288 lines · Jiri Pirko
Quoted 73 lines · Wed, Nov 22, 2023 at 04:14:02PM CET, [email protected] wrote:
Quoted 64 lines · Jiri Pirko
Quoted 62 lines · Tue, Nov 21, 2023 at 04:21:44PM CET, [email protected] wrote:
Quoted 60 lines · Jiri Pirko
Quoted 47 lines · Tue, Nov 21, 2023 at 02:47:40PM CET, [email protected] wrote:
Quoted 46 lines · Jiri Pirko
Quoted 5 lines · Mon, Nov 20, 2023 at 11:56:50PM CET, [email protected] wrote:
Quoted 4 lines · Daniel Borkmann
On 11/20/23 8:56 PM, Jamal Hadi Salim wrote:
On Mon, Nov 20, 2023 at 1:10 PM Jiri Pirko <[email protected]> wrote:
Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:[...]
Quoted 24 lines
Quoted 10 lines
tc BPF and XDP already have widely used infrastructure and can be developed
against libbpf or other user space libraries for a user space control plane.
With 'control plane' you refer here to the tc / netlink shim you've built,
but looking at the tc command line examples, this doesn't really provide a
good user experience (you call it p4 but people load bpf obj files). If the
expectation is that an operator should run tc commands, then neither it's
a nice experience for p4 nor for BPF folks. From a BPF PoV, we moved over
to bpf_mprog and plan to also extend this for XDP to have a common look and
feel wrt networking for developers. Why can't this be reused?The filter loading which loads the program is considered pipeline instantiation - consider it as "provisioning" more than "control" which runs at runtime. "control" is purely netlink based. The iproute2 code we use links libbpf for example for the filter. If we can achieve the same with
bpf_mprogthen sure - we just dont want to loose functionality though. off top of my head, some sample space:
- we could have multiple pipelines with different priorities (which tc provides to us) - and each pipeline may have its own logic with many tables etc (and the choice to iterate the next one is essentially encoded in the tc action codes)
- we use tc block to map groups of ports (which i dont think bpf has internal access of)Quoted 3 lines
In regards to usability: no i dont expect someone doing things at scale to use command line tc. The APIs are via netlink. But the tc cli is must for the rest of the masses per our traditions. Also i really
I don't follow. You repeatedly mention "the must of the traditional tc cli", but what of the existing traditional cli you use for p4tc? If I look at the examples, pretty much everything looks new to me. Example:
tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1Quoted 6 lines
Quoted 3 lines
This is just TC/RTnetlink used as a channel to pass new things over. If that is the case, what's traditional here?
What is not traditional about it?
Okay, so in that case, the following example communitating with userspace deamon using imaginary "p4ctrl" app is equally traditional:
$ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1Quoted 7 lines
Quoted 4 lines
Huh? Thats just an application - classical tc which part of iproute2 that is sending to the kernel, no different than "tc flower.." Where do you get the "userspace" daemon part? Yes, you can write a daemon but it will use the same APIs as tc.
Okay, so which part is the "tradition"?
Quoted 8 lines
Provides tooling via tc cli that _everyone_ in the tc world is familiar with - which uses the same syntax as other tc extensions do, same expectations (eg events, request responses, familiar commands for dumping, flushing etc). Basically someone familiar with tc will pick this up and operate it very quickly and would have an easier time debugging it.
There are caveats - as will be with all new classifiers - but those are within reason.Okay, so syntax familiarity wise, what's the difference between following 2 approaches:
$ tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1 $ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1 ?Quoted 72 lines
Quoted 50 lines
Quoted 50 lines
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines
Quoted 16 lines
didnt even want to use ebpf at all for operator experience reasons - it requires a compilation of the code and an extra loading compared to what our original u32/pedit code offered.
Quoted 7 lines
I don't quite follow why not most of this could be implemented entirely in
user space without the detour of this and you would provide a developer
library which could then be integrated into a p4 runtime/frontend? This
way users never interface with ebpf parts nor tc given they also shouldn't
have to - it's an implementation detail. This is what John was also pointing
out earlier.Quoted 8 lines
Netlink is the API. We will provide a library for object manipulation which abstracts away the need to know netlink. Someone who for their own reasons wants to use p4runtime or TDI could write on top of this. I would not design a kernel interface to just meet p4runtime (we already have TDI which came later which does things differently). So i expect us to support both those two. And if i was to do something on SDN that was more robust i would write my own that still uses these netlink interfaces.
Actually, what Daniel says about the p4 library used as a backend to p4 frontend is pretty much aligned what I claimed on the p4 calls couple of times. If you have this p4 userspace tooling, it is easy for offloads to replace the backed by vendor-specific library which allows p4 offload suitable for all vendors (your plan of p4tc offload does not work well for our hw, as we repeatedly claimed).
Quoted 8 lines
Quoted 6 lines
That's you - NVIDIA. You have chosen a path away from the kernel towards DOCA. I understand NVIDIA's frustration with dealing with upstream process (which has been cited to me as a good reason for DOCA) but please dont impose these values and your politics on other
vendors(Intel, AMD for example)who are more than willing to invest into making the kernel interfaces the path forward. Your choice.No, you are missing the point. This has nothing to do with DOCA.
Right Jiri ;->
Quoted 5 lines
This
has to do with the simple limitation of your offload assuming there are no runtime changes in the compiled pipeline. For Intel, maybe they aren't, and it's a good fit for them. All I say is, that it is not the good fit for everyone.Quoted 7 lines
Quoted 2 lines
a) it is not part of the P4 spec to dynamically make changes to the datapath pipeline after it is create and we are discussing a P4
Isn't this up to the implementation? I mean from the p4 perspective, everything is static. Hw might need to reshuffle the pipeline internally during rule insertion/remove in order to optimize the layout.
But do note: the focus here is on P4 (hence the name P4TC).
Quoted 12 lines
Quoted 11 lines
implementation not an extension that would add more value b) We are more than happy to add extensions in the future to accomodate for features but first
_P4spec_must be met c) we had longer discussions with Matty, Khalid and the Rice folks who wrote a paper on that topic which you probably didnt attend and everything that needs to be done can be from user space today for all those optimizations.Conclusion is: For what you need to do (which i dont believe is a limitation in your hardware rather a design decision on your part) run your user space daemon, do optimizations and update the datapath. Everybody is happy.
Quoted 7 lines
Quoted 3 lines
Should the userspace daemon listen on inserted rules to be offloade over netlink?
I mean you could if you wanted to given this is just traditional netlink which emits events (with some filtering when we integrate the filter approach). But why?
Nevermind.
Quoted 53 lines
Quoted 37 lines
Quoted 37 lines
Quoted 37 lines
Quoted 17 lines
Nobody is stopping you from offering your customers proprietary solutions which include a specific ebpf approach alongside DOCA. We believe that a singular interface regardless of the vendor is the right way forward. IMHO, this siloing that unfortunately is also added by eBPF being a double edged sword is not good for the community.
Quoted 8 lines
As I also said on the p4 call couple of times, I don't see the kernel as the correct place to do the p4 abstractions. Why don't you do it in userspace and give vendors possiblity to have p4 backends with compilers, runtime optimizations etc in userspace, talking to the HW in the vendor-suitable way too. Then the SW implementation could be easily eBPF and the main reason (I believe) why you need to have this is TC (offload) is then void.
Quoted 4 lines
Quoted 2 lines
The "everyone wants to use TC/netlink" claim does not seem correct to me. Why not to have one Linux p4 solution that fits everyones needs?
You mean more fitting to the DOCA world? no, because iam a kernel
Again, this has 0 relation to DOCA.
Quoted 1 line
first person and kernel interfaces are good for everyone.
Yeah, not really. Not always the kernel is the right answer. Your/Intel plan to handle the offload by:
1) abuse devlink to flash p4 binary
2) parse the binary in kernel to match to the table ids of rules coming from p4tcndo_setup_tc
3) abuse devlink to flash p4 binary for tc-flower
4) parse the binary in kernel to match to the table ids of rules coming from tc-flowerndo_setup_tc
is really something that is making me a little bit nauseous.Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
If you don't have a feasible plan to do the offload, p4tc does not make sense to me to be honest.
You mean if there's no plan to match your (NVIDIA?) point of view. For #1 - how's this different from DDP? Wasnt that your suggestion to
I doubt that. Any flashing-blob-parsing-in-kernel is something I'm opposed to from day 1.
Oh well - it is in the kernel and it works fine tbh.
Quoted 3 lines
Quoted 2 lines
begin with? For #2 Nobody is proposing to do anything of the sort. The ndo is passed IDs for the objects and associated contents. For #3+#4
Quoted 8 lines
Quoted 4 lines
During offload, you need to parse the blob in driver to be able to match the ids with blob entities. That was presented by you/Intel in the past IIRC.
You are correct - in case of offload the netlink IDs will have to be authenticated against what the hardware can accept, but the devlink flash use i believe was from you as a compromise.
Definitelly not. I'm against devlink abuse for this from day 1.
Quoted 23 lines
Quoted 15 lines
Quoted 4 lines
tc flower thing has nothing to do with P4TC that was just some random proposal someone made seeing if they could ride on top of P4TC.
Yeah, it's not yet merged and already mentally used for abuse. I love that :)
Quoted 6 lines
Besides this nobody really has to satisfy your point of view - like i said earlier feel free to provide proprietary solutions. From a consumer perspective I would not want to deal with 4 different vendors with 4 different proprietary approaches. The kernel is the unifying part. You seemed happier with tc flower just not with the
Quoted 7 lines
Yeah, that is my point, why the unifying part can't be a userspace daemon/library with multiple backends (p4tc, bpf, vendorX, vendorY, ..)?
I just don't see the kernel as a good fit for abstraction here, given the fact that the vendor compilers does not run in kernel. That is breaking your model.
Quoted 14 lines
Jiri - we want to support P4, first. Like you said the P4 pipeline, once installed is static.
P4 doesnt allow dynamic update of the pipeline. For example, once you say "here are my 14 tables and their associated actions and here's how the pipeline main control (on how to iterate the tables etc) is going to be" and after you instantiate/activate that pipeline, you dont go back 5 minutes later and say "sorry, please introduce table 15, which i want you to walk to after you visit table 3 if metadata foo is 5" or "shoot, let's change that table 5 to be exact instead of LPM". It's not anywhere in the spec.
That doesnt mean it is not useful thing to have - but it is an invention that has_nothingto do with the P4spec_; so saying a P4 implementation must support it is a bit out of scope and there are vendors with hardware who support P4 today that dont need any of this.I'm not talking about the spec. I'm talking about the offload implemetation, the offload compiler the offload runtime manager. You don't have those in kernel. That is the issue. The runtime manager is the one to decide and reshuffle the hw internals. Again, this has nothing to do with p4 frontend. This is offload implementation.
And that is why I believe your p4 kernel implementation is unoffloadable. And if it is unoffloadable, do we really need it? IDK.
Quoted 7 lines
Quoted 4 lines
Say what?
It's not offloadable in your hardware, you mean? Because i have beside me here an intel e2000 which offloads just fine (and the AMD folks seem fine too).Will Intel and AMD have compiler in kernel, so no blob transfer and parsing it in kernel wound not be needed? No.
By that definition anything that parses anything is a compiler.
Quoted 10 lines
Quoted 9 lines
If your view is that all these runtime optimization surmount to a compiler in the kernel/driver that is your, well, your view. In my view (and others have said this to you already) the P4C compiler is responsible for resource optimizations. The hardware supports P4, you give it constraints and it knows what to do. At runtime, anything a driver needs to do for resource optimization (resorting, reshuffling etc), that is not a P4 problem - sorry if you have issues in your architecture approach.
Quoted 3 lines
Sure, it is the offload implementation problem. And for them, you need to use userspace components. And that is the problem. This discussion leads nowhere, I don't know how differently I should describe this.
Quoted 9 lines
Jiri's - that's your view based on whatever design you have in your mind. This has nothing to do with P4.
So let me repeat again:
1) A vendor's backend for P4 when it compiles ensures that resource constraints are taken care of.
2) The same program can run in s/w.
3) It makes *ZERO* sense to mix vendor specific constraintoptimization(what you described as resorting, reshuffling etc)as part of P4TC or P4. Absolutely nothing to do with either. Write a
Quoted 2 lines
I never suggested for it to be part of P4tc of P4. I don't know why you think so.
I guess because this discussion is about P4/P4TC? I may have misread what you are saying then because I saw the "P4TC must be in userspace" mantra tied to this specific optimization requirement.
Quoted 6 lines
Quoted 3 lines
background task, specific to you, if you feel you need to move things around at runtime.
Yeah, that backgroud task is in userspace.
I don't have a horse in this race.
cheers,
jamal
Quoted 59 lines
Quoted 3 lines
We agree on one thing at least: This discussion is going nowhere.
Correct.
Quoted 53 lines
cheers,
jamalQuoted 47 lines
Quoted 47 lines
Quoted 21 lines
Quoted 10 lines
In my opinion that is a feature that could be added later out of necessity (there is some good niche value in being able to add some "dynamicism" to any pipeline) and influence the P4 standards on why it is needed.
It should be doable today in a brute force way (this is just one suggestion that came to me when Rice University/Nvidia presented[1]); i am sure there are other approaches and the idea is by no means proven.Quoted 10 lines
1) User space Creates/compiles/Adds/activate your program that has 14 tables at tc prio X chain Y
2) a) 5 minutes later user space decides it wants to change and add table 3 after table 15, visited when metadata foo=5
b) your compiler in user space compiles a brand new program which
satisfies #2a (how this program was authored is out of scope of discussion)
c) user space adds the new program at tc prio X+1 chain Y or another chain Z
d) user space delete tc prio X chain Y (and make sure your packets
entry point is whatever #c is)Quoted 2 lines
I never suggested anything like what you describe. I'm not sure why you think so.
It's the same class of problems - the paper i pointed to (coauthored by Matty and others) has runtime resource optimizations which are tantamount to changing the nature of the pipeline. We may need to profile in the kernel but all those optimizations can be derived in user space using the approach I described.
cheers,
jamalQuoted 13 lines
Quoted 13 lines
[1] https://www.cs.rice.edu/~eugeneng/papers/SIGCOMM23-Pipeleon.pdf
Quoted 11 lines
Quoted 11 lines
kernel process - which is ironically the same thing we are going through here ;->
cheers,
jamalQuoted 4 lines
Quoted 4 lines
cheers,
jamal
Jiri Pirko
maintainerQuoted 330 lines · Thu, Nov 23, 2023 at 02:45:50PM CET, [email protected] wrote:
Quoted 329 lines · Jiri Pirko
Quoted 326 lines · Thu, Nov 23, 2023 at 02:22:11PM CET, [email protected] wrote:
Quoted 292 lines · Jiri Pirko
Quoted 290 lines · Wed, Nov 22, 2023 at 08:35:21PM CET, [email protected] wrote:
Quoted 288 lines · Jiri Pirko
Quoted 73 lines · Wed, Nov 22, 2023 at 04:14:02PM CET, [email protected] wrote:
Quoted 64 lines · Jiri Pirko
Quoted 62 lines · Tue, Nov 21, 2023 at 04:21:44PM CET, [email protected] wrote:
Quoted 60 lines · Jiri Pirko
Quoted 47 lines · Tue, Nov 21, 2023 at 02:47:40PM CET, [email protected] wrote:
Quoted 46 lines · Jiri Pirko
Quoted 5 lines · Mon, Nov 20, 2023 at 11:56:50PM CET, [email protected] wrote:
On Mon, Nov 20, 2023 at 4:49 PM Daniel Borkmann <[email protected]> wrote:
On 11/20/23 8:56 PM, Jamal Hadi Salim wrote:
On Mon, Nov 20, 2023 at 1:10 PM Jiri Pirko <[email protected]> wrote:
Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:[...]
Quoted 27 lines
tc BPF and XDP already have widely used infrastructure and can be developed
against libbpf or other user space libraries for a user space control plane.
With 'control plane' you refer here to the tc / netlink shim you've built,
but looking at the tc command line examples, this doesn't really provide a
good user experience (you call it p4 but people load bpf obj files). If the
expectation is that an operator should run tc commands, then neither it's
a nice experience for p4 nor for BPF folks. From a BPF PoV, we moved over
to bpf_mprog and plan to also extend this for XDP to have a common look and
feel wrt networking for developers. Why can't this be reused?The filter loading which loads the program is considered pipeline
instantiation - consider it as "provisioning" more than "control"
which runs at runtime. "control" is purely netlink based. The iproute2
code we use links libbpf for example for the filter. If we can achieve
the same with bpf_mprog then sure - we just dont want to loose
functionality though. off top of my head, some sample space:
- we could have multiple pipelines with different priorities (which tc
provides to us) - and each pipeline may have its own logic with many
tables etc (and the choice to iterate the next one is essentially
encoded in the tc action codes)
- we use tc block to map groups of ports (which i dont think bpf has
internal access of)In regards to usability: no i dont expect someone doing things at
scale to use command line tc. The APIs are via netlink. But the tc cli
is must for the rest of the masses per our traditions. Also i reallyI don't follow. You repeatedly mention "the must of the traditional tc cli", but what of the existing traditional cli you use for p4tc? If I look at the examples, pretty much everything looks new to me. Example:
tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1Quoted 6 lines
Quoted 3 lines
This is just TC/RTnetlink used as a channel to pass new things over. If that is the case, what's traditional here?
What is not traditional about it?
Okay, so in that case, the following example communitating with userspace deamon using imaginary "p4ctrl" app is equally traditional:
$ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1Quoted 7 lines
Quoted 4 lines
Huh? Thats just an application - classical tc which part of iproute2 that is sending to the kernel, no different than "tc flower.." Where do you get the "userspace" daemon part? Yes, you can write a daemon but it will use the same APIs as tc.
Okay, so which part is the "tradition"?
Quoted 8 lines
Provides tooling via tc cli that _everyone_ in the tc world is familiar with - which uses the same syntax as other tc extensions do, same expectations (eg events, request responses, familiar commands for dumping, flushing etc). Basically someone familiar with tc will pick this up and operate it very quickly and would have an easier time debugging it.
There are caveats - as will be with all new classifiers - but those are within reason.Okay, so syntax familiarity wise, what's the difference between following 2 approaches:
$ tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1 $ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1 ?Quoted 72 lines
Quoted 50 lines
Quoted 50 lines
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines
Quoted 24 lines
didnt even want to use ebpf at all for operator experience reasons -
it requires a compilation of the code and an extra loading compared to
what our original u32/pedit code offered.I don't quite follow why not most of this could be implemented entirely in
user space without the detour of this and you would provide a developer
library which could then be integrated into a p4 runtime/frontend? This
way users never interface with ebpf parts nor tc given they also shouldn't
have to - it's an implementation detail. This is what John was also pointing
out earlier.Netlink is the API. We will provide a library for object manipulation
which abstracts away the need to know netlink. Someone who for their
own reasons wants to use p4runtime or TDI could write on top of this.
I would not design a kernel interface to just meet p4runtime (we
already have TDI which came later which does things differently). So i
expect us to support both those two. And if i was to do something on
SDN that was more robust i would write my own that still uses these
netlink interfaces.Actually, what Daniel says about the p4 library used as a backend to p4 frontend is pretty much aligned what I claimed on the p4 calls couple of times. If you have this p4 userspace tooling, it is easy for offloads to replace the backed by vendor-specific library which allows p4 offload suitable for all vendors (your plan of p4tc offload does not work well for our hw, as we repeatedly claimed).
Quoted 8 lines
Quoted 6 lines
That's you - NVIDIA. You have chosen a path away from the kernel towards DOCA. I understand NVIDIA's frustration with dealing with upstream process (which has been cited to me as a good reason for DOCA) but please dont impose these values and your politics on other
vendors(Intel, AMD for example)who are more than willing to invest into making the kernel interfaces the path forward. Your choice.No, you are missing the point. This has nothing to do with DOCA.
Right Jiri ;->
Quoted 5 lines
This
has to do with the simple limitation of your offload assuming there are no runtime changes in the compiled pipeline. For Intel, maybe they aren't, and it's a good fit for them. All I say is, that it is not the good fit for everyone.Quoted 7 lines
Quoted 2 lines
a) it is not part of the P4 spec to dynamically make changes to the datapath pipeline after it is create and we are discussing a P4
Isn't this up to the implementation? I mean from the p4 perspective, everything is static. Hw might need to reshuffle the pipeline internally during rule insertion/remove in order to optimize the layout.
But do note: the focus here is on P4 (hence the name P4TC).
Quoted 12 lines
Quoted 11 lines
implementation not an extension that would add more value b) We are more than happy to add extensions in the future to accomodate for features but first
_P4spec_must be met c) we had longer discussions with Matty, Khalid and the Rice folks who wrote a paper on that topic which you probably didnt attend and everything that needs to be done can be from user space today for all those optimizations.Conclusion is: For what you need to do (which i dont believe is a limitation in your hardware rather a design decision on your part) run your user space daemon, do optimizations and update the datapath. Everybody is happy.
Quoted 7 lines
Quoted 3 lines
Should the userspace daemon listen on inserted rules to be offloade over netlink?
I mean you could if you wanted to given this is just traditional netlink which emits events (with some filtering when we integrate the filter approach). But why?
Nevermind.
Quoted 53 lines
Quoted 37 lines
Quoted 37 lines
Quoted 37 lines
Quoted 17 lines
Nobody is stopping you from offering your customers proprietary solutions which include a specific ebpf approach alongside DOCA. We believe that a singular interface regardless of the vendor is the right way forward. IMHO, this siloing that unfortunately is also added by eBPF being a double edged sword is not good for the community.
Quoted 8 lines
As I also said on the p4 call couple of times, I don't see the kernel as the correct place to do the p4 abstractions. Why don't you do it in userspace and give vendors possiblity to have p4 backends with compilers, runtime optimizations etc in userspace, talking to the HW in the vendor-suitable way too. Then the SW implementation could be easily eBPF and the main reason (I believe) why you need to have this is TC (offload) is then void.
Quoted 4 lines
Quoted 2 lines
The "everyone wants to use TC/netlink" claim does not seem correct to me. Why not to have one Linux p4 solution that fits everyones needs?
You mean more fitting to the DOCA world? no, because iam a kernel
Again, this has 0 relation to DOCA.
Quoted 1 line
first person and kernel interfaces are good for everyone.
Yeah, not really. Not always the kernel is the right answer. Your/Intel plan to handle the offload by:
1) abuse devlink to flash p4 binary
2) parse the binary in kernel to match to the table ids of rules coming from p4tcndo_setup_tc
3) abuse devlink to flash p4 binary for tc-flower
4) parse the binary in kernel to match to the table ids of rules coming from tc-flowerndo_setup_tc
is really something that is making me a little bit nauseous.Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
If you don't have a feasible plan to do the offload, p4tc does not make sense to me to be honest.
You mean if there's no plan to match your (NVIDIA?) point of view. For #1 - how's this different from DDP? Wasnt that your suggestion to
I doubt that. Any flashing-blob-parsing-in-kernel is something I'm opposed to from day 1.
Oh well - it is in the kernel and it works fine tbh.
Quoted 3 lines
Quoted 2 lines
begin with? For #2 Nobody is proposing to do anything of the sort. The ndo is passed IDs for the objects and associated contents. For #3+#4
Quoted 8 lines
Quoted 4 lines
During offload, you need to parse the blob in driver to be able to match the ids with blob entities. That was presented by you/Intel in the past IIRC.
You are correct - in case of offload the netlink IDs will have to be authenticated against what the hardware can accept, but the devlink flash use i believe was from you as a compromise.
Definitelly not. I'm against devlink abuse for this from day 1.
Quoted 23 lines
Quoted 15 lines
Quoted 4 lines
tc flower thing has nothing to do with P4TC that was just some random proposal someone made seeing if they could ride on top of P4TC.
Yeah, it's not yet merged and already mentally used for abuse. I love that :)
Quoted 6 lines
Besides this nobody really has to satisfy your point of view - like i said earlier feel free to provide proprietary solutions. From a consumer perspective I would not want to deal with 4 different vendors with 4 different proprietary approaches. The kernel is the unifying part. You seemed happier with tc flower just not with the
Quoted 7 lines
Yeah, that is my point, why the unifying part can't be a userspace daemon/library with multiple backends (p4tc, bpf, vendorX, vendorY, ..)?
I just don't see the kernel as a good fit for abstraction here, given the fact that the vendor compilers does not run in kernel. That is breaking your model.
Quoted 14 lines
Jiri - we want to support P4, first. Like you said the P4 pipeline, once installed is static.
P4 doesnt allow dynamic update of the pipeline. For example, once you say "here are my 14 tables and their associated actions and here's how the pipeline main control (on how to iterate the tables etc) is going to be" and after you instantiate/activate that pipeline, you dont go back 5 minutes later and say "sorry, please introduce table 15, which i want you to walk to after you visit table 3 if metadata foo is 5" or "shoot, let's change that table 5 to be exact instead of LPM". It's not anywhere in the spec.
That doesnt mean it is not useful thing to have - but it is an invention that has_nothingto do with the P4spec_; so saying a P4 implementation must support it is a bit out of scope and there are vendors with hardware who support P4 today that dont need any of this.I'm not talking about the spec. I'm talking about the offload implemetation, the offload compiler the offload runtime manager. You don't have those in kernel. That is the issue. The runtime manager is the one to decide and reshuffle the hw internals. Again, this has nothing to do with p4 frontend. This is offload implementation.
And that is why I believe your p4 kernel implementation is unoffloadable. And if it is unoffloadable, do we really need it? IDK.
Quoted 7 lines
Quoted 4 lines
Say what?
It's not offloadable in your hardware, you mean? Because i have beside me here an intel e2000 which offloads just fine (and the AMD folks seem fine too).Will Intel and AMD have compiler in kernel, so no blob transfer and parsing it in kernel wound not be needed? No.
By that definition anything that parses anything is a compiler.
Quoted 10 lines
Quoted 9 lines
If your view is that all these runtime optimization surmount to a compiler in the kernel/driver that is your, well, your view. In my view (and others have said this to you already) the P4C compiler is responsible for resource optimizations. The hardware supports P4, you give it constraints and it knows what to do. At runtime, anything a driver needs to do for resource optimization (resorting, reshuffling etc), that is not a P4 problem - sorry if you have issues in your architecture approach.
Quoted 3 lines
Sure, it is the offload implementation problem. And for them, you need to use userspace components. And that is the problem. This discussion leads nowhere, I don't know how differently I should describe this.
Jiri's - that's your view based on whatever design you have in your mind. This has nothing to do with P4.
So let me repeat again:
1) A vendor's backend for P4 when it compiles ensures that resource constraints are taken care of.
2) The same program can run in s/w.
3) It makes *ZERO* sense to mix vendor specific constraintoptimization(what you described as resorting, reshuffling etc)as part of P4TC or P4. Absolutely nothing to do with either. Write a
Quoted 6 lines
Quoted 2 lines
I never suggested for it to be part of P4tc of P4. I don't know why you think so.
I guess because this discussion is about P4/P4TC? I may have misread what you are saying then because I saw the "P4TC must be in userspace" mantra tied to this specific optimization requirement.
Yeah, and again, my point is, this is unoffloadable. Do we still need it in kernel?
Quoted 72 lines
Quoted 7 lines
Quoted 4 lines
background task, specific to you, if you feel you need to move things around at runtime.
Yeah, that backgroud task is in userspace.
I don't have a horse in this race.
cheers,
jamalQuoted 59 lines
Quoted 3 lines
We agree on one thing at least: This discussion is going nowhere.
Correct.
Quoted 53 lines
cheers,
jamalQuoted 47 lines
Quoted 47 lines
Quoted 21 lines
Quoted 10 lines
In my opinion that is a feature that could be added later out of necessity (there is some good niche value in being able to add some "dynamicism" to any pipeline) and influence the P4 standards on why it is needed.
It should be doable today in a brute force way (this is just one suggestion that came to me when Rice University/Nvidia presented[1]); i am sure there are other approaches and the idea is by no means proven.Quoted 10 lines
1) User space Creates/compiles/Adds/activate your program that has 14 tables at tc prio X chain Y
2) a) 5 minutes later user space decides it wants to change and add table 3 after table 15, visited when metadata foo=5
b) your compiler in user space compiles a brand new program which
satisfies #2a (how this program was authored is out of scope of discussion)
c) user space adds the new program at tc prio X+1 chain Y or another chain Z
d) user space delete tc prio X chain Y (and make sure your packets
entry point is whatever #c is)Quoted 2 lines
I never suggested anything like what you describe. I'm not sure why you think so.
It's the same class of problems - the paper i pointed to (coauthored by Matty and others) has runtime resource optimizations which are tantamount to changing the nature of the pipeline. We may need to profile in the kernel but all those optimizations can be derived in user space using the approach I described.
cheers,
jamalQuoted 13 lines
Quoted 13 lines
[1] https://www.cs.rice.edu/~eugeneng/papers/SIGCOMM23-Pipeleon.pdf
Quoted 11 lines
Quoted 11 lines
kernel process - which is ironically the same thing we are going through here ;->
cheers,
jamalQuoted 4 lines
Quoted 4 lines
cheers,
jamal
Jamal Hadi Salim
maintainerQuoted 332 lines · Jiri Pirko
Quoted 330 lines · Thu, Nov 23, 2023 at 02:45:50PM CET, [email protected] wrote:
Quoted 329 lines · Jiri Pirko
Quoted 326 lines · Thu, Nov 23, 2023 at 02:22:11PM CET, [email protected] wrote:
Quoted 292 lines · Jiri Pirko
Quoted 290 lines · Wed, Nov 22, 2023 at 08:35:21PM CET, [email protected] wrote:
Quoted 288 lines · Jiri Pirko
Quoted 73 lines · Wed, Nov 22, 2023 at 04:14:02PM CET, [email protected] wrote:
Quoted 64 lines · Jiri Pirko
Quoted 62 lines · Tue, Nov 21, 2023 at 04:21:44PM CET, [email protected] wrote:
Quoted 60 lines · Jiri Pirko
Quoted 47 lines · Tue, Nov 21, 2023 at 02:47:40PM CET, [email protected] wrote:
Quoted 46 lines · Jiri Pirko
Mon, Nov 20, 2023 at 11:56:50PM CET, [email protected] wrote:
On Mon, Nov 20, 2023 at 4:49 PM Daniel Borkmann <[email protected]> wrote:On 11/20/23 8:56 PM, Jamal Hadi Salim wrote:
On Mon, Nov 20, 2023 at 1:10 PM Jiri Pirko <[email protected]> wrote:
Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:[...]
tc BPF and XDP already have widely used infrastructure and can be developed
against libbpf or other user space libraries for a user space control plane.
With 'control plane' you refer here to the tc / netlink shim you've built,
but looking at the tc command line examples, this doesn't really provide a
good user experience (you call it p4 but people load bpf obj files). If the
expectation is that an operator should run tc commands, then neither it's
a nice experience for p4 nor for BPF folks. From a BPF PoV, we moved over
to bpf_mprog and plan to also extend this for XDP to have a common look and
feel wrt networking for developers. Why can't this be reused?The filter loading which loads the program is considered pipeline
instantiation - consider it as "provisioning" more than "control"
which runs at runtime. "control" is purely netlink based. The iproute2
code we use links libbpf for example for the filter. If we can achieve
the same with bpf_mprog then sure - we just dont want to loose
functionality though. off top of my head, some sample space:
- we could have multiple pipelines with different priorities (which tc
provides to us) - and each pipeline may have its own logic with many
tables etc (and the choice to iterate the next one is essentially
encoded in the tc action codes)
- we use tc block to map groups of ports (which i dont think bpf has
internal access of)In regards to usability: no i dont expect someone doing things at
scale to use command line tc. The APIs are via netlink. But the tc cli
is must for the rest of the masses per our traditions. Also i reallyI don't follow. You repeatedly mention "the must of the traditional tc
cli", but what of the existing traditional cli you use for p4tc?
If I look at the examples, pretty much everything looks new to me.
Example:tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \
action send_to_port param port eno1Quoted 6 lines
Quoted 3 lines
This is just TC/RTnetlink used as a channel to pass new things over. If
that is the case, what's traditional here?What is not traditional about it?
Okay, so in that case, the following example communitating with userspace deamon using imaginary "p4ctrl" app is equally traditional:
$ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1Quoted 7 lines
Quoted 4 lines
Huh? Thats just an application - classical tc which part of iproute2 that is sending to the kernel, no different than "tc flower.." Where do you get the "userspace" daemon part? Yes, you can write a daemon but it will use the same APIs as tc.
Okay, so which part is the "tradition"?
Quoted 8 lines
Provides tooling via tc cli that _everyone_ in the tc world is familiar with - which uses the same syntax as other tc extensions do, same expectations (eg events, request responses, familiar commands for dumping, flushing etc). Basically someone familiar with tc will pick this up and operate it very quickly and would have an easier time debugging it.
There are caveats - as will be with all new classifiers - but those are within reason.Okay, so syntax familiarity wise, what's the difference between following 2 approaches:
$ tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1 $ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1 ?Quoted 72 lines
Quoted 50 lines
Quoted 50 lines
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines
didnt even want to use ebpf at all for operator experience reasons -
it requires a compilation of the code and an extra loading compared to
what our original u32/pedit code offered.I don't quite follow why not most of this could be implemented entirely in
user space without the detour of this and you would provide a developer
library which could then be integrated into a p4 runtime/frontend? This
way users never interface with ebpf parts nor tc given they also shouldn't
have to - it's an implementation detail. This is what John was also pointing
out earlier.Netlink is the API. We will provide a library for object manipulation
which abstracts away the need to know netlink. Someone who for their
own reasons wants to use p4runtime or TDI could write on top of this.
I would not design a kernel interface to just meet p4runtime (we
already have TDI which came later which does things differently). So i
expect us to support both those two. And if i was to do something on
SDN that was more robust i would write my own that still uses these
netlink interfaces.Actually, what Daniel says about the p4 library used as a backend to p4
frontend is pretty much aligned what I claimed on the p4 calls couple of
times. If you have this p4 userspace tooling, it is easy for offloads to
replace the backed by vendor-specific library which allows p4 offload
suitable for all vendors (your plan of p4tc offload does not work well
for our hw, as we repeatedly claimed).Quoted 8 lines
Quoted 6 lines
That's you - NVIDIA. You have chosen a path away from the kernel towards DOCA. I understand NVIDIA's frustration with dealing with upstream process (which has been cited to me as a good reason for DOCA) but please dont impose these values and your politics on other
vendors(Intel, AMD for example)who are more than willing to invest into making the kernel interfaces the path forward. Your choice.No, you are missing the point. This has nothing to do with DOCA.
Right Jiri ;->
Quoted 5 lines
This
has to do with the simple limitation of your offload assuming there are no runtime changes in the compiled pipeline. For Intel, maybe they aren't, and it's a good fit for them. All I say is, that it is not the good fit for everyone.Quoted 7 lines
Quoted 2 lines
a) it is not part of the P4 spec to dynamically make changes to the datapath pipeline after it is create and we are discussing a P4
Isn't this up to the implementation? I mean from the p4 perspective, everything is static. Hw might need to reshuffle the pipeline internally during rule insertion/remove in order to optimize the layout.
But do note: the focus here is on P4 (hence the name P4TC).
Quoted 12 lines
Quoted 11 lines
implementation not an extension that would add more value b) We are more than happy to add extensions in the future to accomodate for features but first
_P4spec_must be met c) we had longer discussions with Matty, Khalid and the Rice folks who wrote a paper on that topic which you probably didnt attend and everything that needs to be done can be from user space today for all those optimizations.Conclusion is: For what you need to do (which i dont believe is a limitation in your hardware rather a design decision on your part) run your user space daemon, do optimizations and update the datapath. Everybody is happy.
Quoted 7 lines
Quoted 3 lines
Should the userspace daemon listen on inserted rules to be offloade over netlink?
I mean you could if you wanted to given this is just traditional netlink which emits events (with some filtering when we integrate the filter approach). But why?
Nevermind.
Quoted 53 lines
Quoted 37 lines
Quoted 37 lines
Quoted 37 lines
Quoted 17 lines
Nobody is stopping you from offering your customers proprietary solutions which include a specific ebpf approach alongside DOCA. We believe that a singular interface regardless of the vendor is the right way forward. IMHO, this siloing that unfortunately is also added by eBPF being a double edged sword is not good for the community.
Quoted 8 lines
As I also said on the p4 call couple of times, I don't see the kernel
as the correct place to do the p4 abstractions. Why don't you do it in
userspace and give vendors possiblity to have p4 backends with compilers,
runtime optimizations etc in userspace, talking to the HW in the
vendor-suitable way too. Then the SW implementation could be easily eBPF
and the main reason (I believe) why you need to have this is TC
(offload) is then void.Quoted 4 lines
Quoted 2 lines
The "everyone wants to use TC/netlink" claim does not seem correct
to me. Why not to have one Linux p4 solution that fits everyones needs?You mean more fitting to the DOCA world? no, because iam a kernel
Again, this has 0 relation to DOCA.
Quoted 1 line
first person and kernel interfaces are good for everyone.
Yeah, not really. Not always the kernel is the right answer. Your/Intel plan to handle the offload by:
1) abuse devlink to flash p4 binary
2) parse the binary in kernel to match to the table ids of rules coming from p4tcndo_setup_tc
3) abuse devlink to flash p4 binary for tc-flower
4) parse the binary in kernel to match to the table ids of rules coming from tc-flowerndo_setup_tc
is really something that is making me a little bit nauseous.Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
If you don't have a feasible plan to do the offload, p4tc does not make sense to me to be honest.
You mean if there's no plan to match your (NVIDIA?) point of view. For #1 - how's this different from DDP? Wasnt that your suggestion to
I doubt that. Any flashing-blob-parsing-in-kernel is something I'm opposed to from day 1.
Oh well - it is in the kernel and it works fine tbh.
Quoted 3 lines
Quoted 2 lines
begin with? For #2 Nobody is proposing to do anything of the sort. The ndo is passed IDs for the objects and associated contents. For #3+#4
Quoted 8 lines
Quoted 4 lines
During offload, you need to parse the blob in driver to be able to match the ids with blob entities. That was presented by you/Intel in the past IIRC.
You are correct - in case of offload the netlink IDs will have to be authenticated against what the hardware can accept, but the devlink flash use i believe was from you as a compromise.
Definitelly not. I'm against devlink abuse for this from day 1.
Quoted 23 lines
Quoted 15 lines
Quoted 4 lines
tc flower thing has nothing to do with P4TC that was just some random proposal someone made seeing if they could ride on top of P4TC.
Yeah, it's not yet merged and already mentally used for abuse. I love that :)
Quoted 6 lines
Besides this nobody really has to satisfy your point of view - like i said earlier feel free to provide proprietary solutions. From a consumer perspective I would not want to deal with 4 different vendors with 4 different proprietary approaches. The kernel is the unifying part. You seemed happier with tc flower just not with the
Quoted 7 lines
Yeah, that is my point, why the unifying part can't be a userspace daemon/library with multiple backends (p4tc, bpf, vendorX, vendorY, ..)?
I just don't see the kernel as a good fit for abstraction here, given the fact that the vendor compilers does not run in kernel. That is breaking your model.
Quoted 14 lines
Jiri - we want to support P4, first. Like you said the P4 pipeline, once installed is static.
P4 doesnt allow dynamic update of the pipeline. For example, once you say "here are my 14 tables and their associated actions and here's how the pipeline main control (on how to iterate the tables etc) is going to be" and after you instantiate/activate that pipeline, you dont go back 5 minutes later and say "sorry, please introduce table 15, which i want you to walk to after you visit table 3 if metadata foo is 5" or "shoot, let's change that table 5 to be exact instead of LPM". It's not anywhere in the spec.
That doesnt mean it is not useful thing to have - but it is an invention that has_nothingto do with the P4spec_; so saying a P4 implementation must support it is a bit out of scope and there are vendors with hardware who support P4 today that dont need any of this.I'm not talking about the spec. I'm talking about the offload implemetation, the offload compiler the offload runtime manager. You don't have those in kernel. That is the issue. The runtime manager is the one to decide and reshuffle the hw internals. Again, this has nothing to do with p4 frontend. This is offload implementation.
And that is why I believe your p4 kernel implementation is unoffloadable. And if it is unoffloadable, do we really need it? IDK.
Quoted 7 lines
Quoted 4 lines
Say what?
It's not offloadable in your hardware, you mean? Because i have beside me here an intel e2000 which offloads just fine (and the AMD folks seem fine too).Will Intel and AMD have compiler in kernel, so no blob transfer and parsing it in kernel wound not be needed? No.
By that definition anything that parses anything is a compiler.
Quoted 10 lines
Quoted 9 lines
If your view is that all these runtime optimization surmount to a compiler in the kernel/driver that is your, well, your view. In my view (and others have said this to you already) the P4C compiler is responsible for resource optimizations. The hardware supports P4, you give it constraints and it knows what to do. At runtime, anything a driver needs to do for resource optimization (resorting, reshuffling etc), that is not a P4 problem - sorry if you have issues in your architecture approach.
Quoted 3 lines
Sure, it is the offload implementation problem. And for them, you need to use userspace components. And that is the problem. This discussion leads nowhere, I don't know how differently I should describe this.
Jiri's - that's your view based on whatever design you have in your mind. This has nothing to do with P4.
So let me repeat again:
1) A vendor's backend for P4 when it compiles ensures that resource constraints are taken care of.
2) The same program can run in s/w.
3) It makes *ZERO* sense to mix vendor specific constraintoptimization(what you described as resorting, reshuffling etc)as part of P4TC or P4. Absolutely nothing to do with either. Write a
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
I never suggested for it to be part of P4tc of P4. I don't know why you think so.
I guess because this discussion is about P4/P4TC? I may have misread what you are saying then because I saw the "P4TC must be in userspace" mantra tied to this specific optimization requirement.
Yeah, and again, my point is, this is unoffloadable.
Here we go again with this weird claim. I guess we need to give an award to the other vendors for doing the "impossible"?
Quoted 1 line
Do we still need it in kernel?
Didnt you just say it has nothing to do with P4TC?
You "It cant be offloaded".
Me "it can be offloaded, other vendors are doing it and it has nothing to do with P4 or P4TC and here's why..."
You " i didnt say it has anything to do with P4 or P4TC"
Me "ok i misunderstood i thought you said P4 cant be offloaded via P4TC and has to be done in user space"
You "It cant be offloaded"
Circular non-ending discussion.
Then there's John
John "ebpf, ebpf, ebpf"
Me "we gave you ebpf"
John "but you are not using ebpf system call"
Me " but it doesnt make sense for the following reasons..." John "but someone has already implemented ebpf.." Me "yes, but here's how ..."
John "ebpf, ebpf, ebpf"
Another circular non-ending discussion.
Let's just end this electron-wasting lawyering discussion.
cheers,
jamal
Bizare. Unoffloadable according to you.
Quoted 73 lines
Quoted 73 lines
Quoted 8 lines
Quoted 5 lines
background task, specific to you, if you feel you need to move things around at runtime.
Yeah, that backgroud task is in userspace.
I don't have a horse in this race.
cheers,
jamalQuoted 59 lines
Quoted 3 lines
We agree on one thing at least: This discussion is going nowhere.
Correct.
Quoted 53 lines
cheers,
jamalQuoted 47 lines
Quoted 47 lines
Quoted 21 lines
Quoted 10 lines
In my opinion that is a feature that could be added later out of necessity (there is some good niche value in being able to add some "dynamicism" to any pipeline) and influence the P4 standards on why it is needed.
It should be doable today in a brute force way (this is just one suggestion that came to me when Rice University/Nvidia presented[1]); i am sure there are other approaches and the idea is by no means proven.Quoted 10 lines
1) User space Creates/compiles/Adds/activate your program that has 14 tables at tc prio X chain Y
2) a) 5 minutes later user space decides it wants to change and add table 3 after table 15, visited when metadata foo=5
b) your compiler in user space compiles a brand new program which
satisfies #2a (how this program was authored is out of scope of discussion)
c) user space adds the new program at tc prio X+1 chain Y or another chain Z
d) user space delete tc prio X chain Y (and make sure your packets
entry point is whatever #c is)Quoted 2 lines
I never suggested anything like what you describe. I'm not sure why you think so.
It's the same class of problems - the paper i pointed to (coauthored by Matty and others) has runtime resource optimizations which are tantamount to changing the nature of the pipeline. We may need to profile in the kernel but all those optimizations can be derived in user space using the approach I described.
cheers,
jamalQuoted 13 lines
Quoted 13 lines
[1] https://www.cs.rice.edu/~eugeneng/papers/SIGCOMM23-Pipeleon.pdf
Quoted 11 lines
Quoted 11 lines
kernel process - which is ironically the same thing we are going through here ;->
cheers,
jamalQuoted 4 lines
Quoted 4 lines
cheers,
jamal
Jiri Pirko
maintainerQuoted 336 lines · Thu, Nov 23, 2023 at 03:28:07PM CET, [email protected] wrote:
Quoted 335 lines · Jiri Pirko
Quoted 333 lines · Thu, Nov 23, 2023 at 02:45:50PM CET, [email protected] wrote:
Quoted 331 lines · Jiri Pirko
Quoted 317 lines · Thu, Nov 23, 2023 at 02:22:11PM CET, [email protected] wrote:
Quoted 292 lines · Jiri Pirko
Quoted 290 lines · Wed, Nov 22, 2023 at 08:35:21PM CET, [email protected] wrote:
Quoted 288 lines · Jiri Pirko
Quoted 73 lines · Wed, Nov 22, 2023 at 04:14:02PM CET, [email protected] wrote:
Quoted 64 lines · Jiri Pirko
Quoted 62 lines · Tue, Nov 21, 2023 at 04:21:44PM CET, [email protected] wrote:
Quoted 60 lines · Jiri Pirko
Quoted 53 lines · Tue, Nov 21, 2023 at 02:47:40PM CET, [email protected] wrote:
On Tue, Nov 21, 2023 at 8:06 AM Jiri Pirko <[email protected]> wrote:
Mon, Nov 20, 2023 at 11:56:50PM CET, [email protected] wrote:
On Mon, Nov 20, 2023 at 4:49 PM Daniel Borkmann <[email protected]> wrote:On 11/20/23 8:56 PM, Jamal Hadi Salim wrote:
On Mon, Nov 20, 2023 at 1:10 PM Jiri Pirko <[email protected]> wrote:
Mon, Nov 20, 2023 at 03:23:59PM CET, [email protected] wrote:[...]
tc BPF and XDP already have widely used infrastructure and can be developed
against libbpf or other user space libraries for a user space control plane.
With 'control plane' you refer here to the tc / netlink shim you've built,
but looking at the tc command line examples, this doesn't really provide a
good user experience (you call it p4 but people load bpf obj files). If the
expectation is that an operator should run tc commands, then neither it's
a nice experience for p4 nor for BPF folks. From a BPF PoV, we moved over
to bpf_mprog and plan to also extend this for XDP to have a common look and
feel wrt networking for developers. Why can't this be reused?The filter loading which loads the program is considered pipeline
instantiation - consider it as "provisioning" more than "control"
which runs at runtime. "control" is purely netlink based. The iproute2
code we use links libbpf for example for the filter. If we can achieve
the same with bpf_mprog then sure - we just dont want to loose
functionality though. off top of my head, some sample space:
- we could have multiple pipelines with different priorities (which tc
provides to us) - and each pipeline may have its own logic with many
tables etc (and the choice to iterate the next one is essentially
encoded in the tc action codes)
- we use tc block to map groups of ports (which i dont think bpf has
internal access of)In regards to usability: no i dont expect someone doing things at
scale to use command line tc. The APIs are via netlink. But the tc cli
is must for the rest of the masses per our traditions. Also i reallyI don't follow. You repeatedly mention "the must of the traditional tc
cli", but what of the existing traditional cli you use for p4tc?
If I look at the examples, pretty much everything looks new to me.
Example:tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \
action send_to_port param port eno1This is just TC/RTnetlink used as a channel to pass new things over. If
that is the case, what's traditional here?What is not traditional about it?
Okay, so in that case, the following example communitating with userspace deamon using imaginary "p4ctrl" app is equally traditional:
$ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1Quoted 7 lines
Quoted 4 lines
Huh? Thats just an application - classical tc which part of iproute2 that is sending to the kernel, no different than "tc flower.." Where do you get the "userspace" daemon part? Yes, you can write a daemon but it will use the same APIs as tc.
Okay, so which part is the "tradition"?
Quoted 8 lines
Provides tooling via tc cli that _everyone_ in the tc world is familiar with - which uses the same syntax as other tc extensions do, same expectations (eg events, request responses, familiar commands for dumping, flushing etc). Basically someone familiar with tc will pick this up and operate it very quickly and would have an easier time debugging it.
There are caveats - as will be with all new classifiers - but those are within reason.Okay, so syntax familiarity wise, what's the difference between following 2 approaches:
$ tc p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1 $ p4ctrl create myprog/table/mytable dstAddr 10.0.1.2/32 \ action send_to_port param port eno1 ?Quoted 72 lines
Quoted 50 lines
Quoted 50 lines
Quoted 33 lines
Quoted 33 lines
didnt even want to use ebpf at all for operator experience reasons -
it requires a compilation of the code and an extra loading compared to
what our original u32/pedit code offered.I don't quite follow why not most of this could be implemented entirely in
user space without the detour of this and you would provide a developer
library which could then be integrated into a p4 runtime/frontend? This
way users never interface with ebpf parts nor tc given they also shouldn't
have to - it's an implementation detail. This is what John was also pointing
out earlier.Netlink is the API. We will provide a library for object manipulation
which abstracts away the need to know netlink. Someone who for their
own reasons wants to use p4runtime or TDI could write on top of this.
I would not design a kernel interface to just meet p4runtime (we
already have TDI which came later which does things differently). So i
expect us to support both those two. And if i was to do something on
SDN that was more robust i would write my own that still uses these
netlink interfaces.Actually, what Daniel says about the p4 library used as a backend to p4
frontend is pretty much aligned what I claimed on the p4 calls couple of
times. If you have this p4 userspace tooling, it is easy for offloads to
replace the backed by vendor-specific library which allows p4 offload
suitable for all vendors (your plan of p4tc offload does not work well
for our hw, as we repeatedly claimed).Quoted 8 lines
Quoted 6 lines
That's you - NVIDIA. You have chosen a path away from the kernel
towards DOCA. I understand NVIDIA's frustration with dealing with
upstream process (which has been cited to me as a good reason for
DOCA) but please dont impose these values and your politics on other
vendors(Intel, AMD for example) who are more than willing to invest
into making the kernel interfaces the path forward. Your choice.No, you are missing the point. This has nothing to do with DOCA.
Right Jiri ;->
Quoted 5 lines
This
has to do with the simple limitation of your offload assuming there are no runtime changes in the compiled pipeline. For Intel, maybe they aren't, and it's a good fit for them. All I say is, that it is not the good fit for everyone.Quoted 7 lines
Quoted 2 lines
a) it is not part of the P4 spec to dynamically make changes to the datapath pipeline after it is create and we are discussing a P4
Isn't this up to the implementation? I mean from the p4 perspective, everything is static. Hw might need to reshuffle the pipeline internally during rule insertion/remove in order to optimize the layout.
But do note: the focus here is on P4 (hence the name P4TC).
Quoted 12 lines
Quoted 11 lines
implementation not an extension that would add more value b) We are more than happy to add extensions in the future to accomodate for features but first
_P4spec_must be met c) we had longer discussions with Matty, Khalid and the Rice folks who wrote a paper on that topic which you probably didnt attend and everything that needs to be done can be from user space today for all those optimizations.Conclusion is: For what you need to do (which i dont believe is a limitation in your hardware rather a design decision on your part) run your user space daemon, do optimizations and update the datapath. Everybody is happy.
Quoted 7 lines
Quoted 3 lines
Should the userspace daemon listen on inserted rules to be offloade over netlink?
I mean you could if you wanted to given this is just traditional netlink which emits events (with some filtering when we integrate the filter approach). But why?
Nevermind.
Quoted 53 lines
Quoted 37 lines
Quoted 37 lines
Quoted 37 lines
Quoted 21 lines
Nobody is stopping you from offering your customers proprietary
solutions which include a specific ebpf approach alongside DOCA. We
believe that a singular interface regardless of the vendor is the
right way forward. IMHO, this siloing that unfortunately is also added
by eBPF being a double edged sword is not good for the community.As I also said on the p4 call couple of times, I don't see the kernel
as the correct place to do the p4 abstractions. Why don't you do it in
userspace and give vendors possiblity to have p4 backends with compilers,
runtime optimizations etc in userspace, talking to the HW in the
vendor-suitable way too. Then the SW implementation could be easily eBPF
and the main reason (I believe) why you need to have this is TC
(offload) is then void.The "everyone wants to use TC/netlink" claim does not seem correct
to me. Why not to have one Linux p4 solution that fits everyones needs?You mean more fitting to the DOCA world? no, because iam a kernel
Again, this has 0 relation to DOCA.
Quoted 1 line
first person and kernel interfaces are good for everyone.
Yeah, not really. Not always the kernel is the right answer. Your/Intel plan to handle the offload by:
1) abuse devlink to flash p4 binary
2) parse the binary in kernel to match to the table ids of rules coming from p4tcndo_setup_tc
3) abuse devlink to flash p4 binary for tc-flower
4) parse the binary in kernel to match to the table ids of rules coming from tc-flowerndo_setup_tc
is really something that is making me a little bit nauseous.Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
If you don't have a feasible plan to do the offload, p4tc does not make sense to me to be honest.
You mean if there's no plan to match your (NVIDIA?) point of view. For #1 - how's this different from DDP? Wasnt that your suggestion to
I doubt that. Any flashing-blob-parsing-in-kernel is something I'm opposed to from day 1.
Oh well - it is in the kernel and it works fine tbh.
Quoted 3 lines
Quoted 2 lines
begin with? For #2 Nobody is proposing to do anything of the sort. The ndo is passed IDs for the objects and associated contents. For #3+#4
Quoted 8 lines
Quoted 4 lines
During offload, you need to parse the blob in driver to be able to match the ids with blob entities. That was presented by you/Intel in the past IIRC.
You are correct - in case of offload the netlink IDs will have to be authenticated against what the hardware can accept, but the devlink flash use i believe was from you as a compromise.
Definitelly not. I'm against devlink abuse for this from day 1.
Quoted 23 lines
Quoted 15 lines
Quoted 4 lines
tc flower thing has nothing to do with P4TC that was just some random proposal someone made seeing if they could ride on top of P4TC.
Yeah, it's not yet merged and already mentally used for abuse. I love that :)
Quoted 6 lines
Besides this nobody really has to satisfy your point of view - like i said earlier feel free to provide proprietary solutions. From a consumer perspective I would not want to deal with 4 different vendors with 4 different proprietary approaches. The kernel is the unifying part. You seemed happier with tc flower just not with the
Quoted 7 lines
Yeah, that is my point, why the unifying part can't be a userspace daemon/library with multiple backends (p4tc, bpf, vendorX, vendorY, ..)?
I just don't see the kernel as a good fit for abstraction here, given the fact that the vendor compilers does not run in kernel. That is breaking your model.
Quoted 14 lines
Jiri - we want to support P4, first. Like you said the P4 pipeline, once installed is static.
P4 doesnt allow dynamic update of the pipeline. For example, once you say "here are my 14 tables and their associated actions and here's how the pipeline main control (on how to iterate the tables etc) is going to be" and after you instantiate/activate that pipeline, you dont go back 5 minutes later and say "sorry, please introduce table 15, which i want you to walk to after you visit table 3 if metadata foo is 5" or "shoot, let's change that table 5 to be exact instead of LPM". It's not anywhere in the spec.
That doesnt mean it is not useful thing to have - but it is an invention that has_nothingto do with the P4spec_; so saying a P4 implementation must support it is a bit out of scope and there are vendors with hardware who support P4 today that dont need any of this.I'm not talking about the spec. I'm talking about the offload implemetation, the offload compiler the offload runtime manager. You don't have those in kernel. That is the issue. The runtime manager is the one to decide and reshuffle the hw internals. Again, this has nothing to do with p4 frontend. This is offload implementation.
And that is why I believe your p4 kernel implementation is unoffloadable. And if it is unoffloadable, do we really need it? IDK.
Quoted 7 lines
Quoted 4 lines
Say what?
It's not offloadable in your hardware, you mean? Because i have beside me here an intel e2000 which offloads just fine (and the AMD folks seem fine too).Will Intel and AMD have compiler in kernel, so no blob transfer and parsing it in kernel wound not be needed? No.
By that definition anything that parses anything is a compiler.
Quoted 10 lines
Quoted 9 lines
If your view is that all these runtime optimization surmount to a compiler in the kernel/driver that is your, well, your view. In my view (and others have said this to you already) the P4C compiler is responsible for resource optimizations. The hardware supports P4, you give it constraints and it knows what to do. At runtime, anything a driver needs to do for resource optimization (resorting, reshuffling etc), that is not a P4 problem - sorry if you have issues in your architecture approach.
Quoted 3 lines
Sure, it is the offload implementation problem. And for them, you need to use userspace components. And that is the problem. This discussion leads nowhere, I don't know how differently I should describe this.
Quoted 9 lines
Jiri's - that's your view based on whatever design you have in your mind. This has nothing to do with P4.
So let me repeat again:
1) A vendor's backend for P4 when it compiles ensures that resource constraints are taken care of.
2) The same program can run in s/w.
3) It makes *ZERO* sense to mix vendor specific constraintoptimization(what you described as resorting, reshuffling etc)as part of P4TC or P4. Absolutely nothing to do with either. Write aI never suggested for it to be part of P4tc of P4. I don't know why you think so.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I guess because this discussion is about P4/P4TC? I may have misread what you are saying then because I saw the "P4TC must be in userspace" mantra tied to this specific optimization requirement.
Yeah, and again, my point is, this is unoffloadable.
Here we go again with this weird claim. I guess we need to give an award to the other vendors for doing the "impossible"?
By having the compiler in kernel, that would be awesome. Clear offload from kernel to device.
That's not the case. Trampolines, binary blobs parsing in kernel doing the match with tc structures in drivers, abuse of devlink flash, tc-flower offload using this facility. All this was already seriously discussed before p4tc is even merged. Great, love that.
Quoted 5 lines
Quoted 2 lines
Do we still need it in kernel?
Didnt you just say it has nothing to do with P4TC?
Quoted 7 lines
You "It cant be offloaded".
Me "it can be offloaded, other vendors are doing it and it has nothing to do with P4 or P4TC and here's why..."
You " i didnt say it has anything to do with P4 or P4TC"
Me "ok i misunderstood i thought you said P4 cant be offloaded via P4TC and has to be done in user space"
You "It cant be offloaded"
Let me do my own misinterpretation please.
Quoted 99 lines
Circular non-ending discussion.
Then there's John
John "ebpf, ebpf, ebpf"
Me "we gave you ebpf"
John "but you are not using ebpf system call"
Me " but it doesnt make sense for the following reasons..." John "but someone has already implemented ebpf.." Me "yes, but here's how ..."
John "ebpf, ebpf, ebpf"Another circular non-ending discussion.
Let's just end this electron-wasting lawyering discussion.
cheers,
jamalBizare. Unoffloadable according to you.
Quoted 73 lines
Quoted 73 lines
Quoted 8 lines
Quoted 5 lines
background task, specific to you, if you feel you need to move things around at runtime.
Yeah, that backgroud task is in userspace.
I don't have a horse in this race.
cheers,
jamalQuoted 59 lines
Quoted 3 lines
We agree on one thing at least: This discussion is going nowhere.
Correct.
Quoted 53 lines
cheers,
jamalQuoted 47 lines
Quoted 47 lines
Quoted 21 lines
Quoted 10 lines
In my opinion that is a feature that could be added later out of necessity (there is some good niche value in being able to add some "dynamicism" to any pipeline) and influence the P4 standards on why it is needed.
It should be doable today in a brute force way (this is just one suggestion that came to me when Rice University/Nvidia presented[1]); i am sure there are other approaches and the idea is by no means proven.Quoted 10 lines
1) User space Creates/compiles/Adds/activate your program that has 14 tables at tc prio X chain Y
2) a) 5 minutes later user space decides it wants to change and add table 3 after table 15, visited when metadata foo=5
b) your compiler in user space compiles a brand new program which
satisfies #2a (how this program was authored is out of scope of discussion)
c) user space adds the new program at tc prio X+1 chain Y or another chain Z
d) user space delete tc prio X chain Y (and make sure your packets
entry point is whatever #c is)Quoted 2 lines
I never suggested anything like what you describe. I'm not sure why you think so.
It's the same class of problems - the paper i pointed to (coauthored by Matty and others) has runtime resource optimizations which are tantamount to changing the nature of the pipeline. We may need to profile in the kernel but all those optimizations can be derived in user space using the approach I described.
cheers,
jamalQuoted 13 lines
Quoted 13 lines
[1] https://www.cs.rice.edu/~eugeneng/papers/SIGCOMM23-Pipeleon.pdf
Quoted 11 lines
Quoted 11 lines
kernel process - which is ironically the same thing we are going through here ;->
cheers,
jamalQuoted 4 lines
Quoted 4 lines
cheers,
jamal