Commit 3a5a5f06 authored by Peng Li's avatar Peng Li Committed by David S. Miller

net: hns3: revert to old channel when setting new channel num fail

After setting new channel num, it needs free old ring memory and
allocate new ring memory. If there is no enough memory and allocate
new ring memory fail, the ring may initialize fail. To make sure
the network interface can work normally, driver should revert the
channel to the old configuration.
Signed-off-by: default avatarPeng Li <lipeng321@huawei.com>
Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4093d1a2
...@@ -4410,6 +4410,30 @@ static int hns3_reset_notify(struct hnae3_handle *handle, ...@@ -4410,6 +4410,30 @@ static int hns3_reset_notify(struct hnae3_handle *handle,
return ret; return ret;
} }
static int hns3_change_channels(struct hnae3_handle *handle, u32 new_tqp_num,
bool rxfh_configured)
{
int ret;
ret = handle->ae_algo->ops->set_channels(handle, new_tqp_num,
rxfh_configured);
if (ret) {
dev_err(&handle->pdev->dev,
"Change tqp num(%u) fail.\n", new_tqp_num);
return ret;
}
ret = hns3_reset_notify(handle, HNAE3_INIT_CLIENT);
if (ret)
return ret;
ret = hns3_reset_notify(handle, HNAE3_UP_CLIENT);
if (ret)
hns3_reset_notify(handle, HNAE3_UNINIT_CLIENT);
return ret;
}
int hns3_set_channels(struct net_device *netdev, int hns3_set_channels(struct net_device *netdev,
struct ethtool_channels *ch) struct ethtool_channels *ch)
{ {
...@@ -4450,24 +4474,23 @@ int hns3_set_channels(struct net_device *netdev, ...@@ -4450,24 +4474,23 @@ int hns3_set_channels(struct net_device *netdev,
return ret; return ret;
org_tqp_num = h->kinfo.num_tqps; org_tqp_num = h->kinfo.num_tqps;
ret = h->ae_algo->ops->set_channels(h, new_tqp_num, rxfh_configured); ret = hns3_change_channels(h, new_tqp_num, rxfh_configured);
if (ret) { if (ret) {
ret = h->ae_algo->ops->set_channels(h, org_tqp_num, int ret1;
rxfh_configured);
if (ret) { netdev_warn(netdev,
/* If revert to old tqp failed, fatal error occurred */ "Change channels fail, revert to old value\n");
dev_err(&netdev->dev, ret1 = hns3_change_channels(h, org_tqp_num, rxfh_configured);
"Revert to old tqp num fail, ret=%d", ret); if (ret1) {
return ret; netdev_err(netdev,
"revert to old channel fail\n");
return ret1;
} }
dev_info(&netdev->dev,
"Change tqp num fail, Revert to old tqp num");
}
ret = hns3_reset_notify(h, HNAE3_INIT_CLIENT);
if (ret)
return ret; return ret;
}
return hns3_reset_notify(h, HNAE3_UP_CLIENT); return 0;
} }
static const struct hns3_hw_error_info hns3_hw_err[] = { static const struct hns3_hw_error_info hns3_hw_err[] = {
......
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