idpf: move set_real_num_queues to up_complete
Subsystems (2)
PATCH 1/1 idpf: move set_real_num_queues to up_complete
On initial driver load, alloc_etherdev_mqs is called with whatever max queue values are provided by the control plane. However, if the driver is loaded on a system where num_online_cpus() returns less than the max queues, the netdev will think there are more queues than are actually available. Only num_online_cpus() will be allocated, but skb_get_queue_mapping(skb) could possibly return an index beyond the range of allocated queues. Consequently, the packet is silently dropped and it appears as if TX is broken.
Move setting real number of queues to idpf_up_complete so the netdev knows how many queues were actually allocated after any open flow.
--- drivers/net/ethernet/intel/idpf/idpf_lib.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_lib.c +4 -5
@@ -1280,6 +1280,10 @@ static int idpf_set_real_num_queues(struct idpf_vport *vport)static int idpf_up_complete (struct idpf_vport *vport) {struct idpf_netdev_priv *np =netdev_priv (vport->netdev); +int err =idpf_set_real_num_queues (vport); + +if (err) +return err;if (vport->link_up && !netif_carrier_ok (vport->netdev)) {netif_carrier_on (vport->netdev);
@@ -1913,10 +1917,6 @@ int idpf_initiate_soft_reset(struct idpf_vport *vport,if (reset_cause ==IDPF_SR_Q_CHANGE )idpf_vport_alloc_vec_indexes (vport); - err =idpf_set_real_num_queues (vport); -if (err) - goto err_open; -if (current_state == __IDPF_VPORT_UP) err =idpf_vport_open (vport);
@@ -1928,7 +1928,6 @@ int idpf_initiate_soft_reset(struct idpf_vport *vport,idpf_send_add_queues_msg (vport, vport->num_txq, vport->num_complq, vport->num_rxq, vport->num_bufq); -err_open:if (current_state == __IDPF_VPORT_UP)idpf_vport_open (vport);
Signature · 1 line
2.39.2
Quoted 24 lines · Joshua Hay
On initial driver load,
alloc_etherdev_mqsis called with whatever max queue values are provided by the control plane. However, if the driver is loaded on a system wherenum_online_cpus()returns less than the max queues, the netdev will think there are more queues than are actually available. Onlynum_online_cpus()will be allocated, butskb_get_queue_mapping(skb)could possibly return an index beyond the range of allocated queues. Consequently, the packet is silently dropped and it appears as if TX is broken.Move setting real number of queues to
idpf_up_completeso the netdev knows how many queues were actually allocated after any open flow.Fixes 1c325aac10a8 ("idpf: configure resources for TX queues")Signed-off-by Joshua Hay <[email protected]>Reviewed-by Sridhar Samudrala <[email protected]>--- drivers/net/ethernet/intel/idpf/idpf_lib.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)drivers/net/ethernet/intel/idpf/idpf_lib.c +0
-0
drivers/net/ethernet/intel/idpf/idpf_lib.c static int idpf_set_real_num_queues(struct idpf_vport *vport) · line 1286
Quoted 7 lines
drivers/net/ethernet/intel/idpf/idpf_lib.c +4
-0@@ -1280,6 +1280,10 @@ static int idpf_set_real_num_queues(struct idpf_vport *vport)static int idpf_up_complete (struct idpf_vport *vport) {struct idpf_netdev_priv *np =netdev_priv (vport->netdev); +int err =idpf_set_real_num_queues (vport); + +if (err) +return err;
I dislike using the declaration&initialization section to call functions with side effects, but there is no hard rule against it, so be it.
There is a possibility for a future cleanup, outside of the scope of the current fix: idpf_set_real_num_queues() can be replaced with just a call to netif_set_real_num_queues().
I know Jordan tested the patch with success and he agrees to being mentioned, so you can add: