net: add netif_set_real_num_queues() for device reconfig
Subsystems (3)
Jakub Kicinski
maintainercover net: add netif_set_real_num_queues() for device reconfig
This short set adds a helper to make the implementation of two-phase NIC reconfig easier.
Jakub Kicinski (2):
net: add netif_set_real_num_queues() for device reconfig
nfp: use netif_set_real_num_queues()
.../ethernet/netronome/nfp/nfp_net_common.c | 11 ++--- include/linux/netdevice.h | 2 + net/core/dev.c | 44 +++++++++++++++++++ 3 files changed, 49 insertions(+), 8 deletions(-)
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH 1/2 net: add netif_set_real_num_queues() for device reconfig
netif_set_real_num_rx_queues() and netif_set_real_num_tx_queues() can fail which breaks drivers trying to implement reconfiguration in a way that can't leave the device half-broken. In other words those functions are incompatible with prepare/commit approach.
Luckily setting real number of queues can fail only if the number is increased, meaning that if we order operations correctly we can guarantee ending up with either new config (success), or the old one (on error).
Provide a helper implementing such logic so that drivers don't have to duplicate it.
--- include/linux/netdevice.h | 2 ++ net/core/dev.c | 44 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+)
include/linux/netdevice.h +2 -0
@@ -3916,6 +3916,8 @@ static inline int netif_set_real_num_rx_queues(struct net_device *dev, return 0; }#endif +int netif_set_real_num_queues (struct net_device *dev, +unsigned int txq,unsigned int rxq);static inline struct netdev_rx_queue *__netif_get_rx_queue (struct net_device *dev,unsigned int rxq)
net/core/dev.c +44 -0
50 lines not on this page · raw message
Signature · 1 line
2.31.1
Jakub Kicinski
maintainerPATCH 2/2 nfp: use netif_set_real_num_queues()
In reply to Jakub KicinskiAvoid reconfig problems due to failures in netif_set_real_num_tx_queues() by using netif_set_real_num_queues().
--- drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/net/ethernet/netronome/nfp/nfp_net_common.c +3 -8
@@ -3281,17 +3281,12 @@ static int nfp_net_dp_swap_enable(struct nfp_net *nn, struct nfp_net_dp *dp)for (r =0 ; r < nn->max_r_vecs; r++)nfp_net_vector_assign_rings (&nn->dp, &nn->r_vecs[r], r); - err =netif_set_real_num_rx_queues (nn->dp.netdev, nn->dp.num_rx_rings); + err =netif_set_real_num_queues (nn->dp.netdev, + nn->dp.num_stack_tx_rings, + nn->dp.num_rx_rings);if (err)return err; -if (nn->dp.netdev->real_num_tx_queues != nn->dp.num_stack_tx_rings) { - err =netif_set_real_num_tx_queues (nn->dp.netdev, - nn->dp.num_stack_tx_rings); -if (err) -return err; - } -return nfp_net_set_config_and_enable (nn); }
Signature · 1 line
2.31.1
Quoted 6 lines · Jakub Kicinski
This short set adds a helper to make the implementation of two-phase NIC reconfig easier.
Jakub Kicinski (2):
net: addnetif_set_real_num_queues()for device reconfig
nfp: usenetif_set_real_num_queues()
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 8 lines · On Tue, 3 Aug 2021 06:05:25 -0700 you wrote:
This short set adds a helper to make the implementation of two-phase NIC reconfig easier.
Jakub Kicinski (2):
net: addnetif_set_real_num_queues()for device reconfig
nfp: usenetif_set_real_num_queues()[...]
Here is the summary with links:
- [net-next,1/2] net: add netif_set_real_num_queues() for device reconfig
https://git.kernel.org/netdev/net-next/c/271e5b7d00ae - [net-next,2/2] nfp: use netif_set_real_num_queues() https://git.kernel.org/netdev/net-next/c/e874f4557b36
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html