Skip to content

Commit 98e81b0

Browse files
Achiad Shochatdavem330
authored andcommitted
net/mlx5e: Remove the mlx5e_update_priv_params() function
It was used to update netdev priv parameters that require stopping and re-opening the device in a generic way - it got the new parameters and did: ndo_stop(), copy new parameters into current parameters, ndo_open(). We chose to remove it for two reasons: 1) It requires additional instance of struct mlx5e_params on the stack and looking forward we expect this struct to grow. 2) Sometimes we want to do additional operations (besides just updating the priv parameters) while the netdev is stopped. For example, updating netdev->mtu @mlx5e_change_mtu() should be done while the netdev is stopped (done in this commit). Signed-off-by: Achiad Shochat <[email protected]> Signed-off-by: Amir Vadai <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1fc2273 commit 98e81b0

File tree

3 files changed

+60
-50
lines changed

3 files changed

+60
-50
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,6 @@ void mlx5e_del_all_vlan_rules(struct mlx5e_priv *priv);
496496

497497
int mlx5e_open_locked(struct net_device *netdev);
498498
int mlx5e_close_locked(struct net_device *netdev);
499-
int mlx5e_update_priv_params(struct mlx5e_priv *priv,
500-
struct mlx5e_params *new_params);
501499

502500
static inline void mlx5e_tx_notify_hw(struct mlx5e_sq *sq,
503501
struct mlx5e_tx_wqe *wqe, int bf_sz)

drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ static int mlx5e_set_ringparam(struct net_device *dev,
264264
struct ethtool_ringparam *param)
265265
{
266266
struct mlx5e_priv *priv = netdev_priv(dev);
267-
struct mlx5e_params new_params;
267+
bool was_opened;
268268
u16 min_rx_wqes;
269269
u8 log_rq_size;
270270
u8 log_sq_size;
@@ -316,11 +316,18 @@ static int mlx5e_set_ringparam(struct net_device *dev,
316316
return 0;
317317

318318
mutex_lock(&priv->state_lock);
319-
new_params = priv->params;
320-
new_params.log_rq_size = log_rq_size;
321-
new_params.log_sq_size = log_sq_size;
322-
new_params.min_rx_wqes = min_rx_wqes;
323-
err = mlx5e_update_priv_params(priv, &new_params);
319+
320+
was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
321+
if (was_opened)
322+
mlx5e_close_locked(dev);
323+
324+
priv->params.log_rq_size = log_rq_size;
325+
priv->params.log_sq_size = log_sq_size;
326+
priv->params.min_rx_wqes = min_rx_wqes;
327+
328+
if (was_opened)
329+
err = mlx5e_open_locked(dev);
330+
324331
mutex_unlock(&priv->state_lock);
325332

326333
return err;
@@ -342,7 +349,7 @@ static int mlx5e_set_channels(struct net_device *dev,
342349
struct mlx5e_priv *priv = netdev_priv(dev);
343350
int ncv = priv->mdev->priv.eq_table.num_comp_vectors;
344351
unsigned int count = ch->combined_count;
345-
struct mlx5e_params new_params;
352+
bool was_opened;
346353
int err = 0;
347354

348355
if (!count) {
@@ -365,9 +372,16 @@ static int mlx5e_set_channels(struct net_device *dev,
365372
return 0;
366373

367374
mutex_lock(&priv->state_lock);
368-
new_params = priv->params;
369-
new_params.num_channels = count;
370-
err = mlx5e_update_priv_params(priv, &new_params);
375+
376+
was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
377+
if (was_opened)
378+
mlx5e_close_locked(dev);
379+
380+
priv->params.num_channels = count;
381+
382+
if (was_opened)
383+
err = mlx5e_open_locked(dev);
384+
371385
mutex_unlock(&priv->state_lock);
372386

373387
return err;
@@ -673,10 +687,10 @@ static int mlx5e_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
673687
return 0;
674688
}
675689

676-
static int mlx5e_set_rxfh(struct net_device *netdev, const u32 *indir,
690+
static int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir,
677691
const u8 *key, const u8 hfunc)
678692
{
679-
struct mlx5e_priv *priv = netdev_priv(netdev);
693+
struct mlx5e_priv *priv = netdev_priv(dev);
680694
int err = 0;
681695

682696
if (hfunc == ETH_RSS_HASH_NO_CHANGE)
@@ -690,8 +704,8 @@ static int mlx5e_set_rxfh(struct net_device *netdev, const u32 *indir,
690704

691705
priv->params.rss_hfunc = hfunc;
692706
if (test_bit(MLX5E_STATE_OPENED, &priv->state)) {
693-
mlx5e_close_locked(priv->netdev);
694-
err = mlx5e_open_locked(priv->netdev);
707+
mlx5e_close_locked(dev);
708+
err = mlx5e_open_locked(dev);
695709
}
696710

697711
mutex_unlock(&priv->state_lock);
@@ -724,7 +738,7 @@ static int mlx5e_set_tunable(struct net_device *dev,
724738
{
725739
struct mlx5e_priv *priv = netdev_priv(dev);
726740
struct mlx5_core_dev *mdev = priv->mdev;
727-
struct mlx5e_params new_params;
741+
bool was_opened;
728742
u32 val;
729743
int err = 0;
730744

@@ -737,9 +751,16 @@ static int mlx5e_set_tunable(struct net_device *dev,
737751
}
738752

739753
mutex_lock(&priv->state_lock);
740-
new_params = priv->params;
741-
new_params.tx_max_inline = val;
742-
err = mlx5e_update_priv_params(priv, &new_params);
754+
755+
was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
756+
if (was_opened)
757+
mlx5e_close_locked(dev);
758+
759+
priv->params.tx_max_inline = val;
760+
761+
if (was_opened)
762+
err = mlx5e_open_locked(dev);
763+
743764
mutex_unlock(&priv->state_lock);
744765
break;
745766
default:

drivers/net/ethernet/mellanox/mlx5/core/en_main.c

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,26 +1570,6 @@ static int mlx5e_close(struct net_device *netdev)
15701570
return err;
15711571
}
15721572

1573-
int mlx5e_update_priv_params(struct mlx5e_priv *priv,
1574-
struct mlx5e_params *new_params)
1575-
{
1576-
int err = 0;
1577-
int was_opened;
1578-
1579-
WARN_ON(!mutex_is_locked(&priv->state_lock));
1580-
1581-
was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
1582-
if (was_opened)
1583-
mlx5e_close_locked(priv->netdev);
1584-
1585-
priv->params = *new_params;
1586-
1587-
if (was_opened)
1588-
err = mlx5e_open_locked(priv->netdev);
1589-
1590-
return err;
1591-
}
1592-
15931573
static struct rtnl_link_stats64 *
15941574
mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
15951575
{
@@ -1639,20 +1619,22 @@ static int mlx5e_set_features(struct net_device *netdev,
16391619
netdev_features_t features)
16401620
{
16411621
struct mlx5e_priv *priv = netdev_priv(netdev);
1622+
int err = 0;
16421623
netdev_features_t changes = features ^ netdev->features;
1643-
struct mlx5e_params new_params;
1644-
bool update_params = false;
16451624

16461625
mutex_lock(&priv->state_lock);
1647-
new_params = priv->params;
16481626

16491627
if (changes & NETIF_F_LRO) {
1650-
new_params.lro_en = !!(features & NETIF_F_LRO);
1651-
update_params = true;
1652-
}
1628+
bool was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
1629+
1630+
if (was_opened)
1631+
mlx5e_close_locked(priv->netdev);
16531632

1654-
if (update_params)
1655-
mlx5e_update_priv_params(priv, &new_params);
1633+
priv->params.lro_en = !!(features & NETIF_F_LRO);
1634+
1635+
if (was_opened)
1636+
err = mlx5e_open_locked(priv->netdev);
1637+
}
16561638

16571639
if (changes & NETIF_F_HW_VLAN_CTAG_FILTER) {
16581640
if (features & NETIF_F_HW_VLAN_CTAG_FILTER)
@@ -1670,8 +1652,9 @@ static int mlx5e_change_mtu(struct net_device *netdev, int new_mtu)
16701652
{
16711653
struct mlx5e_priv *priv = netdev_priv(netdev);
16721654
struct mlx5_core_dev *mdev = priv->mdev;
1655+
bool was_opened;
16731656
int max_mtu;
1674-
int err;
1657+
int err = 0;
16751658

16761659
mlx5_query_port_max_mtu(mdev, &max_mtu, 1);
16771660

@@ -1683,8 +1666,16 @@ static int mlx5e_change_mtu(struct net_device *netdev, int new_mtu)
16831666
}
16841667

16851668
mutex_lock(&priv->state_lock);
1669+
1670+
was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
1671+
if (was_opened)
1672+
mlx5e_close_locked(netdev);
1673+
16861674
netdev->mtu = new_mtu;
1687-
err = mlx5e_update_priv_params(priv, &priv->params);
1675+
1676+
if (was_opened)
1677+
err = mlx5e_open_locked(netdev);
1678+
16881679
mutex_unlock(&priv->state_lock);
16891680

16901681
return err;

0 commit comments

Comments
 (0)