Skip to contentSkip to conversation

net:sched: Introduce tc flower2 classifier based on PANDA parser in kernel

RFC PATCH In review Felipe Magno de Almeida 8 participants 24 messages Sep 16, 2021 – Sep 26, 2021 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover net:sched: Introduce tc flower2 classifier based on PANDA parser in kernel

From: Felipe Magno de Almeida <[email protected]>

The venerable Linux flow dissector has proven to be quite useful over the years as a way to quickly and flexibly analyze packets to extract header metadata information for a variety of purposes.

Some history:

The grandfather of the modern day flow dissector was introduced by Tom Herbert in 2010 to extract IP addresses and port numbers for plain TCP and UDP packets. Eric Dumazet centralized the code in 2011 and flow dissector was born as the first skb_flow_dissect(). In 2017, Jiri Pirko added support to make the header metadata extraction programmable and added support for tc flower classifier which uses flow dissector as its parser. In 2018, Peter Penkov added a bpf hook to allow customization of the flow dissector parsing. Over the years various protocols have been added to the flow dissector and it has grown to be a rather complex thousand line function.

While flow dissector has proven quite useful, it does have some shortcomings that are becoming increasingly noticeable as we continue to expand the functionality of the stack:

- It has been prone to bugs, especially in the required bookkeeping, as new protocols are added
- Not being able to parse UDP payloads or multi-leveled encapsulations.
- Customizing parsing behavior is impossible and requires multiple workarounds on client code to avoid pitfalls in special cases handled by flow dissector and to avoid unnecessary overhead
- For consumers that depend on the mapping in user space as well eg tc flower requires even more changes to sync with kernel updates.
- Due to its rigid nature, there's non-trivial loss of information when you have multiple layers of encap (eg multiple repeated ethernet headers, or ip headers etc). See this discussion for example [2].
- It is not flexible enough to map well to the semantics of hardware offloading of parsers i.e the software twin in the kernel and specific hardware semantics may have different capabilities.

The PANDA parser, introduced in [1], addresses most of these problems and introduces a developer friendly highly maintainable approach to adding extensions to the parser. This RFC patch takes a known consumer of flow dissector - tc flower - and shows how it could make use of the PANDA Parser by mostly cutnpaste of the flower code. The new classifier is called "flower2". The control semantics of flower are maintained but the flow dissector parser is replaced with a PANDA Parser. The iproute2 patch is sent separately - but you'll notice other than replacing the user space tc commands with "flower2" the syntax is exactly the same. To illustrate the flexibility of PANDA we show a simple use case of the issues described in [2] when flower consumes PANDA. The PANDA Parser is part of the PANDA programming model for network datapaths, this is described in
https://github.com/panda-net/panda.

[1]: https://netdevconf.info/0x15/session.html?Replacing-Flow-Dissector-with-PANDA-Parser
[2]: https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/

Felipe Magno de Almeida (2):
net: Add PANDA network packet parser
net/sched: Add flower2 packet classifier based on flower and PANDA
parser

 include/net/panda/compiler_helpers.h          |   79 +
 include/net/panda/flag_fields.h               |  369 ++
 include/net/panda/parser.h                    |  394 ++
 include/net/panda/parser_metadata.h           |  873 +++++
 include/net/panda/parser_types.h              |  255 ++
 include/net/panda/proto_nodes.h               |   48 +
 .../net/panda/proto_nodes/proto_arp_rarp.h    |   88 +
 include/net/panda/proto_nodes/proto_batman.h  |  106 +
 include/net/panda/proto_nodes/proto_ether.h   |   58 +
 include/net/panda/proto_nodes/proto_fcoe.h    |   49 +
 include/net/panda/proto_nodes/proto_gre.h     |  290 ++
 include/net/panda/proto_nodes/proto_icmp.h    |   74 +
 include/net/panda/proto_nodes/proto_igmp.h    |   49 +
 include/net/panda/proto_nodes/proto_ip.h      |   77 +
 include/net/panda/proto_nodes/proto_ipv4.h    |  150 +
 include/net/panda/proto_nodes/proto_ipv4ip.h  |   59 +
 include/net/panda/proto_nodes/proto_ipv6.h    |  133 +
 include/net/panda/proto_nodes/proto_ipv6_eh.h |  108 +
 include/net/panda/proto_nodes/proto_ipv6ip.h  |   59 +
 include/net/panda/proto_nodes/proto_mpls.h    |   49 +
 include/net/panda/proto_nodes/proto_ports.h   |   59 +
 include/net/panda/proto_nodes/proto_ppp.h     |   79 +
 include/net/panda/proto_nodes/proto_pppoe.h   |   98 +
 include/net/panda/proto_nodes/proto_tcp.h     |  177 +
 include/net/panda/proto_nodes/proto_tipc.h    |   56 +
 include/net/panda/proto_nodes/proto_vlan.h    |   66 +
 include/net/panda/proto_nodes_def.h           |   40 +
 include/net/panda/tlvs.h                      |  289 ++
 net/Kconfig                                   |    9 +
 net/Makefile                                  |    1 +
 net/panda/Makefile                            |    8 +
 net/panda/panda_parser.c                      |  605 +++
 net/sched/Kconfig                             |   11 +
 net/sched/Makefile                            |    2 +
 net/sched/cls_flower2_main.c                  | 3289 +++++++++++++++++
 net/sched/cls_flower2_panda_noopt.c           |  305 ++
 net/sched/cls_flower2_panda_opt.c             | 1536 ++++++++
 37 files changed, 9997 insertions(+)
 create mode 100644 include/net/panda/compiler_helpers.h
 create mode 100644 include/net/panda/flag_fields.h
 create mode 100644 include/net/panda/parser.h
 create mode 100644 include/net/panda/parser_metadata.h
 create mode 100644 include/net/panda/parser_types.h
 create mode 100644 include/net/panda/proto_nodes.h
 create mode 100644 include/net/panda/proto_nodes/proto_arp_rarp.h
 create mode 100644 include/net/panda/proto_nodes/proto_batman.h
 create mode 100644 include/net/panda/proto_nodes/proto_ether.h
 create mode 100644 include/net/panda/proto_nodes/proto_fcoe.h
 create mode 100644 include/net/panda/proto_nodes/proto_gre.h
 create mode 100644 include/net/panda/proto_nodes/proto_icmp.h
 create mode 100644 include/net/panda/proto_nodes/proto_igmp.h
 create mode 100644 include/net/panda/proto_nodes/proto_ip.h
 create mode 100644 include/net/panda/proto_nodes/proto_ipv4.h
 create mode 100644 include/net/panda/proto_nodes/proto_ipv4ip.h
 create mode 100644 include/net/panda/proto_nodes/proto_ipv6.h
 create mode 100644 include/net/panda/proto_nodes/proto_ipv6_eh.h
 create mode 100644 include/net/panda/proto_nodes/proto_ipv6ip.h
 create mode 100644 include/net/panda/proto_nodes/proto_mpls.h
 create mode 100644 include/net/panda/proto_nodes/proto_ports.h
 create mode 100644 include/net/panda/proto_nodes/proto_ppp.h
 create mode 100644 include/net/panda/proto_nodes/proto_pppoe.h
 create mode 100644 include/net/panda/proto_nodes/proto_tcp.h
 create mode 100644 include/net/panda/proto_nodes/proto_tipc.h
 create mode 100644 include/net/panda/proto_nodes/proto_vlan.h
 create mode 100644 include/net/panda/proto_nodes_def.h
 create mode 100644 include/net/panda/tlvs.h
 create mode 100644 net/panda/Makefile
 create mode 100644 net/panda/panda_parser.c
 create mode 100644 net/sched/cls_flower2_main.c
 create mode 100644 net/sched/cls_flower2_panda_noopt.c
 create mode 100644 net/sched/cls_flower2_panda_opt.c
Signature · 1 line
2.33.0
#1 lore raw

RFC PATCH 1/2 net: Add PANDA network packet parser

From: Felipe Magno de Almeida <[email protected]>

Adds the generic PANDA parser implementation to net/panda and the auxiliary include headers that are used by the optimized and generic implementation to include/net/panda.

The PANDA project allows the user to to create network packet parsers by combining and matching protocols in a declarative way, albeit in C code. This feature allows the flexibility users need to write parsers for specific protocols or to change the specifics on how and what data to extract from network packets.

The PANDA project also has a C-to-C compiler that reads a C file with a declarative parser definition and outputs an optimized version that uses the compiler inline optimizations to achieve much better performance than a generic implementation could. This compiler could be added later to the tools directory to be used in other subsystems to generate optimized versions of specialized parsers.

A couple drawbacks of this commit (which is meant as a RFC PATCH) is that it fails checkpatch in some cases and that it has some code repetition from existing code in kernel. Keep in mind that these drawbacks are known and they will get fixed with a proper submission patch.

For example, to define a very simple parser, you would define the parser nodes and a parser table for each non-terminal parser as such:

```
PANDA_MAKE_PARSE_NODE(ether_node, panda_parse_ether, NULL, NULL, ether_table);
PANDA_MAKE_PARSE_NODE(ipv4_node, panda_parse_ipv4, extract_ipv4, NULL,
		      ip_table);
PANDA_MAKE_PARSE_NODE(ipv6_node, panda_parse_ipv6, extract_ipv6, NULL,
		      ip_table);
PANDA_MAKE_LEAF_PARSE_NODE(ports_node, panda_parse_ports, extract_ports, NULL);

PANDA_MAKE_PROTO_TABLE(ether_table,
	{ __cpu_to_be16(ETH_P_IP), &ipv4_node },
	{ __cpu_to_be16(ETH_P_IPV6), &ipv6_node },
);

PANDA_MAKE_PROTO_TABLE(ip_table,
	{ IPPROTO_TCP, &ports_node },
	{ IPPROTO_UDP, &ports_node },
);

PANDA_PARSER(parser, "Simple parser without md templates", &ether_node);
```

Which you can run this way:

```
panda_parse(parser, packet, len, &extracted_header_metadata, 0, 0);
```
---
 include/net/panda/compiler_helpers.h          |  79 ++
 include/net/panda/flag_fields.h               | 369 ++++++++
 include/net/panda/parser.h                    | 394 ++++++++
 include/net/panda/parser_metadata.h           | 873 ++++++++++++++++++
 include/net/panda/parser_types.h              | 255 +++++
 include/net/panda/proto_nodes.h               |  48 +
 .../net/panda/proto_nodes/proto_arp_rarp.h    |  88 ++
 include/net/panda/proto_nodes/proto_batman.h  | 106 +++
 include/net/panda/proto_nodes/proto_ether.h   |  58 ++
 include/net/panda/proto_nodes/proto_fcoe.h    |  49 +
 include/net/panda/proto_nodes/proto_gre.h     | 290 ++++++
 include/net/panda/proto_nodes/proto_icmp.h    |  74 ++
 include/net/panda/proto_nodes/proto_igmp.h    |  49 +
 include/net/panda/proto_nodes/proto_ip.h      |  77 ++
 include/net/panda/proto_nodes/proto_ipv4.h    | 150 +++
 include/net/panda/proto_nodes/proto_ipv4ip.h  |  59 ++
 include/net/panda/proto_nodes/proto_ipv6.h    | 133 +++
 include/net/panda/proto_nodes/proto_ipv6_eh.h | 108 +++
 include/net/panda/proto_nodes/proto_ipv6ip.h  |  59 ++
 include/net/panda/proto_nodes/proto_mpls.h    |  49 +
 include/net/panda/proto_nodes/proto_ports.h   |  59 ++
 include/net/panda/proto_nodes/proto_ppp.h     |  79 ++
 include/net/panda/proto_nodes/proto_pppoe.h   |  98 ++
 include/net/panda/proto_nodes/proto_tcp.h     | 177 ++++
 include/net/panda/proto_nodes/proto_tipc.h    |  56 ++
 include/net/panda/proto_nodes/proto_vlan.h    |  66 ++
 include/net/panda/proto_nodes_def.h           |  40 +
 include/net/panda/tlvs.h                      | 289 ++++++
 net/Kconfig                                   |   9 +
 net/Makefile                                  |   1 +
 net/panda/Makefile                            |   8 +
 net/panda/panda_parser.c                      | 605 ++++++++++++
 32 files changed, 4854 insertions(+)
 create mode 100644 include/net/panda/compiler_helpers.h
 create mode 100644 include/net/panda/flag_fields.h
 create mode 100644 include/net/panda/parser.h
 create mode 100644 include/net/panda/parser_metadata.h
 create mode 100644 include/net/panda/parser_types.h
 create mode 100644 include/net/panda/proto_nodes.h
 create mode 100644 include/net/panda/proto_nodes/proto_arp_rarp.h
 create mode 100644 include/net/panda/proto_nodes/proto_batman.h
 create mode 100644 include/net/panda/proto_nodes/proto_ether.h
 create mode 100644 include/net/panda/proto_nodes/proto_fcoe.h
 create mode 100644 include/net/panda/proto_nodes/proto_gre.h
 create mode 100644 include/net/panda/proto_nodes/proto_icmp.h
 create mode 100644 include/net/panda/proto_nodes/proto_igmp.h
 create mode 100644 include/net/panda/proto_nodes/proto_ip.h
 create mode 100644 include/net/panda/proto_nodes/proto_ipv4.h
 create mode 100644 include/net/panda/proto_nodes/proto_ipv4ip.h
 create mode 100644 include/net/panda/proto_nodes/proto_ipv6.h
 create mode 100644 include/net/panda/proto_nodes/proto_ipv6_eh.h
 create mode 100644 include/net/panda/proto_nodes/proto_ipv6ip.h
 create mode 100644 include/net/panda/proto_nodes/proto_mpls.h
 create mode 100644 include/net/panda/proto_nodes/proto_ports.h
 create mode 100644 include/net/panda/proto_nodes/proto_ppp.h
 create mode 100644 include/net/panda/proto_nodes/proto_pppoe.h
 create mode 100644 include/net/panda/proto_nodes/proto_tcp.h
 create mode 100644 include/net/panda/proto_nodes/proto_tipc.h
 create mode 100644 include/net/panda/proto_nodes/proto_vlan.h
 create mode 100644 include/net/panda/proto_nodes_def.h
 create mode 100644 include/net/panda/tlvs.h
 create mode 100644 net/panda/Makefile
 create mode 100644 net/panda/panda_parser.c
include/net/panda/compiler_helpers.h new file +79 -0
new file mode 100644
index 000000000000..2f349529a78d
@@ -0,0 +1,79 @@
+/* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2020,2021 SiPanda Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __PANDA_COMPILER_HELPERS_H__
+#define __PANDA_COMPILER_HELPERS_H__
+
+/* Various helper defintions and functions that are compiler specific
+ * (e.g. they use __attribute__
+ */
+
+/* Define the __defaligned macro if it's not already defined */
+#ifndef __defaligned
+#define __defaligned() __attribute__ ((__aligned__))
+#endif
+
+/* Define the __aligned macro if it's not already defined */
+#ifndef __aligned
+#define __aligned(size) __attribute__((__aligned__(size)))
+#endif
+
+/* Define the __unused macro if it's not already defined */
+#ifndef __unused
+#define __unused() __attribute__((unused))
+#endif
+
+/* Define the __always_inline macro if it's not already defined */
+#ifndef __always_inline
+#define __always_inline __attribute__((always_inline)) inline
+#endif
+
+/* Utilities for dynamic arrays in sections */
+
+#define PANDA_DEFINE_SECTION(NAME, TYPE)				\
+extern TYPE __start_##NAME[];						\
+extern TYPE __stop_##NAME[];						\
+static inline unsigned int panda_section_array_size_##NAME(void)	\
+{									\
+	return (unsigned int)(__stop_##NAME - __start_##NAME);		\
+}									\
+static inline TYPE *panda_section_base_##NAME(void)			\
+{									\
+	return __start_##NAME;						\
+}
+
+#ifndef __bpf__
+#define PANDA_SECTION_ATTR(NAME) __attribute__((__used__, __section__(#NAME)))
+#else
+#define PANDA_SECTION_ATTR(NAME)
+#endif
+
+/* Assume cache line size of 64 for purposes of section alignment */
+#ifndef PANDA_ALIGN_SECTION
+#define PANDA_ALIGN_SECTION  __aligned(64)
+#endif
+
+#endif /* __PANDA_COMPILER_HELPERS_H__ */
include/net/panda/flag_fields.h new file +369 -0

369 lines not on this page · raw message

include/net/panda/parser.h new file +394 -0

394 lines not on this page · raw message

include/net/panda/parser_metadata.h new file +873 -0

873 lines not on this page · raw message

include/net/panda/parser_types.h new file +255 -0

255 lines not on this page · raw message

include/net/panda/proto_nodes.h new file +48 -0

48 lines not on this page · raw message

include/net/panda/proto_nodes/proto_arp_rarp.h new file +88 -0

88 lines not on this page · raw message

include/net/panda/proto_nodes/proto_batman.h new file +106 -0

106 lines not on this page · raw message

include/net/panda/proto_nodes/proto_ether.h new file +58 -0

58 lines not on this page · raw message

include/net/panda/proto_nodes/proto_fcoe.h new file +49 -0

49 lines not on this page · raw message

include/net/panda/proto_nodes/proto_gre.h new file +290 -0

290 lines not on this page · raw message

include/net/panda/proto_nodes/proto_icmp.h new file +74 -0

74 lines not on this page · raw message

include/net/panda/proto_nodes/proto_igmp.h new file +49 -0

49 lines not on this page · raw message

include/net/panda/proto_nodes/proto_ip.h new file +77 -0

77 lines not on this page · raw message

include/net/panda/proto_nodes/proto_ipv4.h new file +150 -0

150 lines not on this page · raw message

include/net/panda/proto_nodes/proto_ipv4ip.h new file +59 -0

41 lines not on this page · raw message

include/net/panda/proto_nodes/proto_ipv6.h new file +133 -0

133 lines not on this page · raw message

include/net/panda/proto_nodes/proto_ipv6_eh.h new file +108 -0

108 lines not on this page · raw message

include/net/panda/proto_nodes/proto_ipv6ip.h new file +59 -0

59 lines not on this page · raw message

include/net/panda/proto_nodes/proto_mpls.h new file +49 -0

49 lines not on this page · raw message

include/net/panda/proto_nodes/proto_ports.h new file +59 -0

59 lines not on this page · raw message

include/net/panda/proto_nodes/proto_ppp.h new file +79 -0

79 lines not on this page · raw message

include/net/panda/proto_nodes/proto_pppoe.h new file +98 -0

98 lines not on this page · raw message

include/net/panda/proto_nodes/proto_tcp.h new file +177 -0

177 lines not on this page · raw message

include/net/panda/proto_nodes/proto_tipc.h new file +56 -0

56 lines not on this page · raw message

include/net/panda/proto_nodes/proto_vlan.h new file +66 -0

66 lines not on this page · raw message

include/net/panda/proto_nodes_def.h new file +40 -0
new file mode 100644
index 000000000000..c8fc924e2428

Lines of this file are not shown. View the raw message.

include/net/panda/tlvs.h new file +289 -0

289 lines not on this page · raw message

net/Kconfig +9 -0
index fb13460c6dab..9f2ff50d1788 100644

Lines of this file are not shown. View the raw message.

net/Makefile +1 -0
index fbfeb8a0bb37..e1f46d0b47b1 100644

Lines of this file are not shown. View the raw message.

net/panda/Makefile new file +8 -0
new file mode 100644
index 000000000000..44420a1edf12

Lines of this file are not shown. View the raw message.

net/panda/panda_parser.c new file +605 -0

605 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.33.0

Part of the diff is not shown here. View the raw message.

#2 lore raw

RFC PATCH 2/2 net/sched: Add flower2 packet classifier based on flower and PANDA parser

In reply to Felipe Magno de Almeida

From: Felipe Magno de Almeida <[email protected]>

This commit reimplements the flower classifier, the main consumer of flow dissector, on top of the PANDA parser by mostly cutnpastying the flower code and modifying where the parser is used (fl_classify). The new classifier is called "flower2". The iproute2 patch is sent separately - but you'll notice other than replacing the user space tc commands with "flower2", the syntax is exactly the same. This classifier illustrates the flexibility of the PANDA parser and shows a few simple encapsulation use cases that become convoluted and complex because of flowdissector's intricacies below:

- Customizing parsing behavior is impossible and requires multiple workarounds on client code to avoid pitfalls in special cases handled by flow dissector and to avoid unnecessary overhead.

- Due to its rigid nature, there's non-trivial loss of information when you have multiple layers of encap (eg multiple repeated ethernet headers, or ip headers etc).

- It is not flexible enough to map well to the semantics of hardware offloading of parsers i.e the software twin in the kernel and specific hardware semantics may have different capabilities.

This parser lets us match three levels of encapsulation and check for properties in four stacked protocols simultaneously in a single pass.

Some usage examples of the flower2 classifier:

To show how flower2 is compatible with current flower classifier, let's see how we would create a filter for the following packet (captured via tcpdump):

```
(oui Ethernet) > Broadcast, ethertype IPv4 (0x0800), length 60: \
  localhost.22 > localhost.80: Flags [S], seq 0, win 8192, length
```

As you can expect, the line command is almost identical for flower2:

```
tc filter add dev lo parent ffff: protocol ip prio 1 flower2 \
  ip_proto tcp dst_port 80 action drop
```

Which will create the following filter after a single packet illuistrated earlier (via tcpdump) is seen:

```
filter protocol ip flower2 chain 0
filter protocol ip flower2 chain 0 handle 0x1
  eth_type ipv4
  ip_proto tcp
  dst_port 80
  not_in_hw
        action order 1: gact action drop
         random type none pass val 0
         index 1 ref 1 bind 1 installed 4 sec used 4 sec
        Action statistics:
        Sent 46 bytes 1 pkt (dropped 1, overlimits 0 requeues 0)
        backlog 0b 0p requeues 0
```

However, by using PANDA, flower2, due to its use of PANDA, can be extended to easily cover more complex cases with ease relative to flower. Let us take an example of the following packet (captured via tcpdump) which is subject to discussions in [1]:

```
(oui Ethernet) > Broadcast, ethertype 802.1Q (0x8100), length 85: \
  vlan 2, p 0, ethertype PPPoE S (0x8864), PPPoE  IP6 (0x0057), \
  length 61: localhost.ftp-data > localhost.http: Flags [S], \
  seq 0, win 8192, length 0
```

The above packet has three encapsulation layers, vlan, pppoe, ppp, ipv6, to drop ipv6 encapsulated packets with dst ip ::1, we would write a filter as such:

```
tc filter add dev lo parent ffff: protocol 802.1Q prio 1 flower2 \
  vlan_id 2 vlan_ethtype 0x8864 ppp_proto ppp_ipv6 dst_ip ::1  \
  action drop
```

And the result after a single such packet is seen:

```
filter protocol 802.1Q flower2 chain 0
filter protocol 802.1Q flower2 chain 0 handle 0x1
  ppp_proto ppp_ipv6
  vlan_id 2
  vlan_ethtype ppp_ses
  eth_type 8864
  dst_ip ::1
  not_in_hw
        action order 1: gact action drop
         random type none pass val 0
         index 1 ref 1 bind 1 installed 59 sec used 36 sec firstused 36 sec
        Action statistics:
        Sent 67 bytes 1 pkt (dropped 1, overlimits 0 requeues 0)
        backlog 0b 0p requeues 0
```

[1]: https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/

---
 net/sched/Kconfig                   |   11 +
 net/sched/Makefile                  |    2 +
 net/sched/cls_flower2_main.c        | 3289 +++++++++++++++++++++++++++
 net/sched/cls_flower2_panda_noopt.c |  305 +++
 net/sched/cls_flower2_panda_opt.c   | 1536 +++++++++++++
 5 files changed, 5143 insertions(+)
 create mode 100644 net/sched/cls_flower2_main.c
 create mode 100644 net/sched/cls_flower2_panda_noopt.c
 create mode 100644 net/sched/cls_flower2_panda_opt.c
net/sched/Kconfig +11 -0
index 1e8ab4749c6c..02cd86492992 100644
@@ -630,6 +630,17 @@ config NET_CLS_FLOWER
 	  To compile this code as a module, choose M here: the module will
 	  be called cls_flower.
 
+config NET_CLS_FLOWER2
+	tristate "Flower PANDA classifier"
+	select NET_CLS
+	depends on NET_PANDA
+	help
+	  If you say Y here, you will be able to classify packets based on
+	  a configurable combination of packet keys and masks.
+
+	  To compile this code as a module, choose M here: the module will
+	  be called cls_flower.
+
 config NET_CLS_MATCHALL
 	tristate "Match-all classifier"
 	select NET_CLS
net/sched/Makefile +2 -0
index dd14ef413fda..d97f86ea9f4e 100644
@@ -77,6 +77,8 @@ obj-$(CONFIG_NET_CLS_FLOW)	+= cls_flow.o
 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_FLOWER2)	+= cls_flower2.o
+cls_flower2-y := cls_flower2_main.o cls_flower2_panda_opt.o
 obj-$(CONFIG_NET_CLS_MATCHALL)	+= cls_matchall.o
 obj-$(CONFIG_NET_EMATCH)	+= ematch.o
 obj-$(CONFIG_NET_EMATCH_CMP)	+= em_cmp.o
net/sched/cls_flower2_main.c new file +3289 -0

2,975 lines not on this page · raw message

net/sched/cls_flower2_panda_noopt.c new file +305 -0

305 lines not on this page · raw message

net/sched/cls_flower2_panda_opt.c new file +1536 -0

1,536 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.33.0

Part of the diff is not shown here. View the raw message.

#5 lore raw
In reply to Felipe Magno de Almeida
Quoted 15 lines · Felipe Magno de Almeida

The PANDA parser, introduced in [1], addresses most of these problems and introduces a developer friendly highly maintainable approach to adding extensions to the parser. This RFC patch takes a known consumer of flow dissector - tc flower - and shows how it could make use of the PANDA Parser by mostly cutnpaste of the flower code. The new classifier is called "flower2". The control semantics of flower are maintained but the flow dissector parser is replaced with a PANDA Parser. The iproute2 patch is sent separately - but you'll notice other than replacing the user space tc commands with "flower2" the syntax is exactly the same. To illustrate the flexibility of PANDA we show a simple use case of the issues described in [2] when flower consumes PANDA. The PANDA Parser is part of the PANDA programming model for network datapaths, this is described in
https://github.com/panda-net/panda.

My only concern is that is there any way to reuse flower code instead of duplicating most of them? Especially when you specifically mentioned flower2 has the same user-space syntax as flower, this makes code reusing more reasonable.

Thanks.

maintainer
#6 lore raw
Quoted 18 lines · Wed, Sep 22, 2021 at 06:38:20AM CEST, [email protected] wrote:
Quoted 15 lines · Felipe Magno de Almeida

The PANDA parser, introduced in [1], addresses most of these problems and introduces a developer friendly highly maintainable approach to adding extensions to the parser. This RFC patch takes a known consumer of flow dissector - tc flower - and shows how it could make use of the PANDA Parser by mostly cutnpaste of the flower code. The new classifier is called "flower2". The control semantics of flower are maintained but the flow dissector parser is replaced with a PANDA Parser. The iproute2 patch is sent separately - but you'll notice other than replacing the user space tc commands with "flower2" the syntax is exactly the same. To illustrate the flexibility of PANDA we show a simple use case of the issues described in [2] when flower consumes PANDA. The PANDA Parser is part of the PANDA programming model for network datapaths, this is described in
https://github.com/panda-net/panda.

Quoted 4 lines

My only concern is that is there any way to reuse flower code instead of duplicating most of them? Especially when you specifically mentioned flower2 has the same user-space syntax as flower, this makes code reusing more reasonable.

Exactly. I believe it is wrong to introduce new classifier which would basically behave exacly the same as flower, only has different parser implementation under the hood.

Could you please explore the possibility to replace flow_dissector by your dissector optionally at first (kernel config for example)? And I'm not talking only about flower, but about the rest of the flow_dissector users too.

Thanks!

#7 lore raw
Quoted 25 lines · Jiri Pirko
Quoted 18 lines · Wed, Sep 22, 2021 at 06:38:20AM CEST, [email protected] wrote:
Quoted 15 lines · Felipe Magno de Almeida

The PANDA parser, introduced in [1], addresses most of these problems and introduces a developer friendly highly maintainable approach to adding extensions to the parser. This RFC patch takes a known consumer of flow dissector - tc flower - and shows how it could make use of the PANDA Parser by mostly cutnpaste of the flower code. The new classifier is called "flower2". The control semantics of flower are maintained but the flow dissector parser is replaced with a PANDA Parser. The iproute2 patch is sent separately - but you'll notice other than replacing the user space tc commands with "flower2" the syntax is exactly the same. To illustrate the flexibility of PANDA we show a simple use case of the issues described in [2] when flower consumes PANDA. The PANDA Parser is part of the PANDA programming model for network datapaths, this is described in
https://github.com/panda-net/panda.

Quoted 4 lines

My only concern is that is there any way to reuse flower code instead of duplicating most of them? Especially when you specifically mentioned flower2 has the same user-space syntax as flower, this makes code reusing more reasonable.

Quoted 9 lines

Exactly. I believe it is wrong to introduce new classifier which would basically behave exacly the same as flower, only has different parser implementation under the hood.

Could you please explore the possibility to replace flow_dissector by your dissector optionally at first (kernel config for example)? And I'm not talking only about flower, but about the rest of the flow_dissector users too.

Hi Jiri,

Yes, the intent is to replace flow dissector with a parser that is more extensible, more manageable and can be accelerated in hardware (good luck trying to HW accelerate flow dissector as is ;-) ). I did a presentation on this topic at the last Netdev conf:
https://www.youtube.com/watch?v=zVnmVDSEoXc. FIrst introducing this with a kernel config is a good idea.

Thanks,
Tom

Quoted 1 line

Thanks!

#8 lore raw
Quoted 26 lines · Tom Herbert
Quoted 25 lines · Jiri Pirko
Quoted 22 lines · Wed, Sep 22, 2021 at 06:38:20AM CEST, [email protected] wrote:
Quoted 15 lines · Felipe Magno de Almeida

The PANDA parser, introduced in [1], addresses most of these problems and introduces a developer friendly highly maintainable approach to adding extensions to the parser. This RFC patch takes a known consumer of flow dissector - tc flower - and shows how it could make use of the PANDA Parser by mostly cutnpaste of the flower code. The new classifier is called "flower2". The control semantics of flower are maintained but the flow dissector parser is replaced with a PANDA Parser. The iproute2 patch is sent separately - but you'll notice other than replacing the user space tc commands with "flower2" the syntax is exactly the same. To illustrate the flexibility of PANDA we show a simple use case of the issues described in [2] when flower consumes PANDA. The PANDA Parser is part of the PANDA programming model for network datapaths, this is described in
https://github.com/panda-net/panda.

My only concern is that is there any way to reuse flower code instead of duplicating most of them? Especially when you specifically mentioned flower2 has the same user-space syntax as flower, this makes code reusing more reasonable.

Quoted 8 lines
Quoted 8 lines

Exactly. I believe it is wrong to introduce new classifier which would basically behave exacly the same as flower, only has different parser implementation under the hood.

Could you please explore the possibility to replace flow_dissector by your dissector optionally at first (kernel config for example)? And I'm not talking only about flower, but about the rest of the flow_dissector users too.

+1

Quoted 8 lines

Hi Jiri,

Yes, the intent is to replace flow dissector with a parser that is more extensible, more manageable and can be accelerated in hardware (good luck trying to HW accelerate flow dissector as is ;-) ). I did a presentation on this topic at the last Netdev conf:
https://www.youtube.com/watch?v=zVnmVDSEoXc. FIrst introducing this with a kernel config is a good idea.

Can we drop hyperbole? There are several examples of hardware that offload (a subset of) flower. That the current kernel implementation has the properties you describe is pretty much irrelevant for current hw offload use-cases.

#9 lore raw
Quoted 48 lines · Simon Horman
Quoted 26 lines · Tom Herbert
Quoted 25 lines · Jiri Pirko
Quoted 22 lines · Wed, Sep 22, 2021 at 06:38:20AM CEST, [email protected] wrote:
Quoted 15 lines · Felipe Magno de Almeida

The PANDA parser, introduced in [1], addresses most of these problems and introduces a developer friendly highly maintainable approach to adding extensions to the parser. This RFC patch takes a known consumer of flow dissector - tc flower - and shows how it could make use of the PANDA Parser by mostly cutnpaste of the flower code. The new classifier is called "flower2". The control semantics of flower are maintained but the flow dissector parser is replaced with a PANDA Parser. The iproute2 patch is sent separately - but you'll notice other than replacing the user space tc commands with "flower2" the syntax is exactly the same. To illustrate the flexibility of PANDA we show a simple use case of the issues described in [2] when flower consumes PANDA. The PANDA Parser is part of the PANDA programming model for network datapaths, this is described in
https://github.com/panda-net/panda.

My only concern is that is there any way to reuse flower code instead of duplicating most of them? Especially when you specifically mentioned flower2 has the same user-space syntax as flower, this makes code reusing more reasonable.

Quoted 8 lines
Quoted 8 lines

Exactly. I believe it is wrong to introduce new classifier which would basically behave exacly the same as flower, only has different parser implementation under the hood.

Could you please explore the possibility to replace flow_dissector by your dissector optionally at first (kernel config for example)? And I'm not talking only about flower, but about the rest of the flow_dissector users too.

+1

Quoted 8 lines

Hi Jiri,

Yes, the intent is to replace flow dissector with a parser that is more extensible, more manageable and can be accelerated in hardware (good luck trying to HW accelerate flow dissector as is ;-) ). I did a presentation on this topic at the last Netdev conf:
https://www.youtube.com/watch?v=zVnmVDSEoXc. FIrst introducing this with a kernel config is a good idea.

Quoted 4 lines

Can we drop hyperbole? There are several examples of hardware that offload (a subset of) flower. That the current kernel implementation has the properties you describe is pretty much irrelevant for current hw offload use-cases.

Simon,

"current hw offload use-cases" is the problem; these models offer no extensibility. For instance, if a new protocol appears or a user wants to support their own custom protocol in things like tc-flower there is no feasible way to do this. Unfortunately, as of today it seems, we are still bound by the marketing department at hardware vendors that pick and choose the protocols that they think their customers want and are willing to invest in-- we need to get past this once and for all! IMO, what we need is a common way to extend the kernel, tc, and other applications for new protocols and features, but also be able to apply that method to extend to the hardware which is _offloading_ kernel functionality which in this case is flow dissector. The technology is there to do this as programmable NICs for instance are the rage, but we do need to create common APIs to be able to do that. Note this isn't just tc, but a whole space of features; for instance, XDP hints is nice idea for the NIC to provide information about protocols in a packet, but unless/until there is a way to program the device to pull out arbitrary information that the user cares about like something from their custom protocol, then it's very limited utility...

Tom

#10 lore raw
Quoted 66 lines · Tom Herbert
Quoted 48 lines · Simon Horman
Quoted 26 lines · Tom Herbert
Quoted 25 lines · Jiri Pirko
Quoted 22 lines · Wed, Sep 22, 2021 at 06:38:20AM CEST, [email protected] wrote:
Quoted 15 lines · Felipe Magno de Almeida

The PANDA parser, introduced in [1], addresses most of these problems and introduces a developer friendly highly maintainable approach to adding extensions to the parser. This RFC patch takes a known consumer of flow dissector - tc flower - and shows how it could make use of the PANDA Parser by mostly cutnpaste of the flower code. The new classifier is called "flower2". The control semantics of flower are maintained but the flow dissector parser is replaced with a PANDA Parser. The iproute2 patch is sent separately - but you'll notice other than replacing the user space tc commands with "flower2" the syntax is exactly the same. To illustrate the flexibility of PANDA we show a simple use case of the issues described in [2] when flower consumes PANDA. The PANDA Parser is part of the PANDA programming model for network datapaths, this is described in
https://github.com/panda-net/panda.

My only concern is that is there any way to reuse flower code instead of duplicating most of them? Especially when you specifically mentioned flower2 has the same user-space syntax as flower, this makes code reusing more reasonable.

Quoted 8 lines
Quoted 8 lines

Exactly. I believe it is wrong to introduce new classifier which would basically behave exacly the same as flower, only has different parser implementation under the hood.

Could you please explore the possibility to replace flow_dissector by your dissector optionally at first (kernel config for example)? And I'm not talking only about flower, but about the rest of the flow_dissector users too.

+1

Quoted 8 lines

Hi Jiri,

Yes, the intent is to replace flow dissector with a parser that is more extensible, more manageable and can be accelerated in hardware (good luck trying to HW accelerate flow dissector as is ;-) ). I did a presentation on this topic at the last Netdev conf:
https://www.youtube.com/watch?v=zVnmVDSEoXc. FIrst introducing this with a kernel config is a good idea.

Quoted 4 lines

Can we drop hyperbole? There are several examples of hardware that offload (a subset of) flower. That the current kernel implementation has the properties you describe is pretty much irrelevant for current hw offload use-cases.

Simon,

"current hw offload use-cases" is the problem; these models offer no extensibility. For instance, if a new protocol appears or a user wants to support their own custom protocol in things like tc-flower there is no feasible way to do this. Unfortunately, as of today it seems, we are still bound by the marketing department at hardware vendors that pick and choose the protocols that they think their customers want and are willing to invest in-- we need to get past this once and for all! IMO, what we need is a common way to extend the kernel, tc, and other applications for new protocols and features, but also be able to apply that method to extend to the hardware which is _offloading_ kernel

Quoted 8 lines

functionality which in this case is flow dissector. The technology is there to do this as programmable NICs for instance are the rage, but we do need to create common APIs to be able to do that. Note this isn't just tc, but a whole space of features; for instance, XDP hints is nice idea for the NIC to provide information about protocols in a packet, but unless/until there is a way to program the device to pull out arbitrary information that the user cares about like something from their custom protocol, then it's very limited utility...

... the NIC could run a BPF program if its programmable to that extent.

But ok, I accept your point that it would be good to facilitate more flexible use in both sw and hw.

#11 lore raw
Quoted 77 lines · Simon Horman
Quoted 66 lines · Tom Herbert
Quoted 48 lines · Simon Horman
Quoted 26 lines · Tom Herbert
Quoted 25 lines · Jiri Pirko
Quoted 22 lines · Wed, Sep 22, 2021 at 06:38:20AM CEST, [email protected] wrote:
Quoted 15 lines · Felipe Magno de Almeida

The PANDA parser, introduced in [1], addresses most of these problems and introduces a developer friendly highly maintainable approach to adding extensions to the parser. This RFC patch takes a known consumer of flow dissector - tc flower - and shows how it could make use of the PANDA Parser by mostly cutnpaste of the flower code. The new classifier is called "flower2". The control semantics of flower are maintained but the flow dissector parser is replaced with a PANDA Parser. The iproute2 patch is sent separately - but you'll notice other than replacing the user space tc commands with "flower2" the syntax is exactly the same. To illustrate the flexibility of PANDA we show a simple use case of the issues described in [2] when flower consumes PANDA. The PANDA Parser is part of the PANDA programming model for network datapaths, this is described in
https://github.com/panda-net/panda.

My only concern is that is there any way to reuse flower code instead of duplicating most of them? Especially when you specifically mentioned flower2 has the same user-space syntax as flower, this makes code reusing more reasonable.

Quoted 8 lines
Quoted 8 lines

Exactly. I believe it is wrong to introduce new classifier which would basically behave exacly the same as flower, only has different parser implementation under the hood.

Could you please explore the possibility to replace flow_dissector by your dissector optionally at first (kernel config for example)? And I'm not talking only about flower, but about the rest of the flow_dissector users too.

+1

Quoted 8 lines

Hi Jiri,

Yes, the intent is to replace flow dissector with a parser that is more extensible, more manageable and can be accelerated in hardware (good luck trying to HW accelerate flow dissector as is ;-) ). I did a presentation on this topic at the last Netdev conf:
https://www.youtube.com/watch?v=zVnmVDSEoXc. FIrst introducing this with a kernel config is a good idea.

Quoted 4 lines

Can we drop hyperbole? There are several examples of hardware that offload (a subset of) flower. That the current kernel implementation has the properties you describe is pretty much irrelevant for current hw offload use-cases.

Simon,

"current hw offload use-cases" is the problem; these models offer no extensibility. For instance, if a new protocol appears or a user wants to support their own custom protocol in things like tc-flower there is no feasible way to do this. Unfortunately, as of today it seems, we are still bound by the marketing department at hardware vendors that pick and choose the protocols that they think their customers want and are willing to invest in-- we need to get past this once and for all! IMO, what we need is a common way to extend the kernel, tc, and other applications for new protocols and features, but also be able to apply that method to extend to the hardware which is _offloading_ kernel

Quoted 8 lines

functionality which in this case is flow dissector. The technology is there to do this as programmable NICs for instance are the rage, but we do need to create common APIs to be able to do that. Note this isn't just tc, but a whole space of features; for instance, XDP hints is nice idea for the NIC to provide information about protocols in a packet, but unless/until there is a way to program the device to pull out arbitrary information that the user cares about like something from their custom protocol, then it's very limited utility...

Quoted 2 lines

... the NIC could run a BPF program if its programmable to that extent.

Simon,

True, but that implies that the NIC would just be running code in one CPU instead of another-- i.e., that is doing offload and not acceleration. Hardware parses are more likely to be very specialized and might look something like a parameterized FSM that runs 10x faster than software in a CPU. In order to be able to accelerate, we need to start with a parser representation that is more declarative than imperative. This is what PANDA provides, the user writes a parser in a declarative representation (but still in C). Given the front end representation is declarative, we can compile that to a type of byte code that is digestible to instantiate a reasonably programmable hardware parser. This fits well with eBPF where the byte code is domain specific instructions to eBPF, so when the eBPF program runs they can be JIT compiled into CPU instructions for running on the host, but they can be given to driver that can translate or JIT compile the byte code into their hardware parser (coud JIT compile to P4 backend for instance).

Tom

Quoted 2 lines

But ok, I accept your point that it would be good to facilitate more flexible use in both sw and hw.

#12 lore raw
Quoted 36 lines · Tom Herbert
Quoted 35 lines · Simon Horman
Quoted 33 lines · Tom Herbert
Quoted 32 lines · Simon Horman
Quoted 30 lines · Tom Herbert
Quoted 29 lines · Jiri Pirko
Quoted 18 lines · Wed, Sep 22, 2021 at 06:38:20AM CEST, [email protected] wrote:
Quoted 15 lines · Felipe Magno de Almeida

The PANDA parser, introduced in [1], addresses most of these problems and introduces a developer friendly highly maintainable approach to adding extensions to the parser. This RFC patch takes a known consumer of flow dissector - tc flower - and shows how it could make use of the PANDA Parser by mostly cutnpaste of the flower code. The new classifier is called "flower2". The control semantics of flower are maintained but the flow dissector parser is replaced with a PANDA Parser. The iproute2 patch is sent separately - but you'll notice other than replacing the user space tc commands with "flower2" the syntax is exactly the same. To illustrate the flexibility of PANDA we show a simple use case of the issues described in [2] when flower consumes PANDA. The PANDA Parser is part of the PANDA programming model for network datapaths, this is described in
https://github.com/panda-net/panda.

Quoted 4 lines

My only concern is that is there any way to reuse flower code instead of duplicating most of them? Especially when you specifically mentioned flower2 has the same user-space syntax as flower, this makes code reusing more reasonable.

Exactly. I believe it is wrong to introduce new classifier which would basically behave exacly the same as flower, only has different parser implementation under the hood.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

Could you please explore the possibility to replace flow_dissector by your dissector optionally at first (kernel config for example)? And I'm not talking only about flower, but about the rest of the flow_dissector users too.

+1

Does the existing BPF flow dissector not work for some reason? If its purely a hardware mapping problem, couple questions below.

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 10 lines
Quoted 9 lines

Hi Jiri,

Yes, the intent is to replace flow dissector with a parser that is more extensible, more manageable and can be accelerated in hardware (good luck trying to HW accelerate flow dissector as is ;-) ). I did a presentation on this topic at the last Netdev conf:
https://www.youtube.com/watch?v=zVnmVDSEoXc. FIrst introducing this with a kernel config is a good idea.

Quoted 4 lines

Can we drop hyperbole? There are several examples of hardware that offload (a subset of) flower. That the current kernel implementation has the properties you describe is pretty much irrelevant for current hw offload use-cases.

Simon,

"current hw offload use-cases" is the problem; these models offer no extensibility. For instance, if a new protocol appears or a user wants to support their own custom protocol in things like tc-flower there is no feasible way to do this. Unfortunately, as of today it seems, we are still bound by the marketing department at hardware vendors that pick and choose the protocols that they think their customers want and are willing to invest in-- we need to get past this once and for all! IMO, what we need is a common way to extend the kernel, tc, and other applications for new protocols and features, but also be able to apply that method to extend to the hardware which is _offloading_ kernel

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

functionality which in this case is flow dissector. The technology is there to do this as programmable NICs for instance are the rage, but we do need to create common APIs to be able to do that. Note this isn't just tc, but a whole space of features; for instance, XDP hints is nice idea for the NIC to provide information about protocols in a packet, but unless/until there is a way to program the device to pull out arbitrary information that the user cares about like something from their custom protocol, then it's very limited utility...

Vendors have the ability to code up arbitrary hints today. They just haven't open sourced it or made it widely available. I don't see how a 'tc' interface would help with this. I suspect most hardware could prepend hints or put other arbitrary data in the descriptor or elsewhere. The compelling reason to open source it is missing.

Then the flwo is fairly straight forward the XDP program reads the hints. Then if the rest of the stack needs this in the skb we have the hash and skb extensions.

Quoted 11 lines
Quoted 3 lines

... the NIC could run a BPF program if its programmable to that extent.

Simon,

True, but that implies that the NIC would just be running code in one CPU instead of another-- i.e., that is doing offload and not acceleration. Hardware parses are more likely to be very specialized and might look something like a parameterized FSM that runs 10x faster than software in a CPU. In order to be able to accelerate, we need to start with a parser representation that is more declarative than

Agree, but I don't see how configuration of this hardware makes sense over 'tc'. This is likely to require compiler tools to generate the microcode or *CAM entries running on the hardware. Having 'tc' run a few link, add-header commands that can be converted into reconfigured hardware (thats not just a CPU on a NIC) seems like we will be asking a lot of firmware. Probably too much for my taste, fixing bugs in firmware is going to be harder then if vendors just give us the compiler tools to generate the parsing logic for their hardware.

Show me the hardware that can create new parse trees using flower2, do they exist?

If not the flow is like this,

0. build new parse graph and hardware logic using DSL (P4 or otherwise)
1. apply blob output from 0 onto hardware
2. build out flower2 graph
3. flower2 populates hardware but hardware already got it from 0?

I'm missing the point here?

Quoted 10 lines

imperative. This is what PANDA provides, the user writes a parser in a declarative representation (but still in C). Given the front end representation is declarative, we can compile that to a type of byte code that is digestible to instantiate a reasonably programmable hardware parser. This fits well with eBPF where the byte code is domain specific instructions to eBPF, so when the eBPF program runs they can be JIT compiled into CPU instructions for running on the host, but they can be given to driver that can translate or JIT compile the byte code into their hardware parser (coud JIT compile to P4 backend for instance).

I'm not sure hardware exists that can or will take arbitrary 'tc' commands and build a graph of a new protocols? Also we already have a SW path for arbitrary flow parser with BPF so I see no reasons we need to support yet another one. Even PANDA could produce BPF codes for sofwtare and hardware codes to program the hardware so why is this needed?

Also yes I saw the netdevconf but still missed the point Sorry.

Thanks
.John

#3 lore raw

Re: [PATCH RFC net-next 2/2] net/sched: Add flower2 packet classifier based on flower and PANDA parser

In reply to Felipe Magno de Almeida

net/sched/cls_flower2_main.c line 326

Quoted 11 lines · Felipe Magno de Almeida
net/sched/cls_flower2_main.c new file +11 -0
+int fl2_panda_parse(struct sk_buff *skb, struct fl2_flow_key* frame)
+{
+	int err;
+	struct panda_parser_big_metadata_one mdata;
+	void *data;
+	size_t pktlen;
+
+	memset(&mdata, 0, sizeof(mdata.panda_data));
+	memcpy(&mdata.frame, frame, sizeof(struct fl2_flow_key));
+
+	err = skb_linearize(skb);

Oh ow. Hopefully this is just for the RFC?

Quoted 56 lines
net/sched/cls_flower2_main.c new file +56 -0
+	if (err < 0)
+		return err;
+
+	BUG_ON(skb->data_len);
+
+	data = skb_mac_header(skb);
+	pktlen = skb_mac_header_len(skb) + skb->len;
+
+	err = panda_parse(PANDA_PARSER_KMOD_NAME(panda_parser_big_ether), data,
+			  pktlen, &mdata.panda_data, 0, 1);
+
+	if (err != PANDA_STOP_OKAY) {
+                pr_err("Failed to parse packet! (%d)", err);
+		return -1;
+        }
+
+	memcpy(frame, &mdata.frame, sizeof(struct fl2_flow_key));
+
+	return 0;
+}
+
+static int fl2_classify(struct sk_buff *skb, const struct tcf_proto *tp,
+		       struct tcf_result *res)
+{
+	struct cls_fl2_head *head = rcu_dereference_bh(tp->root);
+	struct fl2_flow_key skb_key;
+	struct fl2_flow_mask *mask;
+	struct cls_fl2_filter *f;
+
+	list_for_each_entry_rcu(mask, &head->masks, list) {
+		flow_dissector_init_keys(&skb_key.control, &skb_key.basic);
+		fl2_clear_masked_range(&skb_key, mask);
+
+		skb_flow_dissect_meta(skb, &mask->dissector, &skb_key);
+		/* skb_flow_dissect() does not set n_proto in case an unknown
+		 * protocol, so do it rather here.
+		 */
+		skb_key.basic.n_proto = skb_protocol(skb, false);
+
+		if(skb->vlan_present) {
+			skb_key.basic.n_proto = skb_protocol(skb, true);
+			skb_key.vlan.vlan_id = skb_vlan_tag_get_id(skb);
+			skb_key.vlan.vlan_priority = skb_vlan_tag_get_prio(skb);
+			skb_key.vlan.vlan_tpid = skb->vlan_proto;
+		}
+		
+		fl2_panda_parse(skb, &skb_key);
+
+		f = fl2_mask_lookup(mask, &skb_key);
+		if (f && !tc_skip_sw(f->flags)) {
+			*res = f->res;
+			return tcf_exts_exec(skb, &f->exts, res);
+		}
+	}
+	return -1;
+}
#23 lore raw
In reply to Tom Herbert
Quoted 56 lines · Tom Herbert
Quoted 48 lines · Simon Horman
Quoted 26 lines · Tom Herbert
Quoted 25 lines · Jiri Pirko
Quoted 22 lines · Wed, Sep 22, 2021 at 06:38:20AM CEST, [email protected] wrote:
Quoted 15 lines · Felipe Magno de Almeida

The PANDA parser, introduced in [1], addresses most of these problems and introduces a developer friendly highly maintainable approach to adding extensions to the parser. This RFC patch takes a known consumer of flow dissector - tc flower - and shows how it could make use of the PANDA Parser by mostly cutnpaste of the flower code. The new classifier is called "flower2". The control semantics of flower are maintained but the flow dissector parser is replaced with a PANDA Parser. The iproute2 patch is sent separately - but you'll notice other than replacing the user space tc commands with "flower2" the syntax is exactly the same. To illustrate the flexibility of PANDA we show a simple use case of the issues described in [2] when flower consumes PANDA. The PANDA Parser is part of the PANDA programming model for network datapaths, this is described in
https://github.com/panda-net/panda.

My only concern is that is there any way to reuse flower code instead of duplicating most of them? Especially when you specifically mentioned flower2 has the same user-space syntax as flower, this makes code reusing more reasonable.

Quoted 8 lines
Quoted 8 lines

Exactly. I believe it is wrong to introduce new classifier which would basically behave exacly the same as flower, only has different parser implementation under the hood.

Could you please explore the possibility to replace flow_dissector by your dissector optionally at first (kernel config for example)? And I'm not talking only about flower, but about the rest of the flow_dissector users too.

+1

Quoted 8 lines

Hi Jiri,

Yes, the intent is to replace flow dissector with a parser that is more extensible, more manageable and can be accelerated in hardware (good luck trying to HW accelerate flow dissector as is ;-) ). I did a presentation on this topic at the last Netdev conf:
https://www.youtube.com/watch?v=zVnmVDSEoXc. FIrst introducing this with a kernel config is a good idea.

Quoted 4 lines

Can we drop hyperbole? There are several examples of hardware that offload (a subset of) flower. That the current kernel implementation has the properties you describe is pretty much irrelevant for current hw offload use-cases.

Simon,

Quoted 7 lines

"current hw offload use-cases" is the problem; these models offer no extensibility. For instance, if a new protocol appears or a user wants to support their own custom protocol in things like tc-flower there is no feasible way to do this. Unfortunately, as of today it seems, we are still bound by the marketing department at hardware vendors that pick and choose the protocols that they think their customers want and are willing to invest in-- we need to get past this once and for all!

Not that I don't agree with this, but I'm having a hard time seeing how flower2 would be more flexible than current approach in this sense. Say that someone wants to add support for IPv64. AFAICS it would still require changes to iproute, cls_flower2, panda and drivers, which is the complain that I usually hear about cls_flower extensibility.

TCP options too, for example. The 1st patch has code like:

+#define PANDA_METADATA_tcp_options                                     \
+       struct {                                                        \
+               __u16 mss;                                              \
+               __u8 window_scaling;                                    \
+               struct {                                                \
+                       __u32 value;                                    \
+                       __u32 echo;                                     \
+               } timestamp;                                            \
+               struct {                                                \
+                       __u32 left_edge;                                \
+                       __u32 right_edge;                               \

+ } sack[PANDA_TCP_MAX_SACKS]; \
+ } tcp_options

...

+#define PANDA_METADATA_TEMP_tcp_option_mss(NAME, STRUCT)               \
+static void NAME(const void *vopt, void *iframe,                       \
+                struct panda_ctrl_data ctrl)                           \
+{                                                                      \
+       const struct tcp_opt_union *opt = vopt;                         \
+       struct STRUCT *frame = iframe;                                  \
+                                                                       \
+       frame->tcp_options.mss = ntohs(opt->mss);                       \

+}

So if we have a new option on the game, what will need updating?

Marcelo

Quoted 13 lines

IMO, what we need is a common way to extend the kernel, tc, and other applications for new protocols and features, but also be able to apply that method to extend to the hardware which is _offloading_ kernel functionality which in this case is flow dissector. The technology is there to do this as programmable NICs for instance are the rage, but we do need to create common APIs to be able to do that. Note this isn't just tc, but a whole space of features; for instance, XDP hints is nice idea for the NIC to provide information about protocols in a packet, but unless/until there is a way to program the device to pull out arbitrary information that the user cares about like something from their custom protocol, then it's very limited utility...

Tom

#24 lore raw
Quoted 66 lines · Marcelo Ricardo Leitner
Quoted 56 lines · Tom Herbert
Quoted 48 lines · Simon Horman
Quoted 26 lines · Tom Herbert
Quoted 25 lines · Jiri Pirko
Quoted 22 lines · Wed, Sep 22, 2021 at 06:38:20AM CEST, [email protected] wrote:
Quoted 15 lines · Felipe Magno de Almeida

The PANDA parser, introduced in [1], addresses most of these problems and introduces a developer friendly highly maintainable approach to adding extensions to the parser. This RFC patch takes a known consumer of flow dissector - tc flower - and shows how it could make use of the PANDA Parser by mostly cutnpaste of the flower code. The new classifier is called "flower2". The control semantics of flower are maintained but the flow dissector parser is replaced with a PANDA Parser. The iproute2 patch is sent separately - but you'll notice other than replacing the user space tc commands with "flower2" the syntax is exactly the same. To illustrate the flexibility of PANDA we show a simple use case of the issues described in [2] when flower consumes PANDA. The PANDA Parser is part of the PANDA programming model for network datapaths, this is described in
https://github.com/panda-net/panda.

My only concern is that is there any way to reuse flower code instead of duplicating most of them? Especially when you specifically mentioned flower2 has the same user-space syntax as flower, this makes code reusing more reasonable.

Quoted 8 lines
Quoted 8 lines

Exactly. I believe it is wrong to introduce new classifier which would basically behave exacly the same as flower, only has different parser implementation under the hood.

Could you please explore the possibility to replace flow_dissector by your dissector optionally at first (kernel config for example)? And I'm not talking only about flower, but about the rest of the flow_dissector users too.

+1

Quoted 8 lines

Hi Jiri,

Yes, the intent is to replace flow dissector with a parser that is more extensible, more manageable and can be accelerated in hardware (good luck trying to HW accelerate flow dissector as is ;-) ). I did a presentation on this topic at the last Netdev conf:
https://www.youtube.com/watch?v=zVnmVDSEoXc. FIrst introducing this with a kernel config is a good idea.

Quoted 4 lines

Can we drop hyperbole? There are several examples of hardware that offload (a subset of) flower. That the current kernel implementation has the properties you describe is pretty much irrelevant for current hw offload use-cases.

Simon,

Quoted 7 lines

"current hw offload use-cases" is the problem; these models offer no extensibility. For instance, if a new protocol appears or a user wants to support their own custom protocol in things like tc-flower there is no feasible way to do this. Unfortunately, as of today it seems, we are still bound by the marketing department at hardware vendors that pick and choose the protocols that they think their customers want and are willing to invest in-- we need to get past this once and for all!

Quoted 7 lines

Not that I don't agree with this, but I'm having a hard time seeing how flower2 would be more flexible than current approach in this sense. Say that someone wants to add support for IPv64. AFAICS it would still require changes to iproute, cls_flower2, panda and drivers, which is the complain that I usually hear about cls_flower extensibility.

Yes, flower2 is not sufficient and neither would be replacing the flow dissector with PANDA. In order to make this tc-flower truly extensible we need "generic tc-flower" which I touched upon in the Netdev. This really means that we need to coordinate three actors of TC application, kernel, and hardware for offloads. Adding a new protocol means that we have to be able to parse the packet before match rules can be created, so that means the parser is a first class citizen in making this work.

Quoted 28 lines

TCP options too, for example. The 1st patch has code like:

(quoted diff) +22 -0
+#define PANDA_METADATA_tcp_options                                     \
+       struct {                                                        \
+               __u16 mss;                                              \
+               __u8 window_scaling;                                    \
+               struct {                                                \
+                       __u32 value;                                    \
+                       __u32 echo;                                     \
+               } timestamp;                                            \
+               struct {                                                \
+                       __u32 left_edge;                                \
+                       __u32 right_edge;                               \
+               } sack[PANDA_TCP_MAX_SACKS];                                    \
+       } tcp_options
 
...
 
+#define PANDA_METADATA_TEMP_tcp_option_mss(NAME, STRUCT)               \
+static void NAME(const void *vopt, void *iframe,                       \
+                struct panda_ctrl_data ctrl)                           \
+{                                                                      \
+       const struct tcp_opt_union *opt = vopt;                         \
+       struct STRUCT *frame = iframe;                                  \
+                                                                       \
+       frame->tcp_options.mss = ntohs(opt->mss);                       \
+}
Quoted 2 lines

So if we have a new option on the game, what will need updating?

It's a matter of adding new options to the parser program and then downloading the parser either to kernel or hardware for offload (again they really should be running identical programs). Given that we need to be able to set up rules for matching fields in the protocols which can be done by using offsets as the keys in an abstract way. The kernel and the user space application then need to be tightly coordinated such that they have agreement that they are talking about the same fields for a given value (BTF might help here). The last part of the equation is to dynamically create a TC CLI for the new fields, this could be derived from the input parser program that is annotated with human readable names for protocols and fields.

Thanks,
Tom

Quoted 15 lines

Marcelo

Quoted 13 lines

IMO, what we need is a common way to extend the kernel, tc, and other applications for new protocols and features, but also be able to apply that method to extend to the hardware which is _offloading_ kernel functionality which in this case is flow dissector. The technology is there to do this as programmable NICs for instance are the rage, but we do need to create common APIs to be able to do that. Note this isn't just tc, but a whole space of features; for instance, XDP hints is nice idea for the NIC to provide information about protocols in a packet, but unless/until there is a way to program the device to pull out arbitrary information that the user cares about like something from their custom protocol, then it's very limited utility...

Tom

#13 lore raw
In reply to John Fastabend
Quoted 43 lines · John Fastabend
Quoted 41 lines · Tom Herbert
Quoted 40 lines · Simon Horman
Quoted 38 lines · Tom Herbert
Quoted 37 lines · Simon Horman
Quoted 34 lines · Tom Herbert
Quoted 33 lines · Jiri Pirko
Quoted 18 lines · Wed, Sep 22, 2021 at 06:38:20AM CEST, [email protected] wrote:
Quoted 15 lines · Felipe Magno de Almeida

The PANDA parser, introduced in [1], addresses most of these problems and introduces a developer friendly highly maintainable approach to adding extensions to the parser. This RFC patch takes a known consumer of flow dissector - tc flower - and shows how it could make use of the PANDA Parser by mostly cutnpaste of the flower code. The new classifier is called "flower2". The control semantics of flower are maintained but the flow dissector parser is replaced with a PANDA Parser. The iproute2 patch is sent separately - but you'll notice other than replacing the user space tc commands with "flower2" the syntax is exactly the same. To illustrate the flexibility of PANDA we show a simple use case of the issues described in [2] when flower consumes PANDA. The PANDA Parser is part of the PANDA programming model for network datapaths, this is described in
https://github.com/panda-net/panda.

Quoted 4 lines

My only concern is that is there any way to reuse flower code instead of duplicating most of them? Especially when you specifically mentioned flower2 has the same user-space syntax as flower, this makes code reusing more reasonable.

Exactly. I believe it is wrong to introduce new classifier which would basically behave exacly the same as flower, only has different parser implementation under the hood.

Could you please explore the possibility to replace flow_dissector by your dissector optionally at first (kernel config for example)? And I'm not talking only about flower, but about the rest of the flow_dissector users too.

Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+1

Does the existing BPF flow dissector not work for some reason? If its purely a hardware mapping problem, couple questions below.

Hi John,

eBPF in its current form is un-acceleratable is a primary problem, however an eBPF flow dissector would still have the same issues in complexity and manageability that the kernel flow dissector. PANDA pretty much can address that since the same source code for flow dissector used in tc-flower could be compiled into eBPF and used with TC (that gives extensibility at some incremental performance degradation). There is an interesting caveat there in that to satisfy verifier we had to break up the parser to avoid being flagged for complexity. The parser code however already started with a restricted structure that enforces rules that prevent the issues the verified is checking for, when we get to verifier though it doesn't have any that context and hence views it as general purpose code. Introducing domain specific constructs into eBPF, like the byte code I mentioned, would simplify the verifier in that case.

Quoted 36 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 10 lines
Quoted 9 lines

Hi Jiri,

Yes, the intent is to replace flow dissector with a parser that is more extensible, more manageable and can be accelerated in hardware (good luck trying to HW accelerate flow dissector as is ;-) ). I did a presentation on this topic at the last Netdev conf:
https://www.youtube.com/watch?v=zVnmVDSEoXc. FIrst introducing this with a kernel config is a good idea.

Quoted 4 lines

Can we drop hyperbole? There are several examples of hardware that offload (a subset of) flower. That the current kernel implementation has the properties you describe is pretty much irrelevant for current hw offload use-cases.

Simon,

"current hw offload use-cases" is the problem; these models offer no extensibility. For instance, if a new protocol appears or a user wants to support their own custom protocol in things like tc-flower there is no feasible way to do this. Unfortunately, as of today it seems, we are still bound by the marketing department at hardware vendors that pick and choose the protocols that they think their customers want and are willing to invest in-- we need to get past this once and for all! IMO, what we need is a common way to extend the kernel, tc, and other applications for new protocols and features, but also be able to apply that method to extend to the hardware which is _offloading_ kernel

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

functionality which in this case is flow dissector. The technology is there to do this as programmable NICs for instance are the rage, but we do need to create common APIs to be able to do that. Note this isn't just tc, but a whole space of features; for instance, XDP hints is nice idea for the NIC to provide information about protocols in a packet, but unless/until there is a way to program the device to pull out arbitrary information that the user cares about like something from their custom protocol, then it's very limited utility...

Quoted 2 lines

Vendors have the ability to code up arbitrary hints today. They just haven't open sourced it or made it widely available. I don't see how

Vendors can do this, but can I do this as a user? If I have a custom protocol can I write some code for that without calling my vendor and can I use that with tc-flower offload as easily as any other protocol? I believe this is what is needed.

Quoted 3 lines

a 'tc' interface would help with this. I suspect most hardware could prepend hints or put other arbitrary data in the descriptor or elsewhere. The compelling reason to open source it is missing.

I'm not sure about that. It's not so much a question of the mechanisms to convey the data (although being restricted to just a few bytes in a receive descriptor for XDP Hints is an obvious limitation), the problem is the generation of the hints themself. For instance, suppose I want to extract the QUIC connection identifier as an XDP Hint? To do this we would need the device to be able to parse in UDP payload and extract the connection identifier. I don't believe that capability is widespread yet, vendors have parsers but generally they have not made them user programmable. And even if they did do that, then we need a common interface to program that functionality-- proprietary APIs are right out due to risk of vendor lockin. I imagine the P4 advocates think they are the solution, but then we have to absorb the maintenance cost of yet another domain specific language and P4 isn't part of the kernel so it really isn't offloading kernel functionality. This is the gap the PANDA fills.

Quoted 4 lines

Then the flwo is fairly straight forward the XDP program reads the hints. Then if the rest of the stack needs this in the skb we have the hash and skb extensions.

Again that's the backend mechanism, the frontend problem is the generation of the hints data itself.

Quoted 22 lines
Quoted 4 lines
Quoted 4 lines

... the NIC could run a BPF program if its programmable to that extent.

Quoted 8 lines

Simon,

True, but that implies that the NIC would just be running code in one CPU instead of another-- i.e., that is doing offload and not acceleration. Hardware parses are more likely to be very specialized and might look something like a parameterized FSM that runs 10x faster than software in a CPU. In order to be able to accelerate, we need to start with a parser representation that is more declarative than

Agree, but I don't see how configuration of this hardware makes sense over 'tc'. This is likely to require compiler tools to generate the microcode or *CAM entries running on the hardware. Having 'tc' run a few link, add-header commands that can be converted into reconfigured hardware (thats not just a CPU on a NIC) seems like we will be asking a lot of firmware. Probably too much for my taste, fixing bugs in firmware is going to be harder then if vendors just give us the compiler tools to generate the parsing logic for their hardware.

Quoted 2 lines

Show me the hardware that can create new parse trees using flower2, do they exist?

Working on it :-)

Quoted 22 lines

If not the flow is like this,

0. build new parse graph and hardware logic using DSL (P4 or otherwise)
1. apply blob output from 0 onto hardware
2. build out flower2 graph
3. flower2 populates hardware but hardware already got it from 0?

I'm missing the point here?

Quoted 10 lines

imperative. This is what PANDA provides, the user writes a parser in a declarative representation (but still in C). Given the front end representation is declarative, we can compile that to a type of byte code that is digestible to instantiate a reasonably programmable hardware parser. This fits well with eBPF where the byte code is domain specific instructions to eBPF, so when the eBPF program runs they can be JIT compiled into CPU instructions for running on the host, but they can be given to driver that can translate or JIT compile the byte code into their hardware parser (coud JIT compile to P4 backend for instance).

Quoted 6 lines

I'm not sure hardware exists that can or will take arbitrary 'tc' commands and build a graph of a new protocols? Also we already have a SW path for arbitrary flow parser with BPF so I see no reasons we need to support yet another one. Even PANDA could produce BPF codes for sofwtare and hardware codes to program the hardware so why is this needed?

Hardware parsers are not general purpose CPUs, but specialized engines that expect input in a declarative representation of an annotated parse graph that includes parameterized functions needed to determine next protocol and length. If we compile PANDA parser, which is in declarative representation, into eBPF then we've lost the structure and essence of the problem so that we can't accelerate the parser in specialized hardware. The alternative I'm suggesting is to extend eBPF to include the declarative representation of the parser. So when the program is downloaded to the kernel it can run in CPU by compiling to host ISA, the kernel can then give the program to the device that in turn can instantiate it in the hardware.

A critical aspect of this method also eliminates any sort of side channel or kernel bypass to program the device, which means the device programming is visible to the kernel hence there is no ambiguity as to what the device is actually doing (this lack of transparency is why protocol specific offloads like LRO have failed to get traction). This visibility is necessary if we are ever to go beyond just getting a few disposable hints from the device and are getting actual operational data for the stack to consume (like accelerated TXDP where we can jump straight to TCP receive processing routine from the driver because the device was able to perform all the stateless TCP and IP processing before giving the packet the host). Generally, I view this direction as extending the boundary of the stack into the device.

Tom

Quoted 5 lines

Also yes I saw the netdevconf but still missed the point Sorry.

Thanks
.John

#14 lore raw
Quoted 44 lines · Tom Herbert
Quoted 43 lines · John Fastabend
Quoted 41 lines · Tom Herbert
Quoted 40 lines · Simon Horman
Quoted 38 lines · Tom Herbert
Quoted 37 lines · Simon Horman
Quoted 34 lines · Tom Herbert
Quoted 33 lines · Jiri Pirko
Quoted 18 lines · Wed, Sep 22, 2021 at 06:38:20AM CEST, [email protected] wrote:
Quoted 15 lines · Felipe Magno de Almeida

The PANDA parser, introduced in [1], addresses most of these problems and introduces a developer friendly highly maintainable approach to adding extensions to the parser. This RFC patch takes a known consumer of flow dissector - tc flower - and shows how it could make use of the PANDA Parser by mostly cutnpaste of the flower code. The new classifier is called "flower2". The control semantics of flower are maintained but the flow dissector parser is replaced with a PANDA Parser. The iproute2 patch is sent separately - but you'll notice other than replacing the user space tc commands with "flower2" the syntax is exactly the same. To illustrate the flexibility of PANDA we show a simple use case of the issues described in [2] when flower consumes PANDA. The PANDA Parser is part of the PANDA programming model for network datapaths, this is described in
https://github.com/panda-net/panda.

Quoted 4 lines

My only concern is that is there any way to reuse flower code instead of duplicating most of them? Especially when you specifically mentioned flower2 has the same user-space syntax as flower, this makes code reusing more reasonable.

Exactly. I believe it is wrong to introduce new classifier which would basically behave exacly the same as flower, only has different parser implementation under the hood.

Could you please explore the possibility to replace flow_dissector by your dissector optionally at first (kernel config for example)? And I'm not talking only about flower, but about the rest of the flow_dissector users too.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

+1

Does the existing BPF flow dissector not work for some reason? If its purely a hardware mapping problem, couple questions below.

Hi John,

eBPF in its current form is un-acceleratable is a primary problem,

We have no disagreement here. Offloading a general purpose instruction set into an architecture (switch, etc.) that looks nothing like this is a losing game.

Quoted 2 lines

however an eBPF flow dissector would still have the same issues in complexity and manageability that the kernel flow dissector. PANDA

PANDA is a DSL and runtime, similarly P4 is another DSL and runtime environment. P4 can compile to BPF, PANDA can as well. I don't think PANDA or P4 belong in kernel. We can argue about preferred DSLs but I don't think that is a @netdev @bpf concern.

Quoted 11 lines

pretty much can address that since the same source code for flow dissector used in tc-flower could be compiled into eBPF and used with TC (that gives extensibility at some incremental performance degradation). There is an interesting caveat there in that to satisfy verifier we had to break up the parser to avoid being flagged for complexity. The parser code however already started with a restricted structure that enforces rules that prevent the issues the verified is checking for, when we get to verifier though it doesn't have any that context and hence views it as general purpose code. Introducing domain specific constructs into eBPF, like the byte code I mentioned, would simplify the verifier in that case.

We have some type specific constructs already. For example we know certain helpers will return a max value, etc. and can avoid extra bounds checks. If we can safely make more assumptions based on the types of the program and/or types of variables lets do it. I'm all in for optimizations in the verifier side.

If you have specific complexity problems we can work to solve those either in the clang backend or in verifier itself. Solving these will help all use cases so again happy to help here.

Quoted 37 lines
Quoted 37 lines
Quoted 36 lines
Quoted 36 lines
Quoted 36 lines
Quoted 11 lines
Quoted 10 lines

Hi Jiri,

Yes, the intent is to replace flow dissector with a parser that is more extensible, more manageable and can be accelerated in hardware (good luck trying to HW accelerate flow dissector as is ;-) ). I did a presentation on this topic at the last Netdev conf:
https://www.youtube.com/watch?v=zVnmVDSEoXc. FIrst introducing this with a kernel config is a good idea.

Quoted 4 lines

Can we drop hyperbole? There are several examples of hardware that offload (a subset of) flower. That the current kernel implementation has the properties you describe is pretty much irrelevant for current hw offload use-cases.

Simon,

"current hw offload use-cases" is the problem; these models offer no extensibility. For instance, if a new protocol appears or a user wants to support their own custom protocol in things like tc-flower there is no feasible way to do this. Unfortunately, as of today it seems, we are still bound by the marketing department at hardware vendors that pick and choose the protocols that they think their customers want and are willing to invest in-- we need to get past this once and for all! IMO, what we need is a common way to extend the kernel, tc, and other applications for new protocols and features, but also be able to apply that method to extend to the hardware which is _offloading_ kernel functionality which in this case is flow dissector. The technology is there to do this as programmable NICs for instance are the rage, but we do need to create common APIs to be able to do that. Note this isn't just tc, but a whole space of features; for instance, XDP hints is nice idea for the NIC to provide information about protocols in a packet, but unless/until there is a way to program the device to pull out arbitrary information that the user cares about like something from their custom protocol, then it's very limited utility...

Quoted 7 lines
Quoted 2 lines

Vendors have the ability to code up arbitrary hints today. They just haven't open sourced it or made it widely available. I don't see how

Vendors can do this, but can I do this as a user? If I have a custom protocol can I write some code for that without calling my vendor and can I use that with tc-flower offload as easily as any other protocol? I believe this is what is needed.

I agree it would be great for the vendors to expose this, but I don't see how flower2 gets us there yet. Said vendors could give us the tools needed now, but haven't.

Quoted 8 lines
Quoted 4 lines

a 'tc' interface would help with this. I suspect most hardware could prepend hints or put other arbitrary data in the descriptor or elsewhere. The compelling reason to open source it is missing.

I'm not sure about that. It's not so much a question of the mechanisms to convey the data (although being restricted to just a few bytes in a receive descriptor for XDP Hints is an obvious limitation), the

We have multi-buffer support coming so we could use pages of data for metadata if we wanted fairly easily once that lands. We could even have hardware DMA the metadata into a page and just add that to the frag list without any copying.

Quoted 4 lines

problem is the generation of the hints themself. For instance, suppose I want to extract the QUIC connection identifier as an XDP Hint? To do this we would need the device to be able to parse in UDP payload and extract the connection identifier. I don't believe that capability is

Quoted 8 lines

widespread yet, vendors have parsers but generally they have not made them user programmable. And even if they did do that, then we need a common interface to program that functionality-- proprietary APIs are right out due to risk of vendor lockin. I imagine the P4 advocates think they are the solution, but then we have to absorb the maintenance cost of yet another domain specific language and P4 isn't part of the kernel so it really isn't offloading kernel functionality. This is the gap the PANDA fills.

I don't think P4 or Panda should be in-kernel. The kernel has a BPF parser that can do arbitrary protocol parsing today. I don't see a reason to add another thing on the chance a hardware offload might come around. Anyways P4/Panda can compile to the BPF parser or flower if they want and do their DSL magic on top. And sure we might want to improve the clang backends, the existing flower classifier, and BPF verifier.

BPF knows about skbs and its attach points. If it can assume bounds lengths or other simplifying constraints automatically lets do it.

Without hardware support I can't see any advantage to flower2. And even if we had support the amount of firmware logic going into taking that parse graph into hardware makes me a bit nervous. I would prefer to see a proper compiler that generates the microcode and *CAM table entires necessary to implement said switch logic from any DSL although I prefer P4. Sure that compiler wont be in kernel most likely, but I want transparency and I want tools to configure my software how I want it. Neither requries a kernel shim.

Quoted 8 lines
Quoted 5 lines

Then the flwo is fairly straight forward the XDP program reads the hints. Then if the rest of the stack needs this in the skb we have the hash and skb extensions.

Again that's the backend mechanism, the frontend problem is the generation of the hints data itself.

Sure, but my point is the mechanism exists today to generate arbitrary hints and no vendor has stepped up and provide code to do it. The only conclusion I can come up with is its not valuable on their side to do it.

Quoted 23 lines
Quoted 23 lines
Quoted 5 lines
Quoted 5 lines

... the NIC could run a BPF program if its programmable to that extent.

Quoted 8 lines

Simon,

True, but that implies that the NIC would just be running code in one CPU instead of another-- i.e., that is doing offload and not acceleration. Hardware parses are more likely to be very specialized and might look something like a parameterized FSM that runs 10x faster than software in a CPU. In order to be able to accelerate, we need to start with a parser representation that is more declarative than

Agree, but I don't see how configuration of this hardware makes sense over 'tc'. This is likely to require compiler tools to generate the microcode or *CAM entries running on the hardware. Having 'tc' run a few link, add-header commands that can be converted into reconfigured hardware (thats not just a CPU on a NIC) seems like we will be asking a lot of firmware. Probably too much for my taste, fixing bugs in firmware is going to be harder then if vendors just give us the compiler tools to generate the parsing logic for their hardware.

Quoted 4 lines
Quoted 2 lines

Show me the hardware that can create new parse trees using flower2, do they exist?

Working on it :-)

OK I think flower2 should wait for the hardware then.

Quoted 30 lines
Quoted 23 lines

If not the flow is like this,

0. build new parse graph and hardware logic using DSL (P4 or otherwise)
1. apply blob output from 0 onto hardware
2. build out flower2 graph
3. flower2 populates hardware but hardware already got it from 0?

I'm missing the point here?

Quoted 10 lines

imperative. This is what PANDA provides, the user writes a parser in a declarative representation (but still in C). Given the front end representation is declarative, we can compile that to a type of byte code that is digestible to instantiate a reasonably programmable hardware parser. This fits well with eBPF where the byte code is domain specific instructions to eBPF, so when the eBPF program runs they can be JIT compiled into CPU instructions for running on the host, but they can be given to driver that can translate or JIT compile the byte code into their hardware parser (coud JIT compile to P4 backend for instance).

Quoted 6 lines

I'm not sure hardware exists that can or will take arbitrary 'tc' commands and build a graph of a new protocols? Also we already have a SW path for arbitrary flow parser with BPF so I see no reasons we need to support yet another one. Even PANDA could produce BPF codes for sofwtare and hardware codes to program the hardware so why is this needed?

Quoted 2 lines

Hardware parsers are not general purpose CPUs, but specialized engines that expect input in a declarative representation of an annotated

Of course.

Quoted 9 lines

parse graph that includes parameterized functions needed to determine next protocol and length. If we compile PANDA parser, which is in declarative representation, into eBPF then we've lost the structure and essence of the problem so that we can't accelerate the parser in specialized hardware. The alternative I'm suggesting is to extend eBPF to include the declarative representation of the parser. So when the program is downloaded to the kernel it can run in CPU by compiling to host ISA, the kernel can then give the program to the device that in turn can instantiate it in the hardware.

This feels like multiple levels of abstraction for no reason. Why not just open up the device and give it the declaration directly. I know some people disagree, but why are we creating all this code when the entire purpose can be done by simply passing the info to the hardware directly. I see no reason BPF should pick up extra complexity just so some hardware device can take it and convert it out of BPF and run some annotations.

Quoted 13 lines

A critical aspect of this method also eliminates any sort of side channel or kernel bypass to program the device, which means the device programming is visible to the kernel hence there is no ambiguity as to what the device is actually doing (this lack of transparency is why protocol specific offloads like LRO have failed to get traction). This visibility is necessary if we are ever to go beyond just getting a few disposable hints from the device and are getting actual operational data for the stack to consume (like accelerated TXDP where we can jump straight to TCP receive processing routine from the driver because the device was able to perform all the stateless TCP and IP processing before giving the packet the host). Generally, I view this direction as extending the boundary of the stack into the device.

Agree we need visibility into what the hardware is doing if we want complex offloads. But, I don't see why we need to complicated the software stacks to support the offload.

Anyways IMO we need hardware support to make heads or tails of this.

Quoted 8 lines

Tom

Quoted 5 lines

Also yes I saw the netdevconf but still missed the point Sorry.

Thanks
.John

#16 lore raw
In reply to a message not in the archive
Quoted 234 lines · Tom Herbert
Quoted 222 lines · John Fastabend
Quoted 1 line · Tom Herbert

On Wed, Sep 22, 2021 at 2:41 PM John Fastabend <[email protected]>

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 1 line · Tom Herbert

On Wed, Sep 22, 2021 at 11:00 AM Simon Horman <

Quoted 3 lines · [email protected]> wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · Tom Herbert
Quoted 1 line

On Wed, Sep 22, 2021 at 8:49 AM Simon Horman <

Quoted 3 lines · [email protected]> wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · Tom Herbert
Quoted 1 line

On Tue, Sep 21, 2021 at 9:46 PM Jiri Pirko <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Wed, Sep 22, 2021 at 06:38:20AM CEST,

Quoted 4 lines · [email protected] wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines · Felipe Magno de Almeida

The PANDA parser, introduced in [1], addresses most of

these problems

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

and introduces a developer friendly highly maintainable

approach to

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

adding extensions to the parser. This RFC patch takes a

known consumer

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

of flow dissector - tc flower - and shows how it could

make use of

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the PANDA Parser by mostly cutnpaste of the flower

code. The new

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

classifier is called "flower2". The control semantics

of flower are

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

maintained but the flow dissector parser is replaced

with a PANDA

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Parser. The iproute2 patch is sent separately - but

you'll notice

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

other than replacing the user space tc commands with

"flower2" the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

syntax is exactly the same. To illustrate the

flexibility of PANDA we

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

show a simple use case of the issues described in [2]

when flower

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

consumes PANDA. The PANDA Parser is part of the PANDA

programming

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

model for network datapaths, this is described in
https://github.com/panda-net/panda.

My only concern is that is there any way to reuse flower

code instead

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

of duplicating most of them? Especially when you

specifically mentioned

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

flower2 has the same user-space syntax as flower, this

makes code

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

reusing more reasonable.

Exactly. I believe it is wrong to introduce new classifier

which would

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

basically behave exacly the same as flower, only has

different parser

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

implementation under the hood.

Could you please explore the possibility to replace

flow_dissector by

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

your dissector optionally at first (kernel config for

example)? And I'm

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

not talking only about flower, but about the rest of the

flow_dissector

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

users too.

+1

Does the existing BPF flow dissector not work for some reason? If its

purely

Quoted 5 lines
Quoted 1 line

a hardware mapping problem, couple questions below.

Hi John,

eBPF in its current form is un-acceleratable is a primary problem,

We have no disagreement here. Offloading a general purpose instruction set into an architecture (switch, etc.) that looks nothing like this is a losing game.

Quoted 2 lines

however an eBPF flow dissector would still have the same issues in complexity and manageability that the kernel flow dissector. PANDA

PANDA is a DSL and runtime, similarly P4 is another DSL and runtime environment. P4 can compile to BPF, PANDA can as well. I don't think PANDA or P4 belong in kernel. We can argue about preferred DSLs but I don't think that is a @netdev @bpf concern.

Quoted 11 lines

pretty much can address that since the same source code for flow dissector used in tc-flower could be compiled into eBPF and used with TC (that gives extensibility at some incremental performance degradation). There is an interesting caveat there in that to satisfy verifier we had to break up the parser to avoid being flagged for complexity. The parser code however already started with a restricted structure that enforces rules that prevent the issues the verified is checking for, when we get to verifier though it doesn't have any that context and hence views it as general purpose code. Introducing domain specific constructs into eBPF, like the byte code I mentioned, would simplify the verifier in that case.

We have some type specific constructs already. For example we know certain helpers will return a max value, etc. and can avoid extra bounds checks. If we can safely make more assumptions based on the types of the program and/or types of variables lets do it. I'm all in for optimizations in the verifier side.

If you have specific complexity problems we can work to solve those either in the clang backend or in verifier itself. Solving these will help all use cases so again happy to help here.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Hi Jiri,

Yes, the intent is to replace flow dissector with a parser

that is

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

more extensible, more manageable and can be accelerated in

hardware

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

(good luck trying to HW accelerate flow dissector as is ;-)

). I did a

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

presentation on this topic at the last Netdev conf:
https://www.youtube.com/watch?v=zVnmVDSEoXc. FIrst

introducing this

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

with a kernel config is a good idea.

Can we drop hyperbole? There are several examples of hardware

that

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

offload (a subset of) flower. That the current kernel

implementation has

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the properties you describe is pretty much irrelevant for

current hw

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

offload use-cases.

Simon,

"current hw offload use-cases" is the problem; these models

offer no

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

extensibility. For instance, if a new protocol appears or a user

wants

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

to support their own custom protocol in things like tc-flower

there is

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

no feasible way to do this. Unfortunately, as of today it seems,

we

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

are still bound by the marketing department at hardware vendors

that

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

pick and choose the protocols that they think their customers

want and

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

are willing to invest in-- we need to get past this once and for

all!

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

IMO, what we need is a common way to extend the kernel, tc, and

other

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

applications for new protocols and features, but also be able to

apply

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

that method to extend to the hardware which is _offloading_

kernel

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

functionality which in this case is flow dissector. The

technology is

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

there to do this as programmable NICs for instance are the rage,

but

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

we do need to create common APIs to be able to do that. Note this isn't just tc, but a whole space of features; for instance, XDP

hints

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

is nice idea for the NIC to provide information about protocols

in a

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

packet, but unless/until there is a way to program the device to

pull

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

out arbitrary information that the user cares about like

something

Quoted 9 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

from their custom protocol, then it's very limited utility...

Vendors have the ability to code up arbitrary hints today. They just haven't open sourced it or made it widely available. I don't see how

Vendors can do this, but can I do this as a user? If I have a custom protocol can I write some code for that without calling my vendor and can I use that with tc-flower offload as easily as any other protocol? I believe this is what is needed.

I agree it would be great for the vendors to expose this, but I don't see how flower2 gets us there yet. Said vendors could give us the tools needed now, but haven't.

Quoted 3 lines
Quoted 3 lines

a 'tc' interface would help with this. I suspect most hardware could prepend hints or put other arbitrary data in the descriptor or

elsewhere.

Quoted 5 lines
Quoted 1 line

The compelling reason to open source it is missing.

I'm not sure about that. It's not so much a question of the mechanisms to convey the data (although being restricted to just a few bytes in a receive descriptor for XDP Hints is an obvious limitation), the

We have multi-buffer support coming so we could use pages of data for metadata if we wanted fairly easily once that lands. We could even have hardware DMA the metadata into a page and just add that to the frag list without any copying.

Quoted 4 lines

problem is the generation of the hints themself. For instance, suppose I want to extract the QUIC connection identifier as an XDP Hint? To do this we would need the device to be able to parse in UDP payload and extract the connection identifier. I don't believe that capability is

Quoted 8 lines

widespread yet, vendors have parsers but generally they have not made them user programmable. And even if they did do that, then we need a common interface to program that functionality-- proprietary APIs are right out due to risk of vendor lockin. I imagine the P4 advocates think they are the solution, but then we have to absorb the maintenance cost of yet another domain specific language and P4 isn't part of the kernel so it really isn't offloading kernel functionality. This is the gap the PANDA fills.

I don't think P4 or Panda should be in-kernel. The kernel has a BPF parser that can do arbitrary protocol parsing today. I don't see a reason to add another thing on the chance a hardware offload might come around. Anyways P4/Panda can compile to the BPF parser or flower if they want and do their DSL magic on top. And sure we might want to improve the clang backends, the existing flower classifier, and BPF verifier.

Quoted 5 lines

BPF knows about skbs and its attach points. If it can assume bounds lengths or other simplifying constraints automatically lets do it.

Without hardware support I can't see any advantage to flower2.

John,

Quoted 11 lines

Please look at patch log, there are number of problems that have come up flow dissector over the years. Most of this is related to inherent inflexibility, limitations, missing support for fairly basic protocols, and there's a lot of information loss because of the fixed monolithic data structures. I've said it many times: skb_flow_dissect is the function we love to hate. Maybe it's arguable, bit I claim it's 2000 lines of spaghetti code. I don't think there's anyone to blame for that, this was a consequence of evolving very useful feature that isn't really amenable to being written in sequence of imperative instructions (if you recall it used to be even worse with something like 20 goto's scattered about that defied any semblance of logical program flow :-) ).

OK, but if thats the goal then shouldn't this series target replacing the flow_dissector code directly? I don't see any edits to ./net/core.

Quoted 5 lines

The equivalent code in PANDA is far simpler, extensible, and maintainable and there are opportunities for context aware optimizations that achieve higher performance (we'll post performance numbers showing that shortly). It's also portable to different environments both SW and HW.

If so replace flow_dissector then I think and lets debate that.

My first question as a flow dissector replacement would be the BPF flow dissector was intended to solve the generic parsing problem. Why would Panda be better? My assumption here is that BPF should solve the generic parsing problem, but as we noted isn't very friendly to HW offload. So we jumped immediately into HW offload space. If the problem is tc_flower is not flexible enough couldn't we make tc_flower use the BPF dissector? That should still allow tc flower to do its offload above the sw BPF dissector to hardware just fine.

I guess my first level question is why did BPF flow dissector program not solve the SW generic parsing problem. I read the commit messages and didn't find the answer.

.John

Quoted 146 lines

Tom

Quoted 142 lines

even if we had support the amount of firmware logic going into taking that parse graph into hardware makes me a bit nervous. I would prefer to see a proper compiler that generates the microcode and *CAM table entires necessary to implement said switch logic from any DSL although I prefer P4. Sure that compiler wont be in kernel most likely, but I want transparency and I want tools to configure my software how I want it. Neither requries a kernel shim.

Quoted 8 lines
Quoted 5 lines

Then the flwo is fairly straight forward the XDP program reads the hints. Then if the rest of the stack needs this in the skb we have the hash and skb extensions.

Again that's the backend mechanism, the frontend problem is the generation of the hints data itself.

Sure, but my point is the mechanism exists today to generate arbitrary hints and no vendor has stepped up and provide code to do it. The only conclusion I can come up with is its not valuable on their side to do it.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

... the NIC could run a BPF program if its programmable to that

extent.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line

Simon,

True, but that implies that the NIC would just be running code in one CPU instead of another-- i.e., that is doing offload and not acceleration. Hardware parses are more likely to be very specialized and might look something like a parameterized FSM that runs 10x

faster

Quoted 12 lines
Quoted 12 lines
Quoted 2 lines

than software in a CPU. In order to be able to accelerate, we need to start with a parser representation that is more declarative than

Agree, but I don't see how configuration of this hardware makes sense over 'tc'. This is likely to require compiler tools to generate the microcode or *CAM entries running on the hardware. Having 'tc' run a few link, add-header commands that can be converted into reconfigured hardware (thats not just a CPU on a NIC) seems like we will be asking a lot of firmware. Probably too much for my taste, fixing bugs in firmware is going to be harder then if vendors just give us the compiler tools to generate the parsing logic for their hardware.

Quoted 4 lines
Quoted 2 lines

Show me the hardware that can create new parse trees using flower2, do they exist?

Working on it :-)

OK I think flower2 should wait for the hardware then.

Quoted 5 lines
Quoted 5 lines

If not the flow is like this,

0. build new parse graph and hardware logic using DSL (P4 or

otherwise)

Quoted 8 lines
Quoted 8 lines

1. apply blob output from 0 onto hardware
2. build out flower2 graph
3. flower2 populates hardware but hardware already got it from 0?

I'm missing the point here?

Quoted 1 line

imperative. This is what PANDA provides, the user writes a parser in

a

Quoted 17 lines
Quoted 10 lines
Quoted 9 lines

declarative representation (but still in C). Given the front end representation is declarative, we can compile that to a type of byte code that is digestible to instantiate a reasonably programmable hardware parser. This fits well with eBPF where the byte code is domain specific instructions to eBPF, so when the eBPF program runs they can be JIT compiled into CPU instructions for running on the host, but they can be given to driver that can translate or JIT compile the byte code into their hardware parser (coud JIT compile to P4 backend for instance).

Quoted 6 lines

I'm not sure hardware exists that can or will take arbitrary 'tc' commands and build a graph of a new protocols? Also we already have a SW path for arbitrary flow parser with BPF so I see no reasons we need to support yet another one. Even PANDA could produce BPF codes for sofwtare and hardware codes to program the hardware so why is this needed?

Quoted 2 lines

Hardware parsers are not general purpose CPUs, but specialized engines that expect input in a declarative representation of an annotated

Of course.

Quoted 9 lines

parse graph that includes parameterized functions needed to determine next protocol and length. If we compile PANDA parser, which is in declarative representation, into eBPF then we've lost the structure and essence of the problem so that we can't accelerate the parser in specialized hardware. The alternative I'm suggesting is to extend eBPF to include the declarative representation of the parser. So when the program is downloaded to the kernel it can run in CPU by compiling to host ISA, the kernel can then give the program to the device that in turn can instantiate it in the hardware.

This feels like multiple levels of abstraction for no reason. Why not just open up the device and give it the declaration directly. I know some people disagree, but why are we creating all this code when the entire purpose can be done by simply passing the info to the hardware directly. I see no reason BPF should pick up extra complexity just so some hardware device can take it and convert it out of BPF and run some annotations.

Quoted 13 lines

A critical aspect of this method also eliminates any sort of side channel or kernel bypass to program the device, which means the device programming is visible to the kernel hence there is no ambiguity as to what the device is actually doing (this lack of transparency is why protocol specific offloads like LRO have failed to get traction). This visibility is necessary if we are ever to go beyond just getting a few disposable hints from the device and are getting actual operational data for the stack to consume (like accelerated TXDP where we can jump straight to TCP receive processing routine from the driver because the device was able to perform all the stateless TCP and IP processing before giving the packet the host). Generally, I view this direction as extending the boundary of the stack into the device.

Agree we need visibility into what the hardware is doing if we want complex offloads. But, I don't see why we need to complicated the software stacks to support the offload.

Anyways IMO we need hardware support to make heads or tails of this.

Quoted 8 lines

Tom

Quoted 5 lines

Also yes I saw the netdevconf but still missed the point Sorry.

Thanks
.John

#17 lore raw
Quoted 248 lines · John Fastabend
Quoted 234 lines · Tom Herbert
Quoted 222 lines · John Fastabend
Quoted 1 line · Tom Herbert

On Wed, Sep 22, 2021 at 2:41 PM John Fastabend <[email protected]>

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 1 line · Tom Herbert

On Wed, Sep 22, 2021 at 11:00 AM Simon Horman <

Quoted 3 lines · [email protected]> wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · Tom Herbert
Quoted 1 line

On Wed, Sep 22, 2021 at 8:49 AM Simon Horman <

Quoted 3 lines · [email protected]> wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · Tom Herbert
Quoted 1 line

On Tue, Sep 21, 2021 at 9:46 PM Jiri Pirko <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Wed, Sep 22, 2021 at 06:38:20AM CEST,

Quoted 4 lines · [email protected] wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines · Felipe Magno de Almeida

The PANDA parser, introduced in [1], addresses most of

these problems

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

and introduces a developer friendly highly maintainable

approach to

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

adding extensions to the parser. This RFC patch takes a

known consumer

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

of flow dissector - tc flower - and shows how it could

make use of

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the PANDA Parser by mostly cutnpaste of the flower

code. The new

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

classifier is called "flower2". The control semantics

of flower are

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

maintained but the flow dissector parser is replaced

with a PANDA

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Parser. The iproute2 patch is sent separately - but

you'll notice

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

other than replacing the user space tc commands with

"flower2" the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

syntax is exactly the same. To illustrate the

flexibility of PANDA we

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

show a simple use case of the issues described in [2]

when flower

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

consumes PANDA. The PANDA Parser is part of the PANDA

programming

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

model for network datapaths, this is described in
https://github.com/panda-net/panda.

My only concern is that is there any way to reuse flower

code instead

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

of duplicating most of them? Especially when you

specifically mentioned

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

flower2 has the same user-space syntax as flower, this

makes code

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

reusing more reasonable.

Exactly. I believe it is wrong to introduce new classifier

which would

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

basically behave exacly the same as flower, only has

different parser

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

implementation under the hood.

Could you please explore the possibility to replace

flow_dissector by

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

your dissector optionally at first (kernel config for

example)? And I'm

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

not talking only about flower, but about the rest of the

flow_dissector

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

users too.

+1

Does the existing BPF flow dissector not work for some reason? If its

purely

Quoted 5 lines
Quoted 1 line

a hardware mapping problem, couple questions below.

Hi John,

eBPF in its current form is un-acceleratable is a primary problem,

We have no disagreement here. Offloading a general purpose instruction set into an architecture (switch, etc.) that looks nothing like this is a losing game.

Quoted 2 lines

however an eBPF flow dissector would still have the same issues in complexity and manageability that the kernel flow dissector. PANDA

PANDA is a DSL and runtime, similarly P4 is another DSL and runtime environment. P4 can compile to BPF, PANDA can as well. I don't think PANDA or P4 belong in kernel. We can argue about preferred DSLs but I don't think that is a @netdev @bpf concern.

Quoted 11 lines

pretty much can address that since the same source code for flow dissector used in tc-flower could be compiled into eBPF and used with TC (that gives extensibility at some incremental performance degradation). There is an interesting caveat there in that to satisfy verifier we had to break up the parser to avoid being flagged for complexity. The parser code however already started with a restricted structure that enforces rules that prevent the issues the verified is checking for, when we get to verifier though it doesn't have any that context and hence views it as general purpose code. Introducing domain specific constructs into eBPF, like the byte code I mentioned, would simplify the verifier in that case.

We have some type specific constructs already. For example we know certain helpers will return a max value, etc. and can avoid extra bounds checks. If we can safely make more assumptions based on the types of the program and/or types of variables lets do it. I'm all in for optimizations in the verifier side.

If you have specific complexity problems we can work to solve those either in the clang backend or in verifier itself. Solving these will help all use cases so again happy to help here.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Hi Jiri,

Yes, the intent is to replace flow dissector with a parser

that is

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

more extensible, more manageable and can be accelerated in

hardware

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

(good luck trying to HW accelerate flow dissector as is ;-)

). I did a

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

presentation on this topic at the last Netdev conf:
https://www.youtube.com/watch?v=zVnmVDSEoXc. FIrst

introducing this

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

with a kernel config is a good idea.

Can we drop hyperbole? There are several examples of hardware

that

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

offload (a subset of) flower. That the current kernel

implementation has

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the properties you describe is pretty much irrelevant for

current hw

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

offload use-cases.

Simon,

"current hw offload use-cases" is the problem; these models

offer no

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

extensibility. For instance, if a new protocol appears or a user

wants

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

to support their own custom protocol in things like tc-flower

there is

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

no feasible way to do this. Unfortunately, as of today it seems,

we

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

are still bound by the marketing department at hardware vendors

that

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

pick and choose the protocols that they think their customers

want and

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

are willing to invest in-- we need to get past this once and for

all!

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

IMO, what we need is a common way to extend the kernel, tc, and

other

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

applications for new protocols and features, but also be able to

apply

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

that method to extend to the hardware which is _offloading_

kernel

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

functionality which in this case is flow dissector. The

technology is

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

there to do this as programmable NICs for instance are the rage,

but

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

we do need to create common APIs to be able to do that. Note this isn't just tc, but a whole space of features; for instance, XDP

hints

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

is nice idea for the NIC to provide information about protocols

in a

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

packet, but unless/until there is a way to program the device to

pull

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

out arbitrary information that the user cares about like

something

Quoted 9 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

from their custom protocol, then it's very limited utility...

Vendors have the ability to code up arbitrary hints today. They just haven't open sourced it or made it widely available. I don't see how

Vendors can do this, but can I do this as a user? If I have a custom protocol can I write some code for that without calling my vendor and can I use that with tc-flower offload as easily as any other protocol? I believe this is what is needed.

I agree it would be great for the vendors to expose this, but I don't see how flower2 gets us there yet. Said vendors could give us the tools needed now, but haven't.

Quoted 3 lines
Quoted 3 lines

a 'tc' interface would help with this. I suspect most hardware could prepend hints or put other arbitrary data in the descriptor or

elsewhere.

Quoted 5 lines
Quoted 1 line

The compelling reason to open source it is missing.

I'm not sure about that. It's not so much a question of the mechanisms to convey the data (although being restricted to just a few bytes in a receive descriptor for XDP Hints is an obvious limitation), the

We have multi-buffer support coming so we could use pages of data for metadata if we wanted fairly easily once that lands. We could even have hardware DMA the metadata into a page and just add that to the frag list without any copying.

Quoted 4 lines

problem is the generation of the hints themself. For instance, suppose I want to extract the QUIC connection identifier as an XDP Hint? To do this we would need the device to be able to parse in UDP payload and extract the connection identifier. I don't believe that capability is

Quoted 8 lines

widespread yet, vendors have parsers but generally they have not made them user programmable. And even if they did do that, then we need a common interface to program that functionality-- proprietary APIs are right out due to risk of vendor lockin. I imagine the P4 advocates think they are the solution, but then we have to absorb the maintenance cost of yet another domain specific language and P4 isn't part of the kernel so it really isn't offloading kernel functionality. This is the gap the PANDA fills.

I don't think P4 or Panda should be in-kernel. The kernel has a BPF parser that can do arbitrary protocol parsing today. I don't see a reason to add another thing on the chance a hardware offload might come around. Anyways P4/Panda can compile to the BPF parser or flower if they want and do their DSL magic on top. And sure we might want to improve the clang backends, the existing flower classifier, and BPF verifier.

Quoted 5 lines

BPF knows about skbs and its attach points. If it can assume bounds lengths or other simplifying constraints automatically lets do it.

Without hardware support I can't see any advantage to flower2.

John,

Quoted 11 lines

Please look at patch log, there are number of problems that have come up flow dissector over the years. Most of this is related to inherent inflexibility, limitations, missing support for fairly basic protocols, and there's a lot of information loss because of the fixed monolithic data structures. I've said it many times: skb_flow_dissect is the function we love to hate. Maybe it's arguable, bit I claim it's 2000 lines of spaghetti code. I don't think there's anyone to blame for that, this was a consequence of evolving very useful feature that isn't really amenable to being written in sequence of imperative instructions (if you recall it used to be even worse with something like 20 goto's scattered about that defied any semblance of logical program flow :-) ).

Quoted 3 lines

OK, but if thats the goal then shouldn't this series target replacing the flow_dissector code directly? I don't see any edits to ./net/core.

John,

Well this is just an RFC ;-). We'll follow with the patch series that more directly illustrates replacing kernel flow dissector.

Quoted 11 lines
Quoted 5 lines

The equivalent code in PANDA is far simpler, extensible, and maintainable and there are opportunities for context aware optimizations that achieve higher performance (we'll post performance numbers showing that shortly). It's also portable to different environments both SW and HW.

If so replace flow_dissector then I think and lets debate that.

My first question as a flow dissector replacement would be the BPF flow dissector was intended to solve the generic parsing problem. Why would Panda be better?

To be clear PANDA is a programming model for the datapath not an execution environment-- I view it as complementary to kernel, eBPF, DPDK, etc. Similar to how we are suggesting to replace the kernel flow dissector with a PANDA derived flow dissector, we can implement a BPF flow dissector in PANDA as well. This should be as simple as recompiling the parser we're using in this patch for eBPF (we'll do that experiment). As I mentioned the immediate benefits are a simplified code base and improved program structure in the source source. With a context aware optimizing compiler we can output C code that has higher performance than the equivalent handwritten imperative code. The longer term benefits are that the same exact parser code is now accleratable and a more user-friendly interface for users adding their own custom protocols to generic tc-flower.

Quoted 3 lines

My assumption here is that BPF should
solve the generic parsing problem, but as we noted isn't very friendly to HW offload.

Right, not friendly to HW offload but that's also correlated to not being very friendly programmability in general.

Quoted 3 lines

So we jumped immediately into HW offload
space. If the problem is tc_flower is not flexible enough couldn't we make tc_flower use the BPF dissector?

Yes, in the software model we would use a BPF dissector, I'm just saying that that for generic tc-flower we would derive that from PANDA which is going to be better performance and easier to make the changes in TC flower application for dynamic CLI to use PANDA parser. Without any additional considerations, all we're really doing is rewriting the BPF and kernel flow dissector in a simpler model but retaining the same functionality (although there is a nice advantage that both instances can be derived from the same code base).

Quoted 3 lines

That should
still allow tc flower to do its offload above the sw BPF dissector to hardware just fine.

Right but we need something to offload, and it really has to be identical functionality to what kernel does. While we can't offload an eBPF flow dissector, we can offload a flow dissector which starts from an expression in PANDA and is also the basis for an eBPF one kernel uses.

Quoted 4 lines

I guess my first level question is why did BPF flow dissector program not solve the SW generic parsing problem. I read the commit messages and didn't find the answer.

I do think eBPF is key to providing a generic software parser, doing an eBPF parser in PANDA has the advantages I mentioned. This does lead to a more profound question with regards to the kernel flow dissector we have today in the kernel: can the flow dissector be completely removed and replaced with just an eBPF hook that is populated with a default parser program as part of kernel compilation? I believe the major reason to have a kernel flow dissector instead of a default eBPF flow dissector is for performance, presumably native kernel code is faster than eBPF code in kernel. But if the eBPF code is actually faster, like in PANDA where we can optimize the code with context, then the performance issue might be moot. So now, instead of eBPF being used as an optional hook, it's actively replacing some core kernel functionality from boot (hence we're starting to rewrite the kernel itself in eBPF which is why I call it profound). That is potentially a big win for extensibility, flexibility, and accelerability also. I think this is something we should explore, but maybe take an incremental approach to get there by first moving the kernel flow dissector to a simpler model.

Tom

Quoted 151 lines

.John

Quoted 146 lines

Tom

Quoted 142 lines

even if we had support the amount of firmware logic going into taking that parse graph into hardware makes me a bit nervous. I would prefer to see a proper compiler that generates the microcode and *CAM table entires necessary to implement said switch logic from any DSL although I prefer P4. Sure that compiler wont be in kernel most likely, but I want transparency and I want tools to configure my software how I want it. Neither requries a kernel shim.

Quoted 8 lines
Quoted 5 lines

Then the flwo is fairly straight forward the XDP program reads the hints. Then if the rest of the stack needs this in the skb we have the hash and skb extensions.

Again that's the backend mechanism, the frontend problem is the generation of the hints data itself.

Sure, but my point is the mechanism exists today to generate arbitrary hints and no vendor has stepped up and provide code to do it. The only conclusion I can come up with is its not valuable on their side to do it.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

... the NIC could run a BPF program if its programmable to that

extent.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line

Simon,

True, but that implies that the NIC would just be running code in one CPU instead of another-- i.e., that is doing offload and not acceleration. Hardware parses are more likely to be very specialized and might look something like a parameterized FSM that runs 10x

faster

Quoted 12 lines
Quoted 12 lines
Quoted 2 lines

than software in a CPU. In order to be able to accelerate, we need to start with a parser representation that is more declarative than

Agree, but I don't see how configuration of this hardware makes sense over 'tc'. This is likely to require compiler tools to generate the microcode or *CAM entries running on the hardware. Having 'tc' run a few link, add-header commands that can be converted into reconfigured hardware (thats not just a CPU on a NIC) seems like we will be asking a lot of firmware. Probably too much for my taste, fixing bugs in firmware is going to be harder then if vendors just give us the compiler tools to generate the parsing logic for their hardware.

Quoted 4 lines
Quoted 2 lines

Show me the hardware that can create new parse trees using flower2, do they exist?

Working on it :-)

OK I think flower2 should wait for the hardware then.

Quoted 5 lines
Quoted 5 lines

If not the flow is like this,

0. build new parse graph and hardware logic using DSL (P4 or

otherwise)

Quoted 8 lines
Quoted 8 lines

1. apply blob output from 0 onto hardware
2. build out flower2 graph
3. flower2 populates hardware but hardware already got it from 0?

I'm missing the point here?

Quoted 1 line

imperative. This is what PANDA provides, the user writes a parser in

a

Quoted 17 lines
Quoted 10 lines
Quoted 9 lines

declarative representation (but still in C). Given the front end representation is declarative, we can compile that to a type of byte code that is digestible to instantiate a reasonably programmable hardware parser. This fits well with eBPF where the byte code is domain specific instructions to eBPF, so when the eBPF program runs they can be JIT compiled into CPU instructions for running on the host, but they can be given to driver that can translate or JIT compile the byte code into their hardware parser (coud JIT compile to P4 backend for instance).

Quoted 6 lines

I'm not sure hardware exists that can or will take arbitrary 'tc' commands and build a graph of a new protocols? Also we already have a SW path for arbitrary flow parser with BPF so I see no reasons we need to support yet another one. Even PANDA could produce BPF codes for sofwtare and hardware codes to program the hardware so why is this needed?

Quoted 2 lines

Hardware parsers are not general purpose CPUs, but specialized engines that expect input in a declarative representation of an annotated

Of course.

Quoted 9 lines

parse graph that includes parameterized functions needed to determine next protocol and length. If we compile PANDA parser, which is in declarative representation, into eBPF then we've lost the structure and essence of the problem so that we can't accelerate the parser in specialized hardware. The alternative I'm suggesting is to extend eBPF to include the declarative representation of the parser. So when the program is downloaded to the kernel it can run in CPU by compiling to host ISA, the kernel can then give the program to the device that in turn can instantiate it in the hardware.

This feels like multiple levels of abstraction for no reason. Why not just open up the device and give it the declaration directly. I know some people disagree, but why are we creating all this code when the entire purpose can be done by simply passing the info to the hardware directly. I see no reason BPF should pick up extra complexity just so some hardware device can take it and convert it out of BPF and run some annotations.

Quoted 13 lines

A critical aspect of this method also eliminates any sort of side channel or kernel bypass to program the device, which means the device programming is visible to the kernel hence there is no ambiguity as to what the device is actually doing (this lack of transparency is why protocol specific offloads like LRO have failed to get traction). This visibility is necessary if we are ever to go beyond just getting a few disposable hints from the device and are getting actual operational data for the stack to consume (like accelerated TXDP where we can jump straight to TCP receive processing routine from the driver because the device was able to perform all the stateless TCP and IP processing before giving the packet the host). Generally, I view this direction as extending the boundary of the stack into the device.

Agree we need visibility into what the hardware is doing if we want complex offloads. But, I don't see why we need to complicated the software stacks to support the offload.

Anyways IMO we need hardware support to make heads or tails of this.

Quoted 8 lines

Tom

Quoted 5 lines

Also yes I saw the netdevconf but still missed the point Sorry.

Thanks
.John

maintainer
#18 lore raw
In reply to John Fastabend

Geez, I missed all the fun ;->

Quoted 3 lines · John Fastabend
Quoted 2 lines · Tom Herbert

On Wed, Sep 22, 2021, 6:29 PM John Fastabend <[email protected]> wrote:

[..]

Quoted 14 lines
Quoted 13 lines

John,

Please look at patch log, there are number of problems that have come up flow dissector over the years. Most of this is related to inherent inflexibility, limitations, missing support for fairly basic protocols, and there's a lot of information loss because of the fixed monolithic data structures. I've said it many times: skb_flow_dissect is the function we love to hate. Maybe it's arguable, bit I claim it's 2000 lines of spaghetti code. I don't think there's anyone to blame for that, this was a consequence of evolving very useful feature that isn't really amenable to being written in sequence of imperative instructions (if you recall it used to be even worse with something like 20 goto's scattered about that defied any semblance of logical program flow :-) ).

Quoted 3 lines

OK, but if thats the goal then shouldn't this series target replacing the flow_dissector code directly? I don't see any edits to ./net/core.

Agreed, replacement of flow dissector should be a focus. Jiri's suggestion of a followup patch which shows how the rest of the consumers of flow dissector could be made to use PANDA is a good idea.

IMO (correct me if i am wrong Tom), flower2 was merely intended to illustrate how one would use PANDA i.e there are already two patches of which the first one is essentially PANDA...
IOW, it is just flower but with flow dissector replaced by PANDA.

Quoted 19 lines
Quoted 5 lines

The equivalent code in PANDA is far simpler, extensible, and maintainable and there are opportunities for context aware optimizations that achieve higher performance (we'll post performance numbers showing that shortly). It's also portable to different environments both SW and HW.

If so replace flow_dissector then I think and lets debate that.

My first question as a flow dissector replacement would be the BPF flow dissector was intended to solve the generic parsing problem.

Why would Panda be better? My assumption here is that BPF should solve the generic parsing problem, but as we noted isn't very friendly to HW offload. So we jumped immediately into HW offload space. If the problem is tc_flower is not flexible enough couldn't we make tc_flower use the BPF dissector? That should still allow tc flower to do its offload above the sw BPF dissector to hardware just fine.

Quoted 4 lines

I guess my first level question is why did BPF flow dissector program not solve the SW generic parsing problem. I read the commit messages and didn't find the answer.

Sorry, you cant replace/flowdissector/BPF such that flower can
consume it;-> You are going to face a huge path explosion with the verifier due to the required branching and then resort to all kinds of speacial-cased acrobatics.
See some samples of XDP code going from trying to parse basic TCP options to resorting to tricking the verifier. For shits and giggles, as they say in Eastern Canada, try to do
IPV6 full parsing with BPF (and handle all the variable length
fields).
Generally:
BPF is good for specific smaller parsing tasks; the ebpf flow dissector
hook should be trivial to add to PANDA. And despite PANDA being able
to generate EBPF - I would still say it depends on the depth of the
parse tree to be sensible to use eBPF.

Earlier in the thread you said a couple of things that caught my attention:

Quoted 9 lines

I don't think P4 or Panda should be in-kernel. The kernel has a BPF parser that can do arbitrary protocol parsing today. I don't see a reason to add another thing on the chance a hardware offload might come around. Anyways P4/Panda can compile to the BPF parser or flower if they want and do their DSL magic on top. And sure we might want to improve the clang backends, the existing flower classifier, and BPF verifier.

Quoted 5 lines

Vendors have the ability to code up arbitrary hints today. They just haven't open sourced it or made it widely available. I don't see how a 'tc' interface would help with this. I suspect most hardware could prepend hints or put other arbitrary data in the descriptor or elsewhere. The compelling reason to open source it is missing.

Please, please _lets not_ encourage vendors to continue
keep things proprietary!
Statements like "I don't think P4 or Panda should be in-kernel..." are just too strong.
Instead lets focus on how we can make P4 and other hardware offloads work in conjunction with the kernel (instead of totally bypassing it which is what vendors are doing enmasse already). There are billions of $ invested in these ASICs and lets welcome them into our world. It serves and helps grow the Linux community better. The efforts of switchdev and tc offloading have proven it is possible. Vendors (and i am going to call out Broadcom on the switching side here) are not partaking because they see it as an economical advantage not to partake.

We have learnt a lot technically since switchdev/tc offloads happened. So it is doable.
The first rule is: In order to get h/w offload to work lets also have digitally equivalent implementation in s/w.

cheers,
jamal

#4 lore raw

Re: [PATCH RFC net-next 2/2] net/sched: Add flower2 packet classifier based on flower and PANDA parser

In reply to Marcelo Ricardo Leitner

Hello Marcelo,

Quoted 15 lines · Marcelo Ricardo Leitner

net/sched/cls_flower2_main.c line 326

Quoted 11 lines · Felipe Magno de Almeida
net/sched/cls_flower2_main.c new file +11 -0
+int fl2_panda_parse(struct sk_buff *skb, struct fl2_flow_key* frame)
+{
+     int err;
+     struct panda_parser_big_metadata_one mdata;
+     void *data;
+     size_t pktlen;
+
+     memset(&mdata, 0, sizeof(mdata.panda_data));
+     memcpy(&mdata.frame, frame, sizeof(struct fl2_flow_key));
+
+     err = skb_linearize(skb);

Oh ow. Hopefully this is just for the RFC?

Yes, this is just for the RFC. Our focus was showing how PANDA can easily replace flow dissector by using a useful and complex use-case (flower) and extending it easily. A proper submission would not linearize, but first we need feedback on how this submission should look like.

Kind regards,
--
Felipe Magno de Almeida
Developer @ SiPanda
Owner @ Expertise Solutions
www: https://expertise.dev
phone: +55 48 9 9681.0157
LinkedIn: in/felipealmeida

#19 lore raw
In reply to Jamal Hadi Salim
Quoted 23 lines · Jamal Hadi Salim

Geez, I missed all the fun ;->

Quoted 3 lines · John Fastabend
Quoted 2 lines · Tom Herbert

On Wed, Sep 22, 2021, 6:29 PM John Fastabend <[email protected]> wrote:

[..]

Quoted 14 lines
Quoted 13 lines

John,

Please look at patch log, there are number of problems that have come up flow dissector over the years. Most of this is related to inherent inflexibility, limitations, missing support for fairly basic protocols, and there's a lot of information loss because of the fixed monolithic data structures. I've said it many times: skb_flow_dissect is the function we love to hate. Maybe it's arguable, bit I claim it's 2000 lines of spaghetti code. I don't think there's anyone to blame for that, this was a consequence of evolving very useful feature that isn't really amenable to being written in sequence of imperative instructions (if you recall it used to be even worse with something like 20 goto's scattered about that defied any semblance of logical program flow :-) ).

Quoted 7 lines
Quoted 3 lines

OK, but if thats the goal then shouldn't this series target replacing the flow_dissector code directly? I don't see any edits to ./net/core.

Agreed, replacement of flow dissector should be a focus. Jiri's suggestion of a followup patch which shows how the rest of the consumers of flow dissector could be made to use PANDA is a good idea.

I'de almost propose starting with flow_dissector.c first so we see that the ./net/core user for the SW only case looks good. Although I like the idea of doing it all in BPF directly so could take a crack at that as well. Then compare them.

Quoted 30 lines

IMO (correct me if i am wrong Tom), flower2 was merely intended to illustrate how one would use PANDA i.e there are already two patches of which the first one is essentially PANDA...
IOW, it is just flower but with flow dissector replaced by PANDA.

Quoted 19 lines
Quoted 5 lines

The equivalent code in PANDA is far simpler, extensible, and maintainable and there are opportunities for context aware optimizations that achieve higher performance (we'll post performance numbers showing that shortly). It's also portable to different environments both SW and HW.

If so replace flow_dissector then I think and lets debate that.

My first question as a flow dissector replacement would be the BPF flow dissector was intended to solve the generic parsing problem.

Why would Panda be better? My assumption here is that BPF should solve the generic parsing problem, but as we noted isn't very friendly to HW offload. So we jumped immediately into HW offload space. If the problem is tc_flower is not flexible enough couldn't we make tc_flower use the BPF dissector? That should still allow tc flower to do its offload above the sw BPF dissector to hardware just fine.

Quoted 4 lines

I guess my first level question is why did BPF flow dissector program not solve the SW generic parsing problem. I read the commit messages and didn't find the answer.

Quoted 9 lines

Sorry, you cant replace/flowdissector/BPF such that flower can consume it;-> You are going to face a huge path explosion with the verifier due to the required branching and then resort to all kinds of speacial-cased acrobatics.
See some samples of XDP code going from trying to parse basic TCP options to resorting to tricking the verifier.
For shits and giggles, as they say in Eastern Canada, try to do IPV6 full parsing with BPF (and handle all the variable length fields).

We parse TLVs already and it works just fine. It requires some careful consideration and clang does some dumb things here and there, but it is doable. Sure verifier could maybe be improved around a few cases and C frontend gets in the way sometimes, but PANDA or P4 or other DSL could rewrite in LLVM-IR directly to get the correct output.

Quoted 5 lines

Generally:
BPF is good for specific smaller parsing tasks; the ebpf flow dissector hook should be trivial to add to PANDA. And despite PANDA being able to generate EBPF - I would still say it depends on the depth of the parse tree to be sensible to use eBPF.

Going to disagree. I'm fairly confident we could write a BPF program to do the flow disection. Anyways we can always improve the verifier as needed and this helps lots of things not just this bit. Also flow dissector will be loaded once at early boot most likely so we can allow it to take a bit longer or pre-verify it. Just ideas.

Quoted 13 lines

Earlier in the thread you said a couple of things that caught my attention:

Quoted 9 lines

I don't think P4 or Panda should be in-kernel. The kernel has a BPF parser that can do arbitrary protocol parsing today. I don't see a reason to add another thing on the chance a hardware offload might come around. Anyways P4/Panda can compile to the BPF parser or flower if they want and do their DSL magic on top. And sure we might want to improve the clang backends, the existing flower classifier, and BPF verifier.

Quoted 8 lines
Quoted 5 lines

Vendors have the ability to code up arbitrary hints today. They just haven't open sourced it or made it widely available. I don't see how a 'tc' interface would help with this. I suspect most hardware could prepend hints or put other arbitrary data in the descriptor or elsewhere. The compelling reason to open source it is missing.

Please, please _lets not_ encourage vendors to continue keep things proprietary!

Fair enough. Some frustration leaking in from my side knowing the hardware has been around for years and we've seen multiple proposals but only limited hardware backing. Tom mentioned he was working on the hardware angle so perhaps its close.

Quoted 2 lines

Statements like "I don't think P4 or Panda should be in-kernel..." are just too strong.

Where I wanted to go with this is P4 and Panda are DSLs in my mind. I think we should keep the kernel non-specific to any one DSL. We should have a low level generic way to add them to the kernel, I think this is BPF. Then we let users pick whatever DSL they like and/or make up their own DSL.

Is the counter-argument that Panda is not a DSL, but rather a low-level parser builder pattern.

Quoted 10 lines

Instead lets focus on how we can make P4 and other hardware offloads work in conjunction with the kernel (instead of totally bypassing it which is what vendors are doing enmasse already). There are billions of $ invested in these ASICs and lets welcome them into our world. It serves and helps grow the Linux community better. The efforts of switchdev and tc offloading have proven it is possible. Vendors (and i am going to call out Broadcom on the switching side here) are not partaking because they see it as an economical advantage not to partake.

Quoted 4 lines

We have learnt a lot technically since switchdev/tc offloads happened. So it is doable.
The first rule is: In order to get h/w offload to work lets also have digitally equivalent implementation in s/w.

But there is a cost to this its yet another bit of software to maintain and review and so on. I'm arguing we already have a generic way to implement h/w equivalence and its BPF. So instead of inventing another method to do software we can improve the BPF layer. If we need to build semantics over it that look consumable to hw so be it.

Also the other core question I still don't understand is how a piece of hardware could consume a parse graph piece-meal through an interface like proposed in flower2 and generate an arbitrary parse graph? On the fly none the less. That feels like some very powerful firmware to me.
And I would prefer open source userspace code (non-kernel) to deep magic in firmware. At least then I can see it, patch it, fix it, etc.

Last thing, I'll point out I got back deep into the hardware debate. I'm still not convinced its the right thing to rip out the flow dissector piece and replace it with Panda.

Thanks!
John

#20 lore raw
Quoted 29 lines · John Fastabend
Quoted 27 lines · Jamal Hadi Salim

Geez, I missed all the fun ;->

Quoted 3 lines · John Fastabend
Quoted 2 lines · Tom Herbert

On Wed, Sep 22, 2021, 6:29 PM John Fastabend <[email protected]> wrote:

[..]

Quoted 17 lines
Quoted 13 lines

John,

Please look at patch log, there are number of problems that have come up flow dissector over the years. Most of this is related to inherent inflexibility, limitations, missing support for fairly basic protocols, and there's a lot of information loss because of the fixed monolithic data structures. I've said it many times: skb_flow_dissect is the function we love to hate. Maybe it's arguable, bit I claim it's 2000 lines of spaghetti code. I don't think there's anyone to blame for that, this was a consequence of evolving very useful feature that isn't really amenable to being written in sequence of imperative instructions (if you recall it used to be even worse with something like 20 goto's scattered about that defied any semblance of logical program flow :-) ).

OK, but if thats the goal then shouldn't this series target replacing the flow_dissector code directly? I don't see any edits to ./net/core.

Quoted 8 lines
Quoted 3 lines

Agreed, replacement of flow dissector should be a focus. Jiri's suggestion of a followup patch which shows how the rest of the consumers of flow dissector could be made to use PANDA is a good idea.

I'de almost propose starting with flow_dissector.c first so we see that the ./net/core user for the SW only case looks good. Although I like the idea of doing it all in BPF directly so could take a crack at that as well. Then compare them.

That's an interesting idea and the intent, but note that one of the reasons we are able to outperform flow dissectors is that flow_dissector is parameterized to be generalized whereas PANDA Parser would provide a customized instance for each use case. This is especially evident in the bits to configure what data fields extracts, in PANDA the extraction is explicit so a whole bunch of conditionals in the datapath are eliminated. Replacing flow dissectors might look more like creating a parser instance for each caller instead of calling one function that tries to solve all problems.

Quoted 41 lines
Quoted 31 lines

IMO (correct me if i am wrong Tom), flower2 was merely intended to illustrate how one would use PANDA i.e there are already two patches of which the first one is essentially PANDA...
IOW, it is just flower but with flow dissector replaced by PANDA.

Quoted 19 lines
Quoted 5 lines

The equivalent code in PANDA is far simpler, extensible, and maintainable and there are opportunities for context aware optimizations that achieve higher performance (we'll post performance numbers showing that shortly). It's also portable to different environments both SW and HW.

If so replace flow_dissector then I think and lets debate that.

My first question as a flow dissector replacement would be the BPF flow dissector was intended to solve the generic parsing problem.

Why would Panda be better? My assumption here is that BPF should solve the generic parsing problem, but as we noted isn't very friendly to HW offload. So we jumped immediately into HW offload space. If the problem is tc_flower is not flexible enough couldn't we make tc_flower use the BPF dissector? That should still allow tc flower to do its offload above the sw BPF dissector to hardware just fine.

Quoted 4 lines

I guess my first level question is why did BPF flow dissector program not solve the SW generic parsing problem. I read the commit messages and didn't find the answer.

Quoted 9 lines

Sorry, you cant replace/flowdissector/BPF such that flower can consume it;-> You are going to face a huge path explosion with the verifier due to the required branching and then resort to all kinds of speacial-cased acrobatics.
See some samples of XDP code going from trying to parse basic TCP options to resorting to tricking the verifier.
For shits and giggles, as they say in Eastern Canada, try to do IPV6 full parsing with BPF (and handle all the variable length fields).

Quoted 7 lines

We parse TLVs already and it works just fine. It requires some careful consideration and clang does some dumb things here and there, but it is doable. Sure verifier could maybe be improved around a few cases and C frontend gets in the way sometimes, but PANDA or P4 or other DSL could rewrite in LLVM-IR directly to get the correct output.

Currently the kernel flow dissector doesn't parse TLVs, for instance Hop-by-Hop, DestOpts, IP options, and TCP options are just skipped. TLVs are also the bane of router vendors since they despise implementing protocols that require serialized processing over combinatorial collection of elements. We need to get past this since TLVs are a protocol extensibility which means they need to be a first class citizen in a programmable parser API. (to be clear I'm not saying anyone should add hardcordes TLV processing to __skb_flow_dissect, it's already bloated enough!)

Quoted 6 lines
Quoted 5 lines

Generally:
BPF is good for specific smaller parsing tasks; the ebpf flow dissector hook should be trivial to add to PANDA. And despite PANDA being able to generate EBPF - I would still say it depends on the depth of the parse tree to be sensible to use eBPF.

Quoted 6 lines

Going to disagree. I'm fairly confident we could write a BPF program to do the flow disection. Anyways we can always improve the verifier as needed and this helps lots of things not just this bit. Also flow dissector will be loaded once at early boot most likely so we can allow it to take a bit longer or pre-verify it. Just ideas.

Yes, we already have a panda-compiler that converts PANDA-C in well-optimized eBPF code. Per Jamal's point, that did require breaking up the program into different tails calls. I believe once we hit four layers of protocols we do a tail call and also do a tail call for each instance of TLV processing. Note the tools/testing/selftests/bpf/progs/bpf_flow.c has to deal with this also and does this by statically making every L3 protocol into a tail call (result is more tail calls than equivalent code PANDA).

Quoted 20 lines
Quoted 20 lines

Earlier in the thread you said a couple of things that caught my attention:

Quoted 14 lines

I don't think P4 or Panda should be in-kernel. The kernel has a BPF parser that can do arbitrary protocol parsing today. I don't see a reason to add another thing on the chance a hardware offload might come around. Anyways P4/Panda can compile to the BPF parser or flower if they want and do their DSL magic on top. And sure we might want to improve the clang backends, the existing flower classifier, and BPF verifier.

Vendors have the ability to code up arbitrary hints today. They just haven't open sourced it or made it widely available. I don't see how a 'tc' interface would help with this. I suspect most hardware could prepend hints or put other arbitrary data in the descriptor or elsewhere. The compelling reason to open source it is missing.

Quoted 8 lines
Quoted 2 lines

Please, please _lets not_ encourage vendors to continue keep things proprietary!

Fair enough. Some frustration leaking in from my side knowing the hardware has been around for years and we've seen multiple proposals but only limited hardware backing. Tom mentioned he was working on the hardware angle so perhaps its close.

I share that frustration!

Quoted 11 lines
Quoted 2 lines

Statements like "I don't think P4 or Panda should be in-kernel..." are just too strong.

Where I wanted to go with this is P4 and Panda are DSLs in my mind. I think we should keep the kernel non-specific to any one DSL. We should have a low level generic way to add them to the kernel, I think this is BPF. Then we let users pick whatever DSL they like and/or make up their own DSL.

Is the counter-argument that Panda is not a DSL, but rather a low-level parser builder pattern.

Yes, PANDA is _not_ a DSL in the sense that it uses a new compiler, tool chain, or skill sets to write a program all of which are required for using P4. PANDA-C (just to make it look like the analogous CUDA-C :-) ) is inherently C code that has a program structure for the "low-level parser builder pattern".

Quoted 22 lines
Quoted 11 lines

Instead lets focus on how we can make P4 and other hardware offloads work in conjunction with the kernel (instead of totally bypassing it which is what vendors are doing enmasse already). There are billions of $ invested in these ASICs and lets welcome them into our world. It serves and helps grow the Linux community better. The efforts of switchdev and tc offloading have proven it is possible. Vendors (and i am going to call out Broadcom on the switching side here) are not partaking because they see it as an economical advantage not to partake.

Quoted 4 lines

We have learnt a lot technically since switchdev/tc offloads happened. So it is doable.
The first rule is: In order to get h/w offload to work lets also have digitally equivalent implementation in s/w.

But there is a cost to this its yet another bit of software to maintain and review and so on. I'm arguing we already have a generic way to implement h/w equivalence and its BPF. So instead of inventing another method to do software we can improve the BPF layer. If we need to build semantics over it that look consumable to hw so be it.

Quoted 8 lines

Also the other core question I still don't understand is how a piece of hardware could consume a parse graph piece-meal through an interface like proposed in flower2 and generate an arbitrary parse graph? On the fly none the less. That feels like some very powerful firmware to me.
And I would prefer open source userspace code (non-kernel) to deep magic in firmware. At least then I can see it, patch it, fix it, etc.

An instance of a parser is inherently a parse graph, so it follows that the best representation for a parser is a declarative representation of the parse graph. There was a watershed paper on this by Nick McKeown and others in "Design principles for packet parsers". A common declarative representation is then amenable to instantiation in a hardware engine which is designed to consume that representation (i.e. hardware parsers are basically programmable FSMs), and it's equally straightforward to elicit a parser from a declarative representation into imperative code for running in CPU. In this regard, the only salient difference between P4 and PANDA-C is that the declarative representation can be coded in PANDA as a graph data structure in standard C, and in P4 the encoding is in an explicit language construct.

Quoted 4 lines

Last thing, I'll point out I got back deep into the hardware debate. I'm still not convinced its the right thing to rip out the flow dissector piece and replace it with Panda.

Hardware acceleration is one goal, but there are merits in just considering the software especially in regards to performance and usability. We'll highlight those benefits in future patch series.

Tom

Quoted 3 lines

Thanks!
John

#21 lore raw
Quoted 39 lines · Tom Herbert
Quoted 29 lines · John Fastabend
Quoted 27 lines · Jamal Hadi Salim

Geez, I missed all the fun ;->

Quoted 3 lines · John Fastabend
Quoted 2 lines · Tom Herbert

On Wed, Sep 22, 2021, 6:29 PM John Fastabend <[email protected]> wrote:

[..]

Quoted 17 lines
Quoted 13 lines

John,

Please look at patch log, there are number of problems that have come up flow dissector over the years. Most of this is related to inherent inflexibility, limitations, missing support for fairly basic protocols, and there's a lot of information loss because of the fixed monolithic data structures. I've said it many times: skb_flow_dissect is the function we love to hate. Maybe it's arguable, bit I claim it's 2000 lines of spaghetti code. I don't think there's anyone to blame for that, this was a consequence of evolving very useful feature that isn't really amenable to being written in sequence of imperative instructions (if you recall it used to be even worse with something like 20 goto's scattered about that defied any semblance of logical program flow :-) ).

OK, but if thats the goal then shouldn't this series target replacing the flow_dissector code directly? I don't see any edits to ./net/core.

Quoted 8 lines
Quoted 3 lines

Agreed, replacement of flow dissector should be a focus. Jiri's suggestion of a followup patch which shows how the rest of the consumers of flow dissector could be made to use PANDA is a good idea.

I'de almost propose starting with flow_dissector.c first so we see that the ./net/core user for the SW only case looks good. Although I like the idea of doing it all in BPF directly so could take a crack at that as well. Then compare them.

Quoted 9 lines

That's an interesting idea and the intent, but note that one of the reasons we are able to outperform flow dissectors is that flow_dissector is parameterized to be generalized whereas PANDA Parser would provide a customized instance for each use case. This is especially evident in the bits to configure what data fields extracts, in PANDA the extraction is explicit so a whole bunch of conditionals in the datapath are eliminated. Replacing flow dissectors might look more like creating a parser instance for each caller instead of calling one function that tries to solve all problems.

Can you say a bit more on how a user would configure PANDA parser from user side? For some reason I was under the impression that users could push commands down to build the parser, but when I just read the commit messages again I didn't see the details. Did I make this up?

It feels like a good fit for BPF under the hood at least. User could use Panda to build the BPF parser and then "load" it. The BPF parser is then customized for each user and we already have the hook for it in flow dissector and in tc.

This is the jump I can't make. I get that writing BPF can be challenging so we want a parser language on top to help users. But I'm missing the comparison between C based Panda parser vs native BPF which we already have support for.

Quoted 49 lines
Quoted 42 lines
Quoted 32 lines

IMO (correct me if i am wrong Tom), flower2 was merely intended to illustrate how one would use PANDA i.e there are already two patches of which the first one is essentially PANDA...
IOW, it is just flower but with flow dissector replaced by PANDA.

Quoted 19 lines
Quoted 5 lines

The equivalent code in PANDA is far simpler, extensible, and maintainable and there are opportunities for context aware optimizations that achieve higher performance (we'll post performance numbers showing that shortly). It's also portable to different environments both SW and HW.

If so replace flow_dissector then I think and lets debate that.

My first question as a flow dissector replacement would be the BPF flow dissector was intended to solve the generic parsing problem.

Why would Panda be better? My assumption here is that BPF should solve the generic parsing problem, but as we noted isn't very friendly to HW offload. So we jumped immediately into HW offload space. If the problem is tc_flower is not flexible enough couldn't we make tc_flower use the BPF dissector? That should still allow tc flower to do its offload above the sw BPF dissector to hardware just fine.

Quoted 4 lines

I guess my first level question is why did BPF flow dissector program not solve the SW generic parsing problem. I read the commit messages and didn't find the answer.

Quoted 9 lines

Sorry, you cant replace/flowdissector/BPF such that flower can consume it;-> You are going to face a huge path explosion with the verifier due to the required branching and then resort to all kinds of speacial-cased acrobatics.
See some samples of XDP code going from trying to parse basic TCP options to resorting to tricking the verifier.
For shits and giggles, as they say in Eastern Canada, try to do IPV6 full parsing with BPF (and handle all the variable length fields).

Quoted 7 lines

We parse TLVs already and it works just fine. It requires some careful consideration and clang does some dumb things here and there, but it is doable. Sure verifier could maybe be improved around a few cases and C frontend gets in the way sometimes, but PANDA or P4 or other DSL could rewrite in LLVM-IR directly to get the correct output.

Quoted 9 lines

Currently the kernel flow dissector doesn't parse TLVs, for instance Hop-by-Hop, DestOpts, IP options, and TCP options are just skipped. TLVs are also the bane of router vendors since they despise implementing protocols that require serialized processing over combinatorial collection of elements. We need to get past this since TLVs are a protocol extensibility which means they need to be a first class citizen in a programmable parser API. (to be clear I'm not saying anyone should add hardcordes TLV processing to __skb_flow_dissect, it's already bloated enough!)

No arguments from me here.

Quoted 14 lines
Quoted 7 lines
Quoted 6 lines

Generally:
BPF is good for specific smaller parsing tasks; the ebpf flow dissector hook should be trivial to add to PANDA. And despite PANDA being able to generate EBPF - I would still say it depends on the depth of the parse tree to be sensible to use eBPF.

Quoted 6 lines

Going to disagree. I'm fairly confident we could write a BPF program to do the flow disection. Anyways we can always improve the verifier as needed and this helps lots of things not just this bit. Also flow dissector will be loaded once at early boot most likely so we can allow it to take a bit longer or pre-verify it. Just ideas.

Quoted 8 lines

Yes, we already have a panda-compiler that converts PANDA-C in well-optimized eBPF code. Per Jamal's point, that did require breaking up the program into different tails calls. I believe once we hit four layers of protocols we do a tail call and also do a tail call for each instance of TLV processing. Note the tools/testing/selftests/bpf/progs/bpf_flow.c has to deal with this also and does this by statically making every L3 protocol into a tail call (result is more tail calls than equivalent code PANDA).

Cool, so kernel has everything needed to run the eBPF parser why do we also need the C parser in kernel? Performance wise they should be comparable if not lets fix up the BPF side.

Quoted 80 lines
Quoted 21 lines
Quoted 21 lines

Earlier in the thread you said a couple of things that caught my attention:

Quoted 14 lines

I don't think P4 or Panda should be in-kernel. The kernel has a BPF parser that can do arbitrary protocol parsing today. I don't see a reason to add another thing on the chance a hardware offload might come around. Anyways P4/Panda can compile to the BPF parser or flower if they want and do their DSL magic on top. And sure we might want to improve the clang backends, the existing flower classifier, and BPF verifier.

Vendors have the ability to code up arbitrary hints today. They just haven't open sourced it or made it widely available. I don't see how a 'tc' interface would help with this. I suspect most hardware could prepend hints or put other arbitrary data in the descriptor or elsewhere. The compelling reason to open source it is missing.

Quoted 8 lines
Quoted 2 lines

Please, please _lets not_ encourage vendors to continue keep things proprietary!

Fair enough. Some frustration leaking in from my side knowing the hardware has been around for years and we've seen multiple proposals but only limited hardware backing. Tom mentioned he was working on the hardware angle so perhaps its close.

I share that frustration!

Quoted 11 lines
Quoted 2 lines

Statements like "I don't think P4 or Panda should be in-kernel..." are just too strong.

Where I wanted to go with this is P4 and Panda are DSLs in my mind. I think we should keep the kernel non-specific to any one DSL. We should have a low level generic way to add them to the kernel, I think this is BPF. Then we let users pick whatever DSL they like and/or make up their own DSL.

Is the counter-argument that Panda is not a DSL, but rather a low-level parser builder pattern.

Yes, PANDA is _not_ a DSL in the sense that it uses a new compiler, tool chain, or skill sets to write a program all of which are required for using P4. PANDA-C (just to make it look like the analogous CUDA-C :-) ) is inherently C code that has a program structure for the "low-level parser builder pattern".

Quoted 22 lines
Quoted 11 lines

Instead lets focus on how we can make P4 and other hardware offloads work in conjunction with the kernel (instead of totally bypassing it which is what vendors are doing enmasse already). There are billions of $ invested in these ASICs and lets welcome them into our world. It serves and helps grow the Linux community better. The efforts of switchdev and tc offloading have proven it is possible. Vendors (and i am going to call out Broadcom on the switching side here) are not partaking because they see it as an economical advantage not to partake.

Quoted 4 lines

We have learnt a lot technically since switchdev/tc offloads happened. So it is doable.
The first rule is: In order to get h/w offload to work lets also have digitally equivalent implementation in s/w.

But there is a cost to this its yet another bit of software to maintain and review and so on. I'm arguing we already have a generic way to implement h/w equivalence and its BPF. So instead of inventing another method to do software we can improve the BPF layer. If we need to build semantics over it that look consumable to hw so be it.

Quoted 8 lines

Also the other core question I still don't understand is how a piece of hardware could consume a parse graph piece-meal through an interface like proposed in flower2 and generate an arbitrary parse graph? On the fly none the less. That feels like some very powerful firmware to me.
And I would prefer open source userspace code (non-kernel) to deep magic in firmware. At least then I can see it, patch it, fix it, etc.

Quoted 13 lines

An instance of a parser is inherently a parse graph, so it follows that the best representation for a parser is a declarative representation of the parse graph. There was a watershed paper on this by Nick McKeown and others in "Design principles for packet parsers". A common declarative representation is then amenable to instantiation in a hardware engine which is designed to consume that representation (i.e. hardware parsers are basically programmable FSMs), and it's equally straightforward to elicit a parser from a declarative representation into imperative code for running in CPU. In this regard, the only salient difference between P4 and PANDA-C is that the declarative representation can be coded in PANDA as a graph data structure in standard C, and in P4 the encoding is in an explicit language construct.

Sure agree with all of the above.

Quoted 9 lines
Quoted 5 lines

Last thing, I'll point out I got back deep into the hardware debate. I'm still not convinced its the right thing to rip out the flow dissector piece and replace it with Panda.

Hardware acceleration is one goal, but there are merits in just considering the software especially in regards to performance and usability. We'll highlight those benefits in future patch series.

So usability would be the PADNA-C representation. Good I'm all for better user experience.

From performance side I think it should be almost the same between your Panda-C runner and the BPF jitted code. If not I would want to take a close look as to why not. Improving this BPF generated code would help lots of software running today. For example our XDP LB does parsing and we would love for it to be faster if its possible.

I keep coming back to this. For software case use BPF the infrastructure is there and we already have the hooks in both flow dissector and 'tc' space. Now BPF is not the best for offloading OK fine, can we just do this,

declarative-parse-graph --- sw case -> BPF

                         --- hw case -> hw-cmds

But, the problem I can't understand without more hardware details is how the declarative parse graph makes the jump from some C code into a new hw parser instantiation. IMO before we continue with this RFC we really need to understand that piece. Otherwise we have no way to see if these patches will work on hw and we already have the sw case covered as best I can tell.

Also we would want at least multiple hardware vendors to review it and agree its something that can work across multiple hardware devices. FWIW I'm not a complete stranger to how parsers run in the hardware and how they get encoded even if my info is a few years out of date.

Thanks,
John

Quoted 6 lines

Tom

Quoted 3 lines

Thanks!
John

maintainer
#22 lore raw
In reply to John Fastabend
Quoted 1 line · John Fastabend

Jamal Hadi Salim wrote:

[..]

Quoted 7 lines
Quoted 6 lines

Generally:
BPF is good for specific smaller parsing tasks; the ebpf flow dissector hook should be trivial to add to PANDA. And despite PANDA being able to generate EBPF - I would still say it depends on the depth of the parse tree to be sensible to use eBPF.

Quoted 7 lines

Going to disagree. I'm fairly confident we could write a BPF program to do the flow disection. Anyways we can always improve the verifier as needed and this helps lots of things not just this bit. Also flow dissector will be loaded once at early boot most likely so we can allow it to take a bit longer or pre-verify it. Just ideas.

With current status quo, it is challenging to achieve that goal. Challenge is complexity and not so much instruction count. In particular: If you include the parser as part of your eBPF program you will reduce the amount of what the rest of your program can do; depending how big the parse tree is, you may have no space left at all for extra logic (even with tailcalls etc).

Changes to the eBPF core + verifier will certainly help - but that remains to be seen. Hopefully the next patch set Felipe posts would also have PANDA output for eBPF - then lets see what magic you say can be added on top ;->

Note: I am not against ebpf, just where the fit is needs discussion. For h/w interfacing, thats a totally different ballgame altogether (tc is a good fit).

cheers,
jamal