提交 6d7ee2ed 编写于 作者: T Tariq Toukan 提交者: Saeed Mahameed

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: NTariq Toukan <tariqt@mellanox.com>
Signed-off-by: NSaeed Mahameed <saeedm@mellanox.com>
上级 0b77f230
...@@ -1086,6 +1086,7 @@ mlx5e_create_netdev(struct mlx5_core_dev *mdev, const struct mlx5e_profile *prof ...@@ -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); int mlx5e_attach_netdev(struct mlx5e_priv *priv);
void mlx5e_detach_netdev(struct mlx5e_priv *priv); void mlx5e_detach_netdev(struct mlx5e_priv *priv);
void mlx5e_destroy_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, void mlx5e_build_nic_params(struct mlx5_core_dev *mdev,
struct mlx5e_rss_params *rss_params, struct mlx5e_rss_params *rss_params,
struct mlx5e_params *params, struct mlx5e_params *params,
......
...@@ -2811,6 +2811,21 @@ int mlx5e_set_dev_port_mtu(struct mlx5e_priv *priv) ...@@ -2811,6 +2811,21 @@ int mlx5e_set_dev_port_mtu(struct mlx5e_priv *priv)
return 0; 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) static void mlx5e_netdev_set_tcs(struct net_device *netdev)
{ {
struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5e_priv *priv = netdev_priv(netdev);
...@@ -4912,7 +4927,6 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv) ...@@ -4912,7 +4927,6 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
{ {
struct net_device *netdev = priv->netdev; struct net_device *netdev = priv->netdev;
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
u16 max_mtu;
mlx5e_init_l2_addr(priv); mlx5e_init_l2_addr(priv);
...@@ -4920,10 +4934,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv) ...@@ -4920,10 +4934,7 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
if (!netif_running(netdev)) if (!netif_running(netdev))
mlx5_set_port_admin_status(mdev, MLX5_PORT_DOWN); mlx5_set_port_admin_status(mdev, MLX5_PORT_DOWN);
/* MTU range: 68 - hw-specific max */ mlx5e_set_netdev_mtu_boundaries(priv);
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_dev_port_mtu(priv); mlx5e_set_dev_port_mtu(priv);
mlx5_lag_add(mdev, netdev); mlx5_lag_add(mdev, netdev);
......
...@@ -1624,13 +1624,7 @@ static void mlx5e_cleanup_rep_tx(struct mlx5e_priv *priv) ...@@ -1624,13 +1624,7 @@ static void mlx5e_cleanup_rep_tx(struct mlx5e_priv *priv)
static void mlx5e_vf_rep_enable(struct mlx5e_priv *priv) static void mlx5e_vf_rep_enable(struct mlx5e_priv *priv)
{ {
struct net_device *netdev = priv->netdev; mlx5e_set_netdev_mtu_boundaries(priv);
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);
} }
static int uplink_rep_async_event(struct notifier_block *nb, unsigned long event, void *data) 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, ...@@ -77,15 +77,14 @@ int mlx5i_init(struct mlx5_core_dev *mdev,
void *ppriv) void *ppriv)
{ {
struct mlx5e_priv *priv = mlx5i_epriv(netdev); struct mlx5e_priv *priv = mlx5i_epriv(netdev);
u16 max_mtu;
int err; int err;
err = mlx5e_netdev_init(netdev, priv, mdev, profile, ppriv); err = mlx5e_netdev_init(netdev, priv, mdev, profile, ppriv);
if (err) if (err)
return err; return err;
mlx5_query_port_max_mtu(mdev, &max_mtu, 1); mlx5e_set_netdev_mtu_boundaries(priv);
netdev->mtu = max_mtu; netdev->mtu = netdev->max_mtu;
mlx5e_build_nic_params(mdev, &priv->rss_params, &priv->channels.params, mlx5e_build_nic_params(mdev, &priv->rss_params, &priv->channels.params,
mlx5e_get_netdev_max_channels(netdev), mlx5e_get_netdev_max_channels(netdev),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册