Skip to content

Commit 2eed5a8

Browse files
Luo bindavem330
authored andcommitted
hinic: add set_channels ethtool_ops support
add support to change TX/RX queue number with "ethtool -L combined". V5 -> V6: remove check for carrier in hinic_xmit_frame V4 -> V5: change time zone in patch header V3 -> V4: update date in patch header V2 -> V3: remove check for zero channels->combined_count V1 -> V2: update commit message("ethtool -L" to "ethtool -L combined") V0 -> V1: remove check for channels->tx_count/rx_count/other_count Signed-off-by: Luo bin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9a5a908 commit 2eed5a8

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

drivers/net/ethernet/huawei/hinic/hinic_ethtool.c

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -619,14 +619,37 @@ static void hinic_get_channels(struct net_device *netdev,
619619
struct hinic_dev *nic_dev = netdev_priv(netdev);
620620
struct hinic_hwdev *hwdev = nic_dev->hwdev;
621621

622-
channels->max_rx = hwdev->nic_cap.max_qps;
623-
channels->max_tx = hwdev->nic_cap.max_qps;
624-
channels->max_other = 0;
625-
channels->max_combined = 0;
626-
channels->rx_count = hinic_hwdev_num_qps(hwdev);
627-
channels->tx_count = hinic_hwdev_num_qps(hwdev);
628-
channels->other_count = 0;
629-
channels->combined_count = 0;
622+
channels->max_combined = nic_dev->max_qps;
623+
channels->combined_count = hinic_hwdev_num_qps(hwdev);
624+
}
625+
626+
static int hinic_set_channels(struct net_device *netdev,
627+
struct ethtool_channels *channels)
628+
{
629+
struct hinic_dev *nic_dev = netdev_priv(netdev);
630+
unsigned int count = channels->combined_count;
631+
int err;
632+
633+
netif_info(nic_dev, drv, netdev, "Set max combined queue number from %d to %d\n",
634+
hinic_hwdev_num_qps(nic_dev->hwdev), count);
635+
636+
if (netif_running(netdev)) {
637+
netif_info(nic_dev, drv, netdev, "Restarting netdev\n");
638+
hinic_close(netdev);
639+
640+
nic_dev->hwdev->nic_cap.num_qps = count;
641+
642+
err = hinic_open(netdev);
643+
if (err) {
644+
netif_err(nic_dev, drv, netdev,
645+
"Failed to open netdev\n");
646+
return -EFAULT;
647+
}
648+
} else {
649+
nic_dev->hwdev->nic_cap.num_qps = count;
650+
}
651+
652+
return 0;
630653
}
631654

632655
static int hinic_get_rss_hash_opts(struct hinic_dev *nic_dev,
@@ -1219,6 +1242,7 @@ static const struct ethtool_ops hinic_ethtool_ops = {
12191242
.get_ringparam = hinic_get_ringparam,
12201243
.set_ringparam = hinic_set_ringparam,
12211244
.get_channels = hinic_get_channels,
1245+
.set_channels = hinic_set_channels,
12221246
.get_rxnfc = hinic_get_rxnfc,
12231247
.set_rxnfc = hinic_set_rxnfc,
12241248
.get_rxfh_key_size = hinic_get_rxfh_key_size,

drivers/net/ethernet/huawei/hinic/hinic_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ static void hinic_enable_rss(struct hinic_dev *nic_dev)
326326
int i, node, err = 0;
327327
u16 num_cpus = 0;
328328

329-
nic_dev->max_qps = hinic_hwdev_max_num_qps(hwdev);
330329
if (nic_dev->max_qps <= 1) {
331330
nic_dev->flags &= ~HINIC_RSS_ENABLE;
332331
nic_dev->rss_limit = nic_dev->max_qps;
@@ -1031,6 +1030,7 @@ static int nic_dev_init(struct pci_dev *pdev)
10311030
nic_dev->rq_depth = HINIC_RQ_DEPTH;
10321031
nic_dev->sriov_info.hwdev = hwdev;
10331032
nic_dev->sriov_info.pdev = pdev;
1033+
nic_dev->max_qps = num_qps;
10341034

10351035
sema_init(&nic_dev->mgmt_lock, 1);
10361036

0 commit comments

Comments
 (0)