Commit cdca4c48 authored by Yunsheng Lin's avatar Yunsheng Lin Committed by David S. Miller

net: hns3: up/down netdev in hclge module when setting mtu

Currently netdev is down in enet module, and it is before
mtu range checking in hclge module, which may be cause
netdev being down unnecessarily.
Signed-off-by: default avatarYunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: default avatarJian Shen <shenjian15@huawei.com>
Signed-off-by: default avatarSalil Mehta <salil.mehta@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 818f1675
...@@ -1573,18 +1573,11 @@ static int hns3_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, ...@@ -1573,18 +1573,11 @@ static int hns3_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan,
static int hns3_nic_change_mtu(struct net_device *netdev, int new_mtu) static int hns3_nic_change_mtu(struct net_device *netdev, int new_mtu)
{ {
struct hnae3_handle *h = hns3_get_handle(netdev); struct hnae3_handle *h = hns3_get_handle(netdev);
bool if_running = netif_running(netdev);
int ret; int ret;
if (!h->ae_algo->ops->set_mtu) if (!h->ae_algo->ops->set_mtu)
return -EOPNOTSUPP; return -EOPNOTSUPP;
/* if this was called with netdev up then bring netdevice down */
if (if_running) {
(void)hns3_nic_net_stop(netdev);
msleep(100);
}
ret = h->ae_algo->ops->set_mtu(h, new_mtu); ret = h->ae_algo->ops->set_mtu(h, new_mtu);
if (ret) if (ret)
netdev_err(netdev, "failed to change MTU in hardware %d\n", netdev_err(netdev, "failed to change MTU in hardware %d\n",
...@@ -1592,10 +1585,6 @@ static int hns3_nic_change_mtu(struct net_device *netdev, int new_mtu) ...@@ -1592,10 +1585,6 @@ static int hns3_nic_change_mtu(struct net_device *netdev, int new_mtu)
else else
netdev->mtu = new_mtu; netdev->mtu = new_mtu;
/* if the netdev was running earlier, bring it up again */
if (if_running && hns3_nic_net_open(netdev))
ret = -EINVAL;
return ret; return ret;
} }
......
...@@ -6450,6 +6450,8 @@ int hclge_set_vport_mtu(struct hclge_vport *vport, int new_mtu) ...@@ -6450,6 +6450,8 @@ int hclge_set_vport_mtu(struct hclge_vport *vport, int new_mtu)
return -EINVAL; return -EINVAL;
} }
hclge_notify_client(hdev, HNAE3_DOWN_CLIENT);
ret = hclge_set_mac_mtu(hdev, max_frm_size); ret = hclge_set_mac_mtu(hdev, max_frm_size);
if (ret) { if (ret) {
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
...@@ -6466,6 +6468,7 @@ int hclge_set_vport_mtu(struct hclge_vport *vport, int new_mtu) ...@@ -6466,6 +6468,7 @@ int hclge_set_vport_mtu(struct hclge_vport *vport, int new_mtu)
"Allocate buffer fail, ret =%d\n", ret); "Allocate buffer fail, ret =%d\n", ret);
out: out:
hclge_notify_client(hdev, HNAE3_UP_CLIENT);
mutex_unlock(&hdev->vport_lock); mutex_unlock(&hdev->vport_lock);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment