diff mbox series

[net-next] flow_offload: add l4 port range match

Message ID 1633525615-6341-1-git-send-email-volodymyr.mytnyk@plvision.eu (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series [net-next] flow_offload: add l4 port range match | expand

Checks

Context Check Description
netdev/cover_letter success Single patches do not need cover letters
netdev/fixes_present success Fixes tag not required for -next series
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 2 maintainers not CCed: elic@nvidia.com jiri@nvidia.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 6286 this patch: 6286
netdev/kdoc success Errors and warnings before: 7 this patch: 7
netdev/verify_fixes success No Fixes tag
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 47 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 6350 this patch: 6350
netdev/header_inline success No static functions without inline keyword in header files

Commit Message

Volodymyr Mytnyk Oct. 6, 2021, 1:06 p.m. UTC
From: Volodymyr Mytnyk <vmytnyk@marvell.com>

Current flow offload API doen't allow to offload l4 port range
match dissector (FLOW_DISSECTOR_KEY_PORTS_RANGE) in the driver,
as is no relevant data struct that will hold this information
and pass it to the driver.

Thus, to make offload of l4 port range possible by other drivers
add dedicated dissector port range struct to get min and max
value provided by user.

- add flow_dissector_key_ports_range to store
  l4 port range match.
- add flow_match_ports_range key/mask

tc cmd example:
    tc qd add dev PORT clsact
    tc filter add dev PORT protocol ip ingress \
        flower skip_sw ip_proto udp src_port 2-37 action drop

Signed-off-by: Volodymyr Mytnyk <vmytnyk@marvell.com>
---
 include/net/flow_dissector.h | 10 ++++++++++
 include/net/flow_offload.h   |  6 ++++++
 net/core/flow_offload.c      |  7 +++++++
 3 files changed, 23 insertions(+)

Comments

Jakub Kicinski Oct. 7, 2021, 12:38 a.m. UTC | #1
On Wed,  6 Oct 2021 16:06:54 +0300 Volodymyr Mytnyk wrote:
> From: Volodymyr Mytnyk <vmytnyk@marvell.com>
> 
> Current flow offload API doen't allow to offload l4 port range
> match dissector (FLOW_DISSECTOR_KEY_PORTS_RANGE) in the driver,
> as is no relevant data struct that will hold this information
> and pass it to the driver.
> 
> Thus, to make offload of l4 port range possible by other drivers
> add dedicated dissector port range struct to get min and max
> value provided by user.
> 
> - add flow_dissector_key_ports_range to store
>   l4 port range match.
> - add flow_match_ports_range key/mask
> 
> tc cmd example:
>     tc qd add dev PORT clsact
>     tc filter add dev PORT protocol ip ingress \
>         flower skip_sw ip_proto udp src_port 2-37 action drop
> 
> Signed-off-by: Volodymyr Mytnyk <vmytnyk@marvell.com>

A driver implementation needs to be posted in the same series.
Otherwise it's an API with no in-tree user. Let's consider this
posting an RFC.
Volodymyr Mytnyk [C] Oct. 7, 2021, 2:57 p.m. UTC | #2
Hi Jakub,

> > From: Volodymyr Mytnyk <vmytnyk@marvell.com>
> > 
> > Current flow offload API doen't allow to offload l4 port range
> > match dissector (FLOW_DISSECTOR_KEY_PORTS_RANGE) in the driver,
> > as is no relevant data struct that will hold this information
> > and pass it to the driver.
> > 
> > Thus, to make offload of l4 port range possible by other drivers
> > add dedicated dissector port range struct to get min and max
> > value provided by user.
> > 
> > - add flow_dissector_key_ports_range to store
> >   l4 port range match.
> > - add flow_match_ports_range key/mask
> > 
> > tc cmd example:
> >     tc qd add dev PORT clsact
> >     tc filter add dev PORT protocol ip ingress \
> >         flower skip_sw ip_proto udp src_port 2-37 action drop
> > 
> > Signed-off-by: Volodymyr Mytnyk <vmytnyk@marvell.com>
> 
> A driver implementation needs to be posted in the same series.
> Otherwise it's an API with no in-tree user. Let's consider this
> posting an RFC.
>
Ok, thanks for the comment. Will post RFC with driver code usage included.

Regards,
Volodymyr
diff mbox series

Patch

diff --git a/include/net/flow_dissector.h b/include/net/flow_dissector.h
index ffd386ea0dbb..8eada83a816e 100644
--- a/include/net/flow_dissector.h
+++ b/include/net/flow_dissector.h
@@ -177,6 +177,16 @@  struct flow_dissector_key_ports {
 };
 
 /**
+ * struct flow_dissector_key_ports_range:
+ *	@tp_min: min port number in range
+ *	@tp_max: max port number in range
+ */
+struct flow_dissector_key_ports_range {
+	struct flow_dissector_key_ports tp_min;
+	struct flow_dissector_key_ports tp_max;
+};
+
+/**
  * flow_dissector_key_icmp:
  *		type: ICMP type
  *		code: ICMP code
diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
index dc5c1e69cd9f..cb480afa674d 100644
--- a/include/net/flow_offload.h
+++ b/include/net/flow_offload.h
@@ -48,6 +48,10 @@  struct flow_match_ports {
 	struct flow_dissector_key_ports *key, *mask;
 };
 
+struct flow_match_ports_range {
+	struct flow_dissector_key_ports_range *key, *mask;
+};
+
 struct flow_match_icmp {
 	struct flow_dissector_key_icmp *key, *mask;
 };
@@ -94,6 +98,8 @@  void flow_rule_match_ip(const struct flow_rule *rule,
 			struct flow_match_ip *out);
 void flow_rule_match_ports(const struct flow_rule *rule,
 			   struct flow_match_ports *out);
+void flow_rule_match_ports_range(const struct flow_rule *rule,
+				 struct flow_match_ports_range *out);
 void flow_rule_match_tcp(const struct flow_rule *rule,
 			 struct flow_match_tcp *out);
 void flow_rule_match_icmp(const struct flow_rule *rule,
diff --git a/net/core/flow_offload.c b/net/core/flow_offload.c
index 715b67f6c62f..d218c1deb40b 100644
--- a/net/core/flow_offload.c
+++ b/net/core/flow_offload.c
@@ -104,6 +104,13 @@  void flow_rule_match_ports(const struct flow_rule *rule,
 }
 EXPORT_SYMBOL(flow_rule_match_ports);
 
+void flow_rule_match_ports_range(const struct flow_rule *rule,
+				 struct flow_match_ports_range *out)
+{
+	FLOW_DISSECTOR_MATCH(rule, FLOW_DISSECTOR_KEY_PORTS_RANGE, out);
+}
+EXPORT_SYMBOL(flow_rule_match_ports_range);
+
 void flow_rule_match_tcp(const struct flow_rule *rule,
 			 struct flow_match_tcp *out)
 {