Skip to contentSkip to conversation

net: add netif_set_real_num_queues() for device reconfig

PATCH Applied Jakub Kicinski 3 participants 5 messages Aug 3, 2021 – Aug 4, 2021

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

cover 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
author maintainer
#1 lore raw

PATCH 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
index cd136499ec59..1b4d4509d04b 100644
@@ -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
author maintainer
#2 lore raw

PATCH 2/2 nfp: use netif_set_real_num_queues()

In reply to Jakub Kicinski

Avoid 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
index 15078f9dc9f1..5bfa22accf2c 100644
@@ -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
#4 lore raw
In reply to Jakub Kicinski
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: add netif_set_real_num_queues() for device reconfig
nfp: use netif_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