Skip to content

Commit 7a242b2

Browse files
Yunsheng Lindavem330
authored andcommitted
net: hns3: fix for coal configuation lost when setting the channel
This patch fixes the coalesce configuation lost problem when setting the channel number by restoring all vectors's coalesce configuation to vector 0's, because all vectors belonging to the same netdev have the same coalesce configuation for now. Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com> Signed-off-by: Peng Li <lipeng321@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 9bc727a commit 7a242b2

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3413,7 +3413,24 @@ static int hns3_reset_notify(struct hnae3_handle *handle,
34133413
return ret;
34143414
}
34153415

3416-
static int hns3_modify_tqp_num(struct net_device *netdev, u16 new_tqp_num)
3416+
static void hns3_restore_coal(struct hns3_nic_priv *priv,
3417+
struct hns3_enet_coalesce *tx,
3418+
struct hns3_enet_coalesce *rx)
3419+
{
3420+
u16 vector_num = priv->vector_num;
3421+
int i;
3422+
3423+
for (i = 0; i < vector_num; i++) {
3424+
memcpy(&priv->tqp_vector[i].tx_group.coal, tx,
3425+
sizeof(struct hns3_enet_coalesce));
3426+
memcpy(&priv->tqp_vector[i].rx_group.coal, rx,
3427+
sizeof(struct hns3_enet_coalesce));
3428+
}
3429+
}
3430+
3431+
static int hns3_modify_tqp_num(struct net_device *netdev, u16 new_tqp_num,
3432+
struct hns3_enet_coalesce *tx,
3433+
struct hns3_enet_coalesce *rx)
34173434
{
34183435
struct hns3_nic_priv *priv = netdev_priv(netdev);
34193436
struct hnae3_handle *h = hns3_get_handle(netdev);
@@ -3431,6 +3448,8 @@ static int hns3_modify_tqp_num(struct net_device *netdev, u16 new_tqp_num)
34313448
if (ret)
34323449
goto err_alloc_vector;
34333450

3451+
hns3_restore_coal(priv, tx, rx);
3452+
34343453
ret = hns3_nic_init_vector_data(priv);
34353454
if (ret)
34363455
goto err_uninit_vector;
@@ -3461,6 +3480,7 @@ int hns3_set_channels(struct net_device *netdev,
34613480
struct hns3_nic_priv *priv = netdev_priv(netdev);
34623481
struct hnae3_handle *h = hns3_get_handle(netdev);
34633482
struct hnae3_knic_private_info *kinfo = &h->kinfo;
3483+
struct hns3_enet_coalesce tx_coal, rx_coal;
34643484
bool if_running = netif_running(netdev);
34653485
u32 new_tqp_num = ch->combined_count;
34663486
u16 org_tqp_num;
@@ -3494,15 +3514,26 @@ int hns3_set_channels(struct net_device *netdev,
34943514
goto open_netdev;
34953515
}
34963516

3517+
/* Changing the tqp num may also change the vector num,
3518+
* ethtool only support setting and querying one coal
3519+
* configuation for now, so save the vector 0' coal
3520+
* configuation here in order to restore it.
3521+
*/
3522+
memcpy(&tx_coal, &priv->tqp_vector[0].tx_group.coal,
3523+
sizeof(struct hns3_enet_coalesce));
3524+
memcpy(&rx_coal, &priv->tqp_vector[0].rx_group.coal,
3525+
sizeof(struct hns3_enet_coalesce));
3526+
34973527
hns3_nic_dealloc_vector_data(priv);
34983528

34993529
hns3_uninit_all_ring(priv);
35003530
hns3_put_ring_config(priv);
35013531

35023532
org_tqp_num = h->kinfo.num_tqps;
3503-
ret = hns3_modify_tqp_num(netdev, new_tqp_num);
3533+
ret = hns3_modify_tqp_num(netdev, new_tqp_num, &tx_coal, &rx_coal);
35043534
if (ret) {
3505-
ret = hns3_modify_tqp_num(netdev, org_tqp_num);
3535+
ret = hns3_modify_tqp_num(netdev, org_tqp_num,
3536+
&tx_coal, &rx_coal);
35063537
if (ret) {
35073538
/* If revert to old tqp failed, fatal error occurred */
35083539
dev_err(&netdev->dev,

0 commit comments

Comments
 (0)