Skip to content

Commit 81d2fb4

Browse files
plinga1anguy11
authored andcommitted
idpf: avoid vport access in idpf_get_link_ksettings
When the device control plane is removed or the platform running device control plane is rebooted, a reset is detected on the driver. On driver reset, it releases the resources and waits for the reset to complete. If the reset fails, it takes the error path and releases the vport lock. At this time if the monitoring tools tries to access link settings, it call traces for accessing released vport pointer. To avoid it, move link_speed_mbps to netdev_priv structure which removes the dependency on vport pointer and the vport lock in idpf_get_link_ksettings. Also use netif_carrier_ok() to check the link status and adjust the offsetof to use link_up instead of link_speed_mbps. Fixes: 02cbfba ("idpf: add ethtool callbacks") Cc: [email protected] # 6.7+ Reviewed-by: Tarun K Singh <[email protected]> Signed-off-by: Pavan Kumar Linga <[email protected]> Tested-by: Krishneil Singh <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 64502da commit 81d2fb4

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

drivers/net/ethernet/intel/idpf/idpf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ enum idpf_vport_state {
141141
* @adapter: Adapter back pointer
142142
* @vport: Vport back pointer
143143
* @vport_id: Vport identifier
144+
* @link_speed_mbps: Link speed in mbps
144145
* @vport_idx: Relative vport index
145146
* @state: See enum idpf_vport_state
146147
* @netstats: Packet and byte stats
@@ -150,6 +151,7 @@ struct idpf_netdev_priv {
150151
struct idpf_adapter *adapter;
151152
struct idpf_vport *vport;
152153
u32 vport_id;
154+
u32 link_speed_mbps;
153155
u16 vport_idx;
154156
enum idpf_vport_state state;
155157
struct rtnl_link_stats64 netstats;
@@ -287,7 +289,6 @@ struct idpf_port_stats {
287289
* @tx_itr_profile: TX profiles for Dynamic Interrupt Moderation
288290
* @port_stats: per port csum, header split, and other offload stats
289291
* @link_up: True if link is up
290-
* @link_speed_mbps: Link speed in mbps
291292
* @sw_marker_wq: workqueue for marker packets
292293
*/
293294
struct idpf_vport {
@@ -331,7 +332,6 @@ struct idpf_vport {
331332
struct idpf_port_stats port_stats;
332333

333334
bool link_up;
334-
u32 link_speed_mbps;
335335

336336
wait_queue_head_t sw_marker_wq;
337337
};

drivers/net/ethernet/intel/idpf/idpf_ethtool.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,24 +1296,19 @@ static void idpf_set_msglevel(struct net_device *netdev, u32 data)
12961296
static int idpf_get_link_ksettings(struct net_device *netdev,
12971297
struct ethtool_link_ksettings *cmd)
12981298
{
1299-
struct idpf_vport *vport;
1300-
1301-
idpf_vport_ctrl_lock(netdev);
1302-
vport = idpf_netdev_to_vport(netdev);
1299+
struct idpf_netdev_priv *np = netdev_priv(netdev);
13031300

13041301
ethtool_link_ksettings_zero_link_mode(cmd, supported);
13051302
cmd->base.autoneg = AUTONEG_DISABLE;
13061303
cmd->base.port = PORT_NONE;
1307-
if (vport->link_up) {
1304+
if (netif_carrier_ok(netdev)) {
13081305
cmd->base.duplex = DUPLEX_FULL;
1309-
cmd->base.speed = vport->link_speed_mbps;
1306+
cmd->base.speed = np->link_speed_mbps;
13101307
} else {
13111308
cmd->base.duplex = DUPLEX_UNKNOWN;
13121309
cmd->base.speed = SPEED_UNKNOWN;
13131310
}
13141311

1315-
idpf_vport_ctrl_unlock(netdev);
1316-
13171312
return 0;
13181313
}
13191314

drivers/net/ethernet/intel/idpf/idpf_lib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,7 +1860,7 @@ int idpf_initiate_soft_reset(struct idpf_vport *vport,
18601860
* mess with. Nothing below should use those variables from new_vport
18611861
* and should instead always refer to them in vport if they need to.
18621862
*/
1863-
memcpy(new_vport, vport, offsetof(struct idpf_vport, link_speed_mbps));
1863+
memcpy(new_vport, vport, offsetof(struct idpf_vport, link_up));
18641864

18651865
/* Adjust resource parameters prior to reallocating resources */
18661866
switch (reset_cause) {
@@ -1906,7 +1906,7 @@ int idpf_initiate_soft_reset(struct idpf_vport *vport,
19061906
/* Same comment as above regarding avoiding copying the wait_queues and
19071907
* mutexes applies here. We do not want to mess with those if possible.
19081908
*/
1909-
memcpy(vport, new_vport, offsetof(struct idpf_vport, link_speed_mbps));
1909+
memcpy(vport, new_vport, offsetof(struct idpf_vport, link_up));
19101910

19111911
if (reset_cause == IDPF_SR_Q_CHANGE)
19121912
idpf_vport_alloc_vec_indexes(vport);

drivers/net/ethernet/intel/idpf/idpf_virtchnl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static void idpf_handle_event_link(struct idpf_adapter *adapter,
141141
}
142142
np = netdev_priv(vport->netdev);
143143

144-
vport->link_speed_mbps = le32_to_cpu(v2e->link_speed);
144+
np->link_speed_mbps = le32_to_cpu(v2e->link_speed);
145145

146146
if (vport->link_up == v2e->link_status)
147147
return;

0 commit comments

Comments
 (0)