Skip to content

Commit

Permalink
net/mlx5e: Update xon formula
Browse files Browse the repository at this point in the history
Set xon = xoff - netdev's max_mtu.
netdev's max_mtu will give enough time for the pause frame to
arrive at the sender.

Fixes: 0696d60 ("net/mlx5e: Receive buffer configuration")
Signed-off-by: Huy Nguyen <huyn@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
  • Loading branch information
Huy Nguyen authored and Saeed Mahameed committed Mar 29, 2019
1 parent 5ec983e commit e28408e
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ static u32 calculate_xoff(struct mlx5e_priv *priv, unsigned int mtu)
}

static int update_xoff_threshold(struct mlx5e_port_buffer *port_buffer,
u32 xoff, unsigned int mtu)
u32 xoff, unsigned int max_mtu)
{
int i;

Expand All @@ -155,19 +155,20 @@ static int update_xoff_threshold(struct mlx5e_port_buffer *port_buffer,
}

if (port_buffer->buffer[i].size <
(xoff + mtu + (1 << MLX5E_BUFFER_CELL_SHIFT)))
(xoff + max_mtu + (1 << MLX5E_BUFFER_CELL_SHIFT)))
return -ENOMEM;

port_buffer->buffer[i].xoff = port_buffer->buffer[i].size - xoff;
port_buffer->buffer[i].xon = port_buffer->buffer[i].xoff - mtu;
port_buffer->buffer[i].xon =
port_buffer->buffer[i].xoff - max_mtu;
}

return 0;
}

/**
* update_buffer_lossy()
* mtu: device's MTU
* max_mtu: netdev's max_mtu
* pfc_en: <input> current pfc configuration
* buffer: <input> current prio to buffer mapping
* xoff: <input> xoff value
Expand All @@ -184,7 +185,7 @@ static int update_xoff_threshold(struct mlx5e_port_buffer *port_buffer,
* Return 0 if no error.
* Set change to true if buffer configuration is modified.
*/
static int update_buffer_lossy(unsigned int mtu,
static int update_buffer_lossy(unsigned int max_mtu,
u8 pfc_en, u8 *buffer, u32 xoff,
struct mlx5e_port_buffer *port_buffer,
bool *change)
Expand Down Expand Up @@ -221,7 +222,7 @@ static int update_buffer_lossy(unsigned int mtu,
}

if (changed) {
err = update_xoff_threshold(port_buffer, xoff, mtu);
err = update_xoff_threshold(port_buffer, xoff, max_mtu);
if (err)
return err;

Expand All @@ -231,6 +232,7 @@ static int update_buffer_lossy(unsigned int mtu,
return 0;
}

#define MINIMUM_MAX_MTU 9216
int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
u32 change, unsigned int mtu,
struct ieee_pfc *pfc,
Expand All @@ -242,20 +244,22 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
bool update_prio2buffer = false;
u8 buffer[MLX5E_MAX_PRIORITY];
bool update_buffer = false;
unsigned int max_mtu;
u32 total_used = 0;
u8 curr_pfc_en;
int err;
int i;

mlx5e_dbg(HW, priv, "%s: change=%x\n", __func__, change);
max_mtu = max_t(unsigned int, priv->netdev->max_mtu, MINIMUM_MAX_MTU);

err = mlx5e_port_query_buffer(priv, &port_buffer);
if (err)
return err;

if (change & MLX5E_PORT_BUFFER_CABLE_LEN) {
update_buffer = true;
err = update_xoff_threshold(&port_buffer, xoff, mtu);
err = update_xoff_threshold(&port_buffer, xoff, max_mtu);
if (err)
return err;
}
Expand All @@ -265,7 +269,7 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
if (err)
return err;

err = update_buffer_lossy(mtu, pfc->pfc_en, buffer, xoff,
err = update_buffer_lossy(max_mtu, pfc->pfc_en, buffer, xoff,
&port_buffer, &update_buffer);
if (err)
return err;
Expand All @@ -277,8 +281,8 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
if (err)
return err;

err = update_buffer_lossy(mtu, curr_pfc_en, prio2buffer, xoff,
&port_buffer, &update_buffer);
err = update_buffer_lossy(max_mtu, curr_pfc_en, prio2buffer,
xoff, &port_buffer, &update_buffer);
if (err)
return err;
}
Expand All @@ -302,15 +306,15 @@ int mlx5e_port_manual_buffer_config(struct mlx5e_priv *priv,
return -EINVAL;

update_buffer = true;
err = update_xoff_threshold(&port_buffer, xoff, mtu);
err = update_xoff_threshold(&port_buffer, xoff, max_mtu);
if (err)
return err;
}

/* Need to update buffer configuration if xoff value is changed */
if (!update_buffer && xoff != priv->dcbx.xoff) {
update_buffer = true;
err = update_xoff_threshold(&port_buffer, xoff, mtu);
err = update_xoff_threshold(&port_buffer, xoff, max_mtu);
if (err)
return err;
}
Expand Down

0 comments on commit e28408e

Please sign in to comment.