net/mlx5e: Unify logic of MTU boundaries
Expose a new helper that wraps the logic for setting the netdevice's MTU boundaries. Use it for the different components (Eth, rep, IPoIB). Set the netdevice min MTU to ETH_MIN_MTU, and the max according to both the FW capability and the kernel definition. Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
This commit is contained in:
Родитель
0b77f2305f
Коммит
6d7ee2edaa
|
@ -1086,6 +1086,7 @@ mlx5e_create_netdev(struct mlx5_core_dev *mdev, const struct mlx5e_profile *prof
|
|||
int mlx5e_attach_netdev(struct mlx5e_priv *priv);
|
||||
void mlx5e_detach_netdev(struct mlx5e_priv *priv);
|
||||
void mlx5e_destroy_netdev(struct mlx5e_priv *priv);
|
||||
void mlx5e_set_netdev_mtu_boundaries(struct mlx5e_priv *priv);
|
||||
void mlx5e_build_nic_params(struct mlx5_core_dev *mdev,
|
||||
struct mlx5e_rss_params *rss_params,
|
||||
struct mlx5e_params *params,
|
||||
|
|
|
@ -2811,6 +2811,21 @@ int mlx5e_set_dev_port_mtu(struct mlx5e_priv *priv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void mlx5e_set_netdev_mtu_boundaries(struct mlx5e_priv *priv)
|
||||
{
|
||||
struct mlx5e_params *params = &priv->channels.params;
|
||||
struct net_device *netdev = priv->netdev;
|
||||
struct mlx5_core_dev *mdev = priv->mdev;
|
||||
u16 max_mtu;
|
||||
|
||||
/* MTU range: 68 - hw-specific max */
|
||||
netdev->min_mtu = ETH_MIN_MTU;
|
||||
|
||||
mlx5_query_port_max_mtu(mdev, &max_mtu, 1);
|
||||
netdev->max_mtu = min_t(unsigned int, MLX5E_HW2SW_MTU(params, max_mtu),
|
||||
ETH_MAX_MTU);
|
||||
}
|
||||
|
||||
static void mlx5e_netdev_set_tcs(struct net_device *netdev)
|
||||
{
|
||||
struct mlx5e_priv *priv = netdev_priv(netdev);
|
||||
|
@ -4912,7 +4927,6 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
|
|||
{
|
||||
struct net_device *netdev = priv->netdev;
|
||||
struct mlx5_core_dev *mdev = priv->mdev;
|
||||
u16 max_mtu;
|
||||
|
||||
mlx5e_init_l2_addr(priv);
|
||||
|
||||
|
@ -4920,10 +4934,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
|
|||
if (!netif_running(netdev))
|
||||
mlx5_set_port_admin_status(mdev, MLX5_PORT_DOWN);
|
||||
|
||||
/* MTU range: 68 - hw-specific max */
|
||||
netdev->min_mtu = ETH_MIN_MTU;
|
||||
mlx5_query_port_max_mtu(priv->mdev, &max_mtu, 1);
|
||||
netdev->max_mtu = MLX5E_HW2SW_MTU(&priv->channels.params, max_mtu);
|
||||
mlx5e_set_netdev_mtu_boundaries(priv);
|
||||
mlx5e_set_dev_port_mtu(priv);
|
||||
|
||||
mlx5_lag_add(mdev, netdev);
|
||||
|
|
|
@ -1624,13 +1624,7 @@ static void mlx5e_cleanup_rep_tx(struct mlx5e_priv *priv)
|
|||
|
||||
static void mlx5e_vf_rep_enable(struct mlx5e_priv *priv)
|
||||
{
|
||||
struct net_device *netdev = priv->netdev;
|
||||
struct mlx5_core_dev *mdev = priv->mdev;
|
||||
u16 max_mtu;
|
||||
|
||||
netdev->min_mtu = ETH_MIN_MTU;
|
||||
mlx5_query_port_max_mtu(mdev, &max_mtu, 1);
|
||||
netdev->max_mtu = MLX5E_HW2SW_MTU(&priv->channels.params, max_mtu);
|
||||
mlx5e_set_netdev_mtu_boundaries(priv);
|
||||
}
|
||||
|
||||
static int uplink_rep_async_event(struct notifier_block *nb, unsigned long event, void *data)
|
||||
|
|
|
@ -77,15 +77,14 @@ int mlx5i_init(struct mlx5_core_dev *mdev,
|
|||
void *ppriv)
|
||||
{
|
||||
struct mlx5e_priv *priv = mlx5i_epriv(netdev);
|
||||
u16 max_mtu;
|
||||
int err;
|
||||
|
||||
err = mlx5e_netdev_init(netdev, priv, mdev, profile, ppriv);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
mlx5_query_port_max_mtu(mdev, &max_mtu, 1);
|
||||
netdev->mtu = max_mtu;
|
||||
mlx5e_set_netdev_mtu_boundaries(priv);
|
||||
netdev->mtu = netdev->max_mtu;
|
||||
|
||||
mlx5e_build_nic_params(mdev, &priv->rss_params, &priv->channels.params,
|
||||
mlx5e_get_netdev_max_channels(netdev),
|
||||
|
|
Загрузка…
Ссылка в новой задаче