Skip to content

Commit 5f48059

Browse files
Eran Ben Elishabwhacks
authored andcommitted
net/mlx4_en: Fix mixed PFC and Global pause user control requests
commit 6e8814c upstream. Global pause and PFC configuration should be mutually exclusive (i.e. only one of them at most can be set). However, once PFC was turned off, driver automatically turned Global pause on. This is a bug. Fix the driver behaviour to turn off PFC/Global once the user turned the other on. This also fixed a weird behaviour that at a current time, the profile had both PFC and global pause configuration turned on, which is Hardware-wise impossible and caused returning false positive indication to query tools. In addition, fix error code when setting global pause or PFC to change metadata only upon successful change. Also, removed useless debug print. Fixes: af7d518 ("net/mlx4_en: Add DCB PFC support through CEE netlink commands") Fixes: c27a02c ("mlx4_en: Add driver for Mellanox ConnectX 10GbE NIC") Signed-off-by: Eran Ben Elisha <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Signed-off-by: David S. Miller <[email protected]> [bwh: Backported to 3.16: - Drop changes to mlx4_en_dcbnl_set_all() - Don't call mlx4_en_update_pfc_stats_bitmap()] Signed-off-by: Ben Hutchings <[email protected]>
1 parent 8340856 commit 5f48059

File tree

3 files changed

+32
-19
lines changed

3 files changed

+32
-19
lines changed

drivers/net/ethernet/mellanox/mlx4/en_dcb_nl.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ static int mlx4_en_dcbnl_ieee_setpfc(struct net_device *dev,
162162
struct mlx4_en_priv *priv = netdev_priv(dev);
163163
struct mlx4_en_port_profile *prof = priv->prof;
164164
struct mlx4_en_dev *mdev = priv->mdev;
165+
u32 tx_pause, tx_ppp, rx_pause, rx_ppp;
165166
int err;
166167

167168
en_dbg(DRV, priv, "cap: 0x%x en: 0x%x mbc: 0x%x delay: %d\n",
@@ -170,19 +171,23 @@ static int mlx4_en_dcbnl_ieee_setpfc(struct net_device *dev,
170171
pfc->mbc,
171172
pfc->delay);
172173

173-
prof->rx_pause = !pfc->pfc_en;
174-
prof->tx_pause = !pfc->pfc_en;
175-
prof->rx_ppp = pfc->pfc_en;
176-
prof->tx_ppp = pfc->pfc_en;
174+
rx_pause = prof->rx_pause && !pfc->pfc_en;
175+
tx_pause = prof->tx_pause && !pfc->pfc_en;
176+
rx_ppp = pfc->pfc_en;
177+
tx_ppp = pfc->pfc_en;
177178

178179
err = mlx4_SET_PORT_general(mdev->dev, priv->port,
179180
priv->rx_skb_size + ETH_FCS_LEN,
180-
prof->tx_pause,
181-
prof->tx_ppp,
182-
prof->rx_pause,
183-
prof->rx_ppp);
184-
if (err)
181+
tx_pause, tx_ppp, rx_pause, rx_ppp);
182+
if (err) {
185183
en_err(priv, "Failed setting pause params\n");
184+
return err;
185+
}
186+
187+
prof->tx_ppp = tx_ppp;
188+
prof->rx_ppp = rx_ppp;
189+
prof->rx_pause = rx_pause;
190+
prof->tx_pause = tx_pause;
186191

187192
return err;
188193
}

drivers/net/ethernet/mellanox/mlx4/en_ethtool.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -474,21 +474,29 @@ static int mlx4_en_set_pauseparam(struct net_device *dev,
474474
{
475475
struct mlx4_en_priv *priv = netdev_priv(dev);
476476
struct mlx4_en_dev *mdev = priv->mdev;
477+
u8 tx_pause, tx_ppp, rx_pause, rx_ppp;
477478
int err;
478479

479480
if (pause->autoneg)
480481
return -EINVAL;
481482

482-
priv->prof->tx_pause = pause->tx_pause != 0;
483-
priv->prof->rx_pause = pause->rx_pause != 0;
483+
tx_pause = !!(pause->tx_pause);
484+
rx_pause = !!(pause->rx_pause);
485+
rx_ppp = priv->prof->rx_ppp && !(tx_pause || rx_pause);
486+
tx_ppp = priv->prof->tx_ppp && !(tx_pause || rx_pause);
487+
484488
err = mlx4_SET_PORT_general(mdev->dev, priv->port,
485489
priv->rx_skb_size + ETH_FCS_LEN,
486-
priv->prof->tx_pause,
487-
priv->prof->tx_ppp,
488-
priv->prof->rx_pause,
489-
priv->prof->rx_ppp);
490-
if (err)
491-
en_err(priv, "Failed setting pause params\n");
490+
tx_pause, tx_ppp, rx_pause, rx_ppp);
491+
if (err) {
492+
en_err(priv, "Failed setting pause params, err = %d\n", err);
493+
return err;
494+
}
495+
496+
priv->prof->tx_pause = tx_pause;
497+
priv->prof->rx_pause = rx_pause;
498+
priv->prof->tx_ppp = tx_ppp;
499+
priv->prof->rx_ppp = rx_ppp;
492500

493501
return err;
494502
}

drivers/net/ethernet/mellanox/mlx4/en_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ static int mlx4_en_get_profile(struct mlx4_en_dev *mdev)
137137
params->udp_rss = 0;
138138
}
139139
for (i = 1; i <= MLX4_MAX_PORTS; i++) {
140-
params->prof[i].rx_pause = 1;
140+
params->prof[i].rx_pause = !(pfcrx || pfctx);
141141
params->prof[i].rx_ppp = pfcrx;
142-
params->prof[i].tx_pause = 1;
142+
params->prof[i].tx_pause = !(pfcrx || pfctx);
143143
params->prof[i].tx_ppp = pfctx;
144144
params->prof[i].tx_ring_size = MLX4_EN_DEF_TX_RING_SIZE;
145145
params->prof[i].rx_ring_size = MLX4_EN_DEF_RX_RING_SIZE;

0 commit comments

Comments
 (0)