generic: backport some flow offload helper patch
Backport some flow offload helper patch in preparation for Airoha Flow Offload support. Link: https://github.com/openwrt/openwrt/pull/18166 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
This commit is contained in:
parent
921d438564
commit
34ba7e8a8a
3 changed files with 186 additions and 0 deletions
|
@ -0,0 +1,101 @@
|
|||
From d11e63119432bdb55065d094cb6fd37e9147c70d Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= <ast@fiberby.net>
|
||||
Date: Thu, 11 Apr 2024 10:52:54 +0000
|
||||
Subject: [PATCH] flow_offload: add control flag checking helpers
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
These helpers aim to help drivers, with checking
|
||||
for the presence of unsupported control flags.
|
||||
|
||||
For drivers supporting at least one control flag:
|
||||
flow_rule_is_supp_control_flags()
|
||||
|
||||
For drivers using flow_rule_match_control(), but not using flags:
|
||||
flow_rule_has_control_flags()
|
||||
|
||||
For drivers not using flow_rule_match_control():
|
||||
flow_rule_match_has_control_flags()
|
||||
|
||||
While primarily aimed at FLOW_DISSECTOR_KEY_CONTROL
|
||||
and flow_rule_match_control(), then the first two
|
||||
can also be used with FLOW_DISSECTOR_KEY_ENC_CONTROL
|
||||
and flow_rule_match_enc_control().
|
||||
|
||||
These helpers mirrors the existing check done in sfc:
|
||||
drivers/net/ethernet/sfc/tc.c +276
|
||||
|
||||
Only compile-tested.
|
||||
|
||||
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
|
||||
Reviewed-by: Louis Peens <louis.peens@corigine.com>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
include/net/flow_offload.h | 55 ++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 55 insertions(+)
|
||||
|
||||
--- a/include/net/flow_offload.h
|
||||
+++ b/include/net/flow_offload.h
|
||||
@@ -449,6 +449,61 @@ static inline bool flow_rule_match_key(c
|
||||
return dissector_uses_key(rule->match.dissector, key);
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * flow_rule_is_supp_control_flags() - check for supported control flags
|
||||
+ * @supp_flags: control flags supported by driver
|
||||
+ * @ctrl_flags: control flags present in rule
|
||||
+ * @extack: The netlink extended ACK for reporting errors.
|
||||
+ *
|
||||
+ * Return: true if only supported control flags are set, false otherwise.
|
||||
+ */
|
||||
+static inline bool flow_rule_is_supp_control_flags(const u32 supp_flags,
|
||||
+ const u32 ctrl_flags,
|
||||
+ struct netlink_ext_ack *extack)
|
||||
+{
|
||||
+ if (likely((ctrl_flags & ~supp_flags) == 0))
|
||||
+ return true;
|
||||
+
|
||||
+ NL_SET_ERR_MSG_FMT_MOD(extack,
|
||||
+ "Unsupported match on control.flags %#x",
|
||||
+ ctrl_flags);
|
||||
+
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * flow_rule_has_control_flags() - check for presence of any control flags
|
||||
+ * @ctrl_flags: control flags present in rule
|
||||
+ * @extack: The netlink extended ACK for reporting errors.
|
||||
+ *
|
||||
+ * Return: true if control flags are set, false otherwise.
|
||||
+ */
|
||||
+static inline bool flow_rule_has_control_flags(const u32 ctrl_flags,
|
||||
+ struct netlink_ext_ack *extack)
|
||||
+{
|
||||
+ return !flow_rule_is_supp_control_flags(0, ctrl_flags, extack);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * flow_rule_match_has_control_flags() - match and check for any control flags
|
||||
+ * @rule: The flow_rule under evaluation.
|
||||
+ * @extack: The netlink extended ACK for reporting errors.
|
||||
+ *
|
||||
+ * Return: true if control flags are set, false otherwise.
|
||||
+ */
|
||||
+static inline bool flow_rule_match_has_control_flags(struct flow_rule *rule,
|
||||
+ struct netlink_ext_ack *extack)
|
||||
+{
|
||||
+ struct flow_match_control match;
|
||||
+
|
||||
+ if (!flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CONTROL))
|
||||
+ return false;
|
||||
+
|
||||
+ flow_rule_match_control(rule, &match);
|
||||
+
|
||||
+ return flow_rule_has_control_flags(match.mask->flags, extack);
|
||||
+}
|
||||
+
|
||||
struct flow_stats {
|
||||
u64 pkts;
|
||||
u64 bytes;
|
|
@ -0,0 +1,40 @@
|
|||
From f40a455d01f80c6638be382d75cb1c4e7748d8af Mon Sep 17 00:00:00 2001
|
||||
From: Simon Horman <horms@kernel.org>
|
||||
Date: Tue, 13 Aug 2024 14:33:47 +0100
|
||||
Subject: [PATCH] ipv6: Add ipv6_addr_{cpu_to_be32,be32_to_cpu} helpers
|
||||
|
||||
Add helpers to convert an ipv6 addr, expressed as an array
|
||||
of words, from CPU to big-endian byte order, and vice versa.
|
||||
|
||||
No functional change intended.
|
||||
Compile tested only.
|
||||
|
||||
Suggested-by: Andrew Lunn <andrew@lunn.ch>
|
||||
Link: https://lore.kernel.org/netdev/c7684349-535c-45a4-9a74-d47479a50020@lunn.ch/
|
||||
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
||||
Signed-off-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20240813-ipv6_addr-helpers-v2-1-5c974f8cca3e@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
include/net/ipv6.h | 12 ++++++++++++
|
||||
1 file changed, 12 insertions(+)
|
||||
|
||||
--- a/include/net/ipv6.h
|
||||
+++ b/include/net/ipv6.h
|
||||
@@ -1382,4 +1382,16 @@ static inline void ip6_sock_set_recvpkti
|
||||
release_sock(sk);
|
||||
}
|
||||
|
||||
+#define IPV6_ADDR_WORDS 4
|
||||
+
|
||||
+static inline void ipv6_addr_cpu_to_be32(__be32 *dst, const u32 *src)
|
||||
+{
|
||||
+ cpu_to_be32_array(dst, src, IPV6_ADDR_WORDS);
|
||||
+}
|
||||
+
|
||||
+static inline void ipv6_addr_be32_to_cpu(u32 *dst, const __be32 *src)
|
||||
+{
|
||||
+ be32_to_cpu_array(dst, src, IPV6_ADDR_WORDS);
|
||||
+}
|
||||
+
|
||||
#endif /* _NET_IPV6_H */
|
|
@ -0,0 +1,45 @@
|
|||
From 3dc95a3edd0a86b4a59670b3fafcc64c7d83e2e7 Mon Sep 17 00:00:00 2001
|
||||
From: Alexander Lobakin <aleksander.lobakin@intel.com>
|
||||
Date: Wed, 4 Sep 2024 17:47:45 +0200
|
||||
Subject: [PATCH] netdevice: add netdev_tx_reset_subqueue() shorthand
|
||||
|
||||
Add a shorthand similar to other net*_subqueue() helpers for resetting
|
||||
the queue by its index w/o obtaining &netdev_tx_queue beforehand
|
||||
manually.
|
||||
|
||||
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
|
||||
Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
|
||||
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
|
||||
---
|
||||
include/linux/netdevice.h | 13 ++++++++++++-
|
||||
1 file changed, 12 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/include/linux/netdevice.h
|
||||
+++ b/include/linux/netdevice.h
|
||||
@@ -3616,6 +3616,17 @@ static inline void netdev_tx_reset_queue
|
||||
}
|
||||
|
||||
/**
|
||||
+ * netdev_tx_reset_subqueue - reset the BQL stats and state of a netdev queue
|
||||
+ * @dev: network device
|
||||
+ * @qid: stack index of the queue to reset
|
||||
+ */
|
||||
+static inline void netdev_tx_reset_subqueue(const struct net_device *dev,
|
||||
+ u32 qid)
|
||||
+{
|
||||
+ netdev_tx_reset_queue(netdev_get_tx_queue(dev, qid));
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
* netdev_reset_queue - reset the packets and bytes count of a network device
|
||||
* @dev_queue: network device
|
||||
*
|
||||
@@ -3624,7 +3635,7 @@ static inline void netdev_tx_reset_queue
|
||||
*/
|
||||
static inline void netdev_reset_queue(struct net_device *dev_queue)
|
||||
{
|
||||
- netdev_tx_reset_queue(netdev_get_tx_queue(dev_queue, 0));
|
||||
+ netdev_tx_reset_subqueue(dev_queue, 0);
|
||||
}
|
||||
|
||||
/**
|
Loading…
Reference in a new issue