lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240813223325.3522113-1-maze@google.com>
Date: Tue, 13 Aug 2024 15:33:25 -0700
From: "Maciej Żenczykowski" <maze@...gle.com>
To: "Maciej Żenczykowski" <zenczykowski@...il.com>
Cc: Linux Network Development Mailing List <netdev@...r.kernel.org>, "David S . Miller" <davem@...emloft.net>, 
	Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, 
	"Maciej Żenczykowski" <maze@...gle.com>, 
	"Kory Maincent (Dent Project)" <kory.maincent@...tlin.com>, Ahmed Zaki <ahmed.zaki@...el.com>, 
	Edward Cree <ecree.xilinx@...il.com>, Yuyang Huang <yuyanghuang@...gle.com>, 
	Lorenzo Colitti <lorenzo@...gle.com>
Subject: [PATCH net-next] ethtool: add tunable api to disable various firmware offloads

In order to save power (battery), most network hardware
designed for low power environments (ie. battery powered
devices) supports varying types of hardware/firmware offload
(filtering and/or generating replies) of incoming packets.

The goal being to prevent device wakeups caused by ingress 'spam'.

This is particularly true for wifi (especially phones/tablets),
but isn't actually wifi specific.  It can also be implemented
in wired nics (TV) or usb ethernet dongles.

For examples TVs require this to keep power consumption
under (the EU mandated) 2 Watts while idle (display off),
while still being discoverable on the network.

This may include things like: ARP/IPv6 ND, IGMP/MLD, ping, mdns,
but various other possibilities are also possible,
for example:
  ethertype filtering (discarding non-IP ethertypes),
  nat-t keepalive (discarding ingress, automating periodic egress),
  tcp keepalive (generation/processing/filtering),
  tethering (forwarding) offload

In many ways, in its goals, it is somewhat similar to the
relatively standard destination mac filtering most wired nics
have supported for ages: reduce the amount of traffic the host
must handle.

While working on Android we've discovered that there is
no device/driver agnostic way to disable these offloads.

This patch is an attempt to rectify this.

It does not add an API to configure these offloads, as usually
this isn't needed as the driver will just fetch the required
configuration information straight from the kernel.

What it does do is add a simple API to allow disabling (masking)
them, either for debugging or for test purposes.

Cc: "Kory Maincent (Dent Project)" <kory.maincent@...tlin.com>
Cc: Ahmed Zaki <ahmed.zaki@...el.com>
Cc: Edward Cree <ecree.xilinx@...il.com>
Cc: "David S. Miller" <davem@...emloft.net>
Cc: Eric Dumazet <edumazet@...gle.com>
Cc: Jakub Kicinski <kuba@...nel.org>
Cc: Paolo Abeni <pabeni@...hat.com>
Cc: Yuyang Huang <yuyanghuang@...gle.com>
Cc: Lorenzo Colitti <lorenzo@...gle.com>
Signed-off-by: Maciej Żenczykowski <maze@...gle.com>
---
 include/uapi/linux/ethtool.h | 15 +++++++++++++++
 net/ethtool/common.c         |  1 +
 net/ethtool/ioctl.c          |  5 +++++
 3 files changed, 21 insertions(+)

diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index 4a0a6e703483..7b58860c3731 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -224,12 +224,27 @@ struct ethtool_value {
 #define PFC_STORM_PREVENTION_AUTO	0xffff
 #define PFC_STORM_PREVENTION_DISABLE	0
 
+/* For power/wakeup (*not* performance) related offloads */
+enum tunable_fw_offload_disable {
+	ETHTOOL_TUNABLE_FW_OFFLOAD_DISABLE_ALL,
+	ETHTOOL_TUNABLE_FW_OFFLOAD_DISABLE_IPV4_ARP,
+	ETHTOOL_TUNABLE_FW_OFFLOAD_DISABLE_IPV6_ND,
+	ETHTOOL_TUNABLE_FW_OFFLOAD_DISABLE_IPV4_PING,
+	ETHTOOL_TUNABLE_FW_OFFLOAD_DISABLE_IPV6_PING,
+	ETHTOOL_TUNABLE_FW_OFFLOAD_DISABLE_IPV4_IGMP,
+	ETHTOOL_TUNABLE_FW_OFFLOAD_DISABLE_IPV6_MLD,
+	ETHTOOL_TUNABLE_FW_OFFLOAD_DISABLE_IPV4_MDNS,
+	ETHTOOL_TUNABLE_FW_OFFLOAD_DISABLE_IPV6_MDNS,
+	/* 55 bits remaining for future use */
+};
+
 enum tunable_id {
 	ETHTOOL_ID_UNSPEC,
 	ETHTOOL_RX_COPYBREAK,
 	ETHTOOL_TX_COPYBREAK,
 	ETHTOOL_PFC_PREVENTION_TOUT, /* timeout in msecs */
 	ETHTOOL_TX_COPYBREAK_BUF_SIZE,
+	ETHTOOL_FW_OFFLOAD_DISABLE, /* u64 bits numbered from LSB per tunable_fw_offload_disable */
 	/*
 	 * Add your fresh new tunable attribute above and remember to update
 	 * tunable_strings[] in net/ethtool/common.c
diff --git a/net/ethtool/common.c b/net/ethtool/common.c
index 7257ae272296..8dc0c084fce5 100644
--- a/net/ethtool/common.c
+++ b/net/ethtool/common.c
@@ -91,6 +91,7 @@ tunable_strings[__ETHTOOL_TUNABLE_COUNT][ETH_GSTRING_LEN] = {
 	[ETHTOOL_TX_COPYBREAK]	= "tx-copybreak",
 	[ETHTOOL_PFC_PREVENTION_TOUT] = "pfc-prevention-tout",
 	[ETHTOOL_TX_COPYBREAK_BUF_SIZE] = "tx-copybreak-buf-size",
+	[ETHTOOL_FW_OFFLOAD_DISABLE] = "fw-offload-disable",
 };
 
 const char
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 18cf9fa32ae3..31318ded17a7 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -2733,6 +2733,11 @@ static int ethtool_get_module_eeprom(struct net_device *dev,
 static int ethtool_tunable_valid(const struct ethtool_tunable *tuna)
 {
 	switch (tuna->id) {
+	case ETHTOOL_FW_OFFLOAD_DISABLE:
+		if (tuna->len != sizeof(u64) ||
+		    tuna->type_id != ETHTOOL_TUNABLE_U64)
+			return -EINVAL;
+		break;
 	case ETHTOOL_RX_COPYBREAK:
 	case ETHTOOL_TX_COPYBREAK:
 	case ETHTOOL_TX_COPYBREAK_BUF_SIZE:
-- 
2.46.0.76.ge559c4bf1a-goog


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ