summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorErni Sri Satya Vennela <ernis@linux.microsoft.com>2026-06-06 16:32:55 +0300
committerJakub Kicinski <kuba@kernel.org>2026-06-10 03:56:21 +0300
commit8e0ffcc926f42103fdded733a28af16438babc0e (patch)
tree927f0ae92ba70cba634420df22c13b37fb10a100 /include
parentea07514700f7a5125db67c9d1cbfb06e65c30a07 (diff)
downloadlinux-8e0ffcc926f42103fdded733a28af16438babc0e.tar.xz
net: mana: Cache MANA_QUERY_LINK_CONFIG result to avoid repeated HWC queries
mana_query_link_cfg() sends an HWC command to firmware on every call, but the link speed and QoS values it returns only change when the driver explicitly calls mana_set_bw_clamp(). This function is called not only by userspace via ethtool get_link_ksettings, but also periodically by hv_netvsc through netvsc_get_link_ksettings and by the sysfs speed_show attribute via dev_attr_show, resulting in unnecessary HWC traffic every few minutes. Add a link_cfg_error field to mana_port_context to cache the query result. The field uses three states: 1 (not yet queried, initial value set during mana_probe_port), 0 (success, speed/max_speed are valid), or a negative errno for permanent errors like -EOPNOTSUPP when the hardware does not support the command. Transient errors and qos_unconfigured responses are not cached so that subsequent calls will retry. MANA is ops-locked because it implements net_shaper_ops, so the core already takes netdev_lock() around all ethtool_ops and net_shaper_ops entry points. Reuse that lock to serialize mana_query_link_cfg() and mana_set_bw_clamp(). This prevents a concurrent mana_set_bw_clamp() from racing with an in-flight query and publishing stale pre-clamp speed/max_speed. Invalidate the cache inside mana_set_bw_clamp() on success, so all current and future callers that change the link configuration automatically trigger a fresh query on the next mana_query_link_cfg() call. Also reset link_cfg_error during resume in mana_probe() under netdev_lock(), so that any query already in flight cannot later store 0 and silently overwrite the post-resume invalidation. Signed-off-by: Erni Sri Satya Vennela <ernis@linux.microsoft.com> Link: https://patch.msgid.link/20260606133301.2180073-1-ernis@linux.microsoft.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/net/mana/mana.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/net/mana/mana.h b/include/net/mana/mana.h
index 5a9b94e0ef34..13c87baf018e 100644
--- a/include/net/mana/mana.h
+++ b/include/net/mana/mana.h
@@ -562,6 +562,10 @@ struct mana_port_context {
u32 speed;
/* Maximum speed supported by the SKU (mbps) */
u32 max_speed;
+ /* 1 = not queried, 0 = cached success, negative = permanent error.
+ * Protected by the netdev instance lock.
+ */
+ int link_cfg_error;
bool port_is_up;
bool port_st_save; /* Saved port state */