@@ -1495,6 +1495,12 @@ int mana_query_link_cfg(struct mana_port_context *apc)
struct mana_query_link_config_req req = {};
int err;
+ netdev_assert_locked(ndev);
+
+ err = apc->link_cfg_error;
+ if (err <= 0)
+ return err;
+
mana_gd_init_req_hdr(&req.hdr, MANA_QUERY_LINK_CONFIG,
sizeof(req), sizeof(resp));
@@ -1507,6 +1513,7 @@ int mana_query_link_cfg(struct mana_port_context *apc)
if (err) {
if (err == -EOPNOTSUPP) {
netdev_info_once(ndev, "MANA_QUERY_LINK_CONFIG not supported\n");
+ apc->link_cfg_error = err;
return err;
}
netdev_err(ndev, "Failed to query link config: %d\n", err);
@@ -1524,12 +1531,12 @@ int mana_query_link_cfg(struct mana_port_context *apc)
return err;
}
- if (resp.qos_unconfigured) {
- err = -EINVAL;
- return err;
- }
+ if (resp.qos_unconfigured)
+ return -EINVAL;
+
apc->speed = resp.link_speed_mbps;
apc->max_speed = resp.qos_speed_mbps;
+ apc->link_cfg_error = 0;
return 0;
}
@@ -1541,6 +1548,8 @@ int mana_set_bw_clamp(struct mana_port_context *apc, u32 speed,
struct net_device *ndev = apc->ndev;
int err;
+ netdev_assert_locked(ndev);
+
mana_gd_init_req_hdr(&req.hdr, MANA_SET_BW_CLAMP,
sizeof(req), sizeof(resp));
req.vport = apc->port_handle;
@@ -1574,6 +1583,8 @@ int mana_set_bw_clamp(struct mana_port_context *apc, u32 speed,
if (resp.qos_unconfigured)
netdev_info(ndev, "QoS is unconfigured\n");
+ /* Invalidate the cache; next query will re-fetch from firmware. */
+ apc->link_cfg_error = 1;
return 0;
}
@@ -3759,6 +3770,7 @@ static int mana_probe_port(struct mana_context *ac, int port_idx,
apc->port_handle = INVALID_MANA_HANDLE;
apc->pf_filter_handle = INVALID_MANA_HANDLE;
apc->port_idx = port_idx;
+ apc->link_cfg_error = 1;
apc->cqe_coalescing_enable = 0;
apc->cqe8_coalescing_enable = 0;
@@ -4084,6 +4096,9 @@ int mana_probe(struct gdma_dev *gd, bool resuming)
rtnl_lock();
apc = netdev_priv(ac->ports[i]);
enable_work(&apc->queue_reset_work);
+ netdev_lock(ac->ports[i]);
+ apc->link_cfg_error = 1;
+ netdev_unlock(ac->ports[i]);
err = mana_attach(ac->ports[i]);
rtnl_unlock();
/* Log the port for which the attach failed, stop
@@ -621,6 +621,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 */