Merge branch 'queues'
Jakub Kicinski says: ==================== 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. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
8730379ee0
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -2973,6 +2973,50 @@ int netif_set_real_num_rx_queues(struct net_device *dev, unsigned int rxq)
|
||||
EXPORT_SYMBOL(netif_set_real_num_rx_queues);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* netif_set_real_num_queues - set actual number of RX and TX queues used
|
||||
* @dev: Network device
|
||||
* @txq: Actual number of TX queues
|
||||
* @rxq: Actual number of RX queues
|
||||
*
|
||||
* Set the real number of both TX and RX queues.
|
||||
* Does nothing if the number of queues is already correct.
|
||||
*/
|
||||
int netif_set_real_num_queues(struct net_device *dev,
|
||||
unsigned int txq, unsigned int rxq)
|
||||
{
|
||||
unsigned int old_rxq = dev->real_num_rx_queues;
|
||||
int err;
|
||||
|
||||
if (txq < 1 || txq > dev->num_tx_queues ||
|
||||
rxq < 1 || rxq > dev->num_rx_queues)
|
||||
return -EINVAL;
|
||||
|
||||
/* Start from increases, so the error path only does decreases -
|
||||
* decreases can't fail.
|
||||
*/
|
||||
if (rxq > dev->real_num_rx_queues) {
|
||||
err = netif_set_real_num_rx_queues(dev, rxq);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
if (txq > dev->real_num_tx_queues) {
|
||||
err = netif_set_real_num_tx_queues(dev, txq);
|
||||
if (err)
|
||||
goto undo_rx;
|
||||
}
|
||||
if (rxq < dev->real_num_rx_queues)
|
||||
WARN_ON(netif_set_real_num_rx_queues(dev, rxq));
|
||||
if (txq < dev->real_num_tx_queues)
|
||||
WARN_ON(netif_set_real_num_tx_queues(dev, txq));
|
||||
|
||||
return 0;
|
||||
undo_rx:
|
||||
WARN_ON(netif_set_real_num_rx_queues(dev, old_rxq));
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL(netif_set_real_num_queues);
|
||||
|
||||
/**
|
||||
* netif_get_num_default_rss_queues - default number of RSS queues
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user