Skip to contentSkip to conversation

hinic: add set_channels ethtool_ops support

PATCH In review Luo bin 4 participants 6 messages May 15, 2020 – May 16, 2020

Subsystems (3)
lore
Share & tools
lore

Luo bin

author
#0 lore raw

PATCH 1/1 hinic: add set_channels ethtool_ops support

add support to change TX/RX queue number with ethtool -L

---
 .../net/ethernet/huawei/hinic/hinic_ethtool.c | 67 +++++++++++++++++--
 .../net/ethernet/huawei/hinic/hinic_hw_dev.c  |  7 ++
 .../net/ethernet/huawei/hinic/hinic_hw_dev.h  |  2 +
 .../net/ethernet/huawei/hinic/hinic_main.c    |  5 +-
 drivers/net/ethernet/huawei/hinic/hinic_tx.c  |  5 ++
 5 files changed, 79 insertions(+), 7 deletions(-)
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +61 -6
index ace18d258049..92a0e3bd19c3 100644
@@ -619,14 +619,68 @@ static void hinic_get_channels(struct net_device *netdev,
 	struct hinic_dev *nic_dev = netdev_priv(netdev);
 	struct hinic_hwdev *hwdev = nic_dev->hwdev;
 
-	channels->max_rx = hwdev->nic_cap.max_qps;
-	channels->max_tx = hwdev->nic_cap.max_qps;
+	channels->max_rx = 0;
+	channels->max_tx = 0;
 	channels->max_other = 0;
-	channels->max_combined = 0;
-	channels->rx_count = hinic_hwdev_num_qps(hwdev);
-	channels->tx_count = hinic_hwdev_num_qps(hwdev);
+	channels->max_combined = nic_dev->max_qps;
+	channels->rx_count = 0;
+	channels->tx_count = 0;
 	channels->other_count = 0;
-	channels->combined_count = 0;
+	channels->combined_count = hinic_hwdev_num_qps(hwdev);
+}
+
+int hinic_set_channels(struct net_device *netdev,
+		       struct ethtool_channels *channels)
+{
+	struct hinic_dev *nic_dev = netdev_priv(netdev);
+	unsigned int count = channels->combined_count;
+	int err;
+
+	if (!count) {
+		netif_err(nic_dev, drv, netdev,
+			  "Unsupported combined_count: 0\n");
+		return -EINVAL;
+	}
+
+	if (channels->tx_count || channels->rx_count || channels->other_count) {
+		netif_err(nic_dev, drv, netdev,
+			  "Setting rx/tx/other count not supported\n");
+		return -EINVAL;
+	}
+
+	if (!(nic_dev->flags & HINIC_RSS_ENABLE)) {
+		netif_err(nic_dev, drv, netdev,
+			  "This function doesn't support RSS, only support 1 queue pair\n");
+		return -EOPNOTSUPP;
+	}
+
+	if (count > nic_dev->max_qps) {
+		netif_err(nic_dev, drv, netdev,
+			  "Combined count %d exceeds limit %d\n",
+			  count, nic_dev->max_qps);
+		return -EINVAL;
+	}
+
+	netif_info(nic_dev, drv, netdev, "Set max combined queue number from %d to %d\n",
+		   hinic_hwdev_num_qps(nic_dev->hwdev), count);
+
+	if (netif_running(netdev)) {
+		netif_info(nic_dev, drv, netdev, "Restarting netdev\n");
+		hinic_close(netdev);
+
+		hinic_update_num_qps(nic_dev->hwdev, count);
+
+		err = hinic_open(netdev);
+		if (err) {
+			netif_err(nic_dev, drv, netdev,
+				  "Failed to open netdev\n");
+			return -EFAULT;
+		}
+	} else {
+		hinic_update_num_qps(nic_dev->hwdev, count);
+	}
+
+	return 0;
 }
 
 static int hinic_get_rss_hash_opts(struct hinic_dev *nic_dev,
@@ -1219,6 +1273,7 @@ static const struct ethtool_ops hinic_ethtool_ops = {
 	.get_ringparam = hinic_get_ringparam,
 	.set_ringparam = hinic_set_ringparam,
 	.get_channels = hinic_get_channels,
+	.set_channels = hinic_set_channels,
 	.get_rxnfc = hinic_get_rxnfc,
 	.set_rxnfc = hinic_set_rxnfc,
 	.get_rxfh_key_size = hinic_get_rxfh_key_size,
drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c +7 -0
index 0245da02efbb..d40a0a5d2c8d 100644
@@ -858,6 +858,13 @@ int hinic_hwdev_num_qps(struct hinic_hwdev *hwdev)
 	return nic_cap->num_qps;
 }
 
+void hinic_update_num_qps(struct hinic_hwdev *hwdev, u16 num_qp)
+{
+	struct hinic_cap *nic_cap = &hwdev->nic_cap;
+
+	nic_cap->num_qps = num_qp;
+}
+
 /**
  * hinic_hwdev_get_sq - get SQ
  * @hwdev: the NIC HW device
drivers/net/ethernet/huawei/hinic/hinic_hw_dev.h +2 -0
index 71ea7e46dbbc..e7dfe5ae2f8b 100644
@@ -359,6 +359,8 @@ int hinic_hwdev_max_num_qps(struct hinic_hwdev *hwdev);
 
 int hinic_hwdev_num_qps(struct hinic_hwdev *hwdev);
 
+void hinic_update_num_qps(struct hinic_hwdev *hwdev, u16 num_qp);
+
 struct hinic_sq *hinic_hwdev_get_sq(struct hinic_hwdev *hwdev, int i);
 
 struct hinic_rq *hinic_hwdev_get_rq(struct hinic_hwdev *hwdev, int i);
drivers/net/ethernet/huawei/hinic/hinic_main.c +4 -1
index e3ff119fe341..5a130c982a02 100644
@@ -326,7 +326,6 @@ static void hinic_enable_rss(struct hinic_dev *nic_dev)
 	int i, node, err = 0;
 	u16 num_cpus = 0;
 
-	nic_dev->max_qps = hinic_hwdev_max_num_qps(hwdev);
 	if (nic_dev->max_qps <= 1) {
 		nic_dev->flags &= ~HINIC_RSS_ENABLE;
 		nic_dev->rss_limit = nic_dev->max_qps;
@@ -1043,6 +1042,10 @@ static int nic_dev_init(struct pci_dev *pdev)
 	nic_dev->rq_depth = HINIC_RQ_DEPTH;
 	nic_dev->sriov_info.hwdev = hwdev;
 	nic_dev->sriov_info.pdev = pdev;
+	nic_dev->max_qps = num_qps;
+
+	if (nic_dev->max_qps > 1)
+		nic_dev->flags |= HINIC_RSS_ENABLE;
 
 	sema_init(&nic_dev->mgmt_lock, 1);
 
drivers/net/ethernet/huawei/hinic/hinic_tx.c +5 -0
index 4c66a0bc1b28..6da761d7a6ef 100644
@@ -470,6 +470,11 @@ netdev_tx_t hinic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 	struct hinic_txq *txq;
 	struct hinic_qp *qp;
 
+	if (unlikely(!netif_carrier_ok(netdev))) {
+		dev_kfree_skb_any(skb);
+		return NETDEV_TX_OK;
+	}
+
 	txq = &nic_dev->txqs[q_id];
 	qp = container_of(txq->sq, struct hinic_qp, sq);
 
Signature · 1 line
2.17.1
maintainer
#1 lore raw

From: Luo bin <[email protected]>
Date: Fri, 15 May 2020 00:35:47 +0000

drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c int hinic_hwdev_num_qps(struct hinic_hwdev *hwdev) · line 866

Quoted 6 lines
drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c +6 -0
+void hinic_update_num_qps(struct hinic_hwdev *hwdev, u16 num_qp)
+{
+	struct hinic_cap *nic_cap = &hwdev->nic_cap;
+
+	nic_cap->num_qps = num_qp;
+}

It is excessive to have a helper function that assigns a single struct member, the layout of which is visible to all callers. All callers are also in a single function.

Please remove this helper and just go "hwdev->nic_cap.num_qps = xxx;" at the call sites.

Thank you.

maintainer
#2 lore raw
In reply to Luo bin
Quoted 16 lines · On Fri, 15 May 2020 00:35:47 +0000 Luo bin wrote:

add support to change TX/RX queue number with ethtool -L

---
 .../net/ethernet/huawei/hinic/hinic_ethtool.c | 67 +++++++++++++++++--
 .../net/ethernet/huawei/hinic/hinic_hw_dev.c  |  7 ++
 .../net/ethernet/huawei/hinic/hinic_hw_dev.h  |  2 +
 .../net/ethernet/huawei/hinic/hinic_main.c    |  5 +-
 drivers/net/ethernet/huawei/hinic/hinic_tx.c  |  5 ++
 5 files changed, 79 insertions(+), 7 deletions(-)
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +0 -0
index ace18d258049..92a0e3bd19c3 100644

drivers/net/ethernet/huawei/hinic/hinic_ethtool.c static void hinic_get_channels(struct net_device *netdev, · line 623

Quoted 7 lines
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +2 -2
@@ -619,14 +619,68 @@ static void hinic_get_channels(struct net_device *netdev,
 	struct hinic_dev *nic_dev = netdev_priv(netdev);
 	struct hinic_hwdev *hwdev = nic_dev->hwdev;
 
-	channels->max_rx = hwdev->nic_cap.max_qps;
-	channels->max_tx = hwdev->nic_cap.max_qps;
+	channels->max_rx = 0;
+	channels->max_tx = 0;

No need to set members to zero, core passes in a zero-initialized structure.

Quoted 4 lines
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +0 -3
 	channels->max_other = 0;
-	channels->max_combined = 0;
-	channels->rx_count = hinic_hwdev_num_qps(hwdev);
-	channels->tx_count = hinic_hwdev_num_qps(hwdev);

drivers/net/ethernet/huawei/hinic/hinic_ethtool.c static void hinic_get_channels(struct net_device *netdev, · line 633

Quoted 10 lines
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +8 -1
+	channels->max_combined = nic_dev->max_qps;
+	channels->rx_count = 0;
+	channels->tx_count = 0;
 	channels->other_count = 0;
-	channels->combined_count = 0;
+	channels->combined_count = hinic_hwdev_num_qps(hwdev);
+}
+
+int hinic_set_channels(struct net_device *netdev,
+		       struct ethtool_channels *channels)

I haven't actually built this, but - static?

Quoted 6 lines
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +6 -0
+{
+	struct hinic_dev *nic_dev = netdev_priv(netdev);
+	unsigned int count = channels->combined_count;
+	int err;
+
+	if (!count) {

drivers/net/ethernet/huawei/hinic/hinic_ethtool.c static void hinic_get_channels(struct net_device *netdev, · line 649

Quoted 10 lines
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +10 -0
+		netif_err(nic_dev, drv, netdev,
+			  "Unsupported combined_count: 0\n");
+		return -EINVAL;
+	}
+
+	if (channels->tx_count || channels->rx_count || channels->other_count) {
+		netif_err(nic_dev, drv, netdev,
+			  "Setting rx/tx/other count not supported\n");
+		return -EINVAL;
+	}

Core already checks this:

	if (channels.rx_count > curr.max_rx ||
	    channels.tx_count > curr.max_tx ||
	    channels.combined_count > curr.max_combined ||
	    channels.other_count > curr.max_other)
		return -EINVAL;

drivers/net/ethernet/huawei/hinic/hinic_ethtool.c static void hinic_get_channels(struct net_device *netdev, · line 657

Quoted 7 lines
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +7 -0
+	if (!(nic_dev->flags & HINIC_RSS_ENABLE)) {
+		netif_err(nic_dev, drv, netdev,
+			  "This function doesn't support RSS, only support 1 queue pair\n");
+		return -EOPNOTSUPP;
+	}
+
+	if (count > nic_dev->max_qps) {

same here

Quoted 96 lines
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +27 -0
+		netif_err(nic_dev, drv, netdev,
+			  "Combined count %d exceeds limit %d\n",
+			  count, nic_dev->max_qps);
+		return -EINVAL;
+	}
+
+	netif_info(nic_dev, drv, netdev, "Set max combined queue number from %d to %d\n",
+		   hinic_hwdev_num_qps(nic_dev->hwdev), count);
+
+	if (netif_running(netdev)) {
+		netif_info(nic_dev, drv, netdev, "Restarting netdev\n");
+		hinic_close(netdev);
+
+		hinic_update_num_qps(nic_dev->hwdev, count);
+
+		err = hinic_open(netdev);
+		if (err) {
+			netif_err(nic_dev, drv, netdev,
+				  "Failed to open netdev\n");
+			return -EFAULT;
+		}
+	} else {
+		hinic_update_num_qps(nic_dev->hwdev, count);
+	}
+
+	return 0;
 }
 
 static int hinic_get_rss_hash_opts(struct hinic_dev *nic_dev,
@@ -1219,6 +1273,7 @@ static const struct ethtool_ops hinic_ethtool_ops = {
 	.get_ringparam = hinic_get_ringparam,
 	.set_ringparam = hinic_set_ringparam,
 	.get_channels = hinic_get_channels,
+	.set_channels = hinic_set_channels,
 	.get_rxnfc = hinic_get_rxnfc,
 	.set_rxnfc = hinic_set_rxnfc,
 	.get_rxfh_key_size = hinic_get_rxfh_key_size,
drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c +7 -0
index 0245da02efbb..d40a0a5d2c8d 100644
@@ -858,6 +858,13 @@ int hinic_hwdev_num_qps(struct hinic_hwdev *hwdev)
 	return nic_cap->num_qps;
 }
 
+void hinic_update_num_qps(struct hinic_hwdev *hwdev, u16 num_qp)
+{
+	struct hinic_cap *nic_cap = &hwdev->nic_cap;
+
+	nic_cap->num_qps = num_qp;
+}
+
 /**
  * hinic_hwdev_get_sq - get SQ
  * @hwdev: the NIC HW device
drivers/net/ethernet/huawei/hinic/hinic_hw_dev.h +2 -0
index 71ea7e46dbbc..e7dfe5ae2f8b 100644
@@ -359,6 +359,8 @@ int hinic_hwdev_max_num_qps(struct hinic_hwdev *hwdev);
 
 int hinic_hwdev_num_qps(struct hinic_hwdev *hwdev);
 
+void hinic_update_num_qps(struct hinic_hwdev *hwdev, u16 num_qp);
+
 struct hinic_sq *hinic_hwdev_get_sq(struct hinic_hwdev *hwdev, int i);
 
 struct hinic_rq *hinic_hwdev_get_rq(struct hinic_hwdev *hwdev, int i);
drivers/net/ethernet/huawei/hinic/hinic_main.c +4 -1
index e3ff119fe341..5a130c982a02 100644
@@ -326,7 +326,6 @@ static void hinic_enable_rss(struct hinic_dev *nic_dev)
 	int i, node, err = 0;
 	u16 num_cpus = 0;
 
-	nic_dev->max_qps = hinic_hwdev_max_num_qps(hwdev);
 	if (nic_dev->max_qps <= 1) {
 		nic_dev->flags &= ~HINIC_RSS_ENABLE;
 		nic_dev->rss_limit = nic_dev->max_qps;
@@ -1043,6 +1042,10 @@ static int nic_dev_init(struct pci_dev *pdev)
 	nic_dev->rq_depth = HINIC_RQ_DEPTH;
 	nic_dev->sriov_info.hwdev = hwdev;
 	nic_dev->sriov_info.pdev = pdev;
+	nic_dev->max_qps = num_qps;
+
+	if (nic_dev->max_qps > 1)
+		nic_dev->flags |= HINIC_RSS_ENABLE;
 
 	sema_init(&nic_dev->mgmt_lock, 1);
 
drivers/net/ethernet/huawei/hinic/hinic_tx.c +0 -0
index 4c66a0bc1b28..6da761d7a6ef 100644

drivers/net/ethernet/huawei/hinic/hinic_tx.c netdev_tx_t hinic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) · line 476

Quoted 7 lines
drivers/net/ethernet/huawei/hinic/hinic_tx.c +4 -0
@@ -470,6 +470,11 @@ netdev_tx_t hinic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 	struct hinic_txq *txq;
 	struct hinic_qp *qp;
 
+	if (unlikely(!netif_carrier_ok(netdev))) {
+		dev_kfree_skb_any(skb);
+		return NETDEV_TX_OK;
+	}

Why do you need this? How is it supposed to be synchronized in the first place, the link can go down two instructions after you do the check.

Quoted 3 lines
drivers/net/ethernet/huawei/hinic/hinic_tx.c +0 -0
 	txq = &nic_dev->txqs[q_id];
 	qp = container_of(txq->sq, struct hinic_qp, sq);
 
#3 lore raw
In reply to Luo bin
Quoted 43 lines · Luo bin

add support to change TX/RX queue number with ethtool -L

---
 .../net/ethernet/huawei/hinic/hinic_ethtool.c | 67 +++++++++++++++++--
 .../net/ethernet/huawei/hinic/hinic_hw_dev.c  |  7 ++
 .../net/ethernet/huawei/hinic/hinic_hw_dev.h  |  2 +
 .../net/ethernet/huawei/hinic/hinic_main.c    |  5 +-
 drivers/net/ethernet/huawei/hinic/hinic_tx.c  |  5 ++
 5 files changed, 79 insertions(+), 7 deletions(-)
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +16 -6
index ace18d258049..92a0e3bd19c3 100644
@@ -619,14 +619,68 @@ static void hinic_get_channels(struct net_device *netdev,
 	struct hinic_dev *nic_dev = netdev_priv(netdev);
 	struct hinic_hwdev *hwdev = nic_dev->hwdev;
 
-	channels->max_rx = hwdev->nic_cap.max_qps;
-	channels->max_tx = hwdev->nic_cap.max_qps;
+	channels->max_rx = 0;
+	channels->max_tx = 0;
 	channels->max_other = 0;
-	channels->max_combined = 0;
-	channels->rx_count = hinic_hwdev_num_qps(hwdev);
-	channels->tx_count = hinic_hwdev_num_qps(hwdev);
+	channels->max_combined = nic_dev->max_qps;
+	channels->rx_count = 0;
+	channels->tx_count = 0;
 	channels->other_count = 0;
-	channels->combined_count = 0;
+	channels->combined_count = hinic_hwdev_num_qps(hwdev);
+}
+
+int hinic_set_channels(struct net_device *netdev,
+		       struct ethtool_channels *channels)
+{
+	struct hinic_dev *nic_dev = netdev_priv(netdev);
+	unsigned int count = channels->combined_count;
+	int err;
+
+	if (!count) {

drivers/net/ethernet/huawei/hinic/hinic_ethtool.c static void hinic_get_channels(struct net_device *netdev, · line 649

Quoted 10 lines
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +10 -0
+		netif_err(nic_dev, drv, netdev,
+			  "Unsupported combined_count: 0\n");
+		return -EINVAL;
+	}
+
+	if (channels->tx_count || channels->rx_count || channels->other_count) {
+		netif_err(nic_dev, drv, netdev,
+			  "Setting rx/tx/other count not supported\n");
+		return -EINVAL;
+	}

With max_* reported as 0, these will be caught in ethnl_set_channels() or ethtool_set_channels().

drivers/net/ethernet/huawei/hinic/hinic_ethtool.c static void hinic_get_channels(struct net_device *netdev, · line 655

Quoted 5 lines
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +5 -0
+	if (!(nic_dev->flags & HINIC_RSS_ENABLE)) {
+		netif_err(nic_dev, drv, netdev,
+			  "This function doesn't support RSS, only support 1 queue pair\n");
+		return -EOPNOTSUPP;
+	}

I'm not sure if the request should fail even if requested count is actually 1.

drivers/net/ethernet/huawei/hinic/hinic_ethtool.c static void hinic_get_channels(struct net_device *netdev, · line 662

Quoted 6 lines
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +6 -0
+	if (count > nic_dev->max_qps) {
+		netif_err(nic_dev, drv, netdev,
+			  "Combined count %d exceeds limit %d\n",
+			  count, nic_dev->max_qps);
+		return -EINVAL;
+	}

As above, this check has been already performed in ethnl_set_channels() or ethtool_set_channels().

drivers/net/ethernet/huawei/hinic/hinic_ethtool.c static void hinic_get_channels(struct net_device *netdev, · line 665

Quoted 2 lines
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +2 -0
+	netif_info(nic_dev, drv, netdev, "Set max combined queue number from %d to %d\n",
+		   hinic_hwdev_num_qps(nic_dev->hwdev), count);

We have netlink notifications now, is it necessary to log successful changes?

Michal

#4 lore raw

On Fri, May 15, 2020 at 08:13:30PM +0200, Michal Kubecek wrote:
[...]

Quoted 22 lines
Quoted 8 lines
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +8 -0
+int hinic_set_channels(struct net_device *netdev,
+		       struct ethtool_channels *channels)
+{
+	struct hinic_dev *nic_dev = netdev_priv(netdev);
+	unsigned int count = channels->combined_count;
+	int err;
+
+	if (!count) {

drivers/net/ethernet/huawei/hinic/hinic_ethtool.c static void hinic_get_channels(struct net_device *netdev, · line 649

Quoted 10 lines
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +10 -0
+		netif_err(nic_dev, drv, netdev,
+			  "Unsupported combined_count: 0\n");
+		return -EINVAL;
+	}
+
+	if (channels->tx_count || channels->rx_count || channels->other_count) {
+		netif_err(nic_dev, drv, netdev,
+			  "Setting rx/tx/other count not supported\n");
+		return -EINVAL;
+	}

With max_* reported as 0, these will be caught in ethnl_set_channels() or ethtool_set_channels().

Quoted 8 lines

drivers/net/ethernet/huawei/hinic/hinic_ethtool.c static void hinic_get_channels(struct net_device *netdev, · line 655

Quoted 5 lines
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +5 -0
+	if (!(nic_dev->flags & HINIC_RSS_ENABLE)) {
+		netif_err(nic_dev, drv, netdev,
+			  "This function doesn't support RSS, only support 1 queue pair\n");
+		return -EOPNOTSUPP;
+	}

I'm not sure if the request should fail even if requested count is actually 1.

Thinking about it again, as long as you report max_combined=1 in this case, anything higher than 1 would be rejected by general ethtool code and 0 is rejected by the first check above so that you can in fact only get here for combined_count=1 - and only for ioctl requests as netlink code path won't call the ethtool_ops callback if there is no change.

Michal

author
#5 lore raw
In reply to Michal Kubecek
Quoted 82 lines · Michal Kubecek
Quoted 43 lines · Luo bin

add support to change TX/RX queue number with ethtool -L

---
  .../net/ethernet/huawei/hinic/hinic_ethtool.c | 67 +++++++++++++++++--
  .../net/ethernet/huawei/hinic/hinic_hw_dev.c  |  7 ++
  .../net/ethernet/huawei/hinic/hinic_hw_dev.h  |  2 +
  .../net/ethernet/huawei/hinic/hinic_main.c    |  5 +-
  drivers/net/ethernet/huawei/hinic/hinic_tx.c  |  5 ++
  5 files changed, 79 insertions(+), 7 deletions(-)
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +16 -6
index ace18d258049..92a0e3bd19c3 100644
@@ -619,14 +619,68 @@ static void hinic_get_channels(struct net_device *netdev,
  	struct hinic_dev *nic_dev = netdev_priv(netdev);
  	struct hinic_hwdev *hwdev = nic_dev->hwdev;
 
-	channels->max_rx = hwdev->nic_cap.max_qps;
-	channels->max_tx = hwdev->nic_cap.max_qps;
+	channels->max_rx = 0;
+	channels->max_tx = 0;
  	channels->max_other = 0;
-	channels->max_combined = 0;
-	channels->rx_count = hinic_hwdev_num_qps(hwdev);
-	channels->tx_count = hinic_hwdev_num_qps(hwdev);
+	channels->max_combined = nic_dev->max_qps;
+	channels->rx_count = 0;
+	channels->tx_count = 0;
  	channels->other_count = 0;
-	channels->combined_count = 0;
+	channels->combined_count = hinic_hwdev_num_qps(hwdev);
+}
+
+int hinic_set_channels(struct net_device *netdev,
+		       struct ethtool_channels *channels)
+{
+	struct hinic_dev *nic_dev = netdev_priv(netdev);
+	unsigned int count = channels->combined_count;
+	int err;
+
+	if (!count) {

drivers/net/ethernet/huawei/hinic/hinic_ethtool.c static void hinic_get_channels(struct net_device *netdev, · line 649

Quoted 10 lines
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +10 -0
+		netif_err(nic_dev, drv, netdev,
+			  "Unsupported combined_count: 0\n");
+		return -EINVAL;
+	}
+
+	if (channels->tx_count || channels->rx_count || channels->other_count) {
+		netif_err(nic_dev, drv, netdev,
+			  "Setting rx/tx/other count not supported\n");
+		return -EINVAL;
+	}

With max_* reported as 0, these will be caught in ethnl_set_channels() or ethtool_set_channels().
---Will fix. Thanks

drivers/net/ethernet/huawei/hinic/hinic_ethtool.c static void hinic_get_channels(struct net_device *netdev, · line 655

Quoted 5 lines
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +5 -0
+	if (!(nic_dev->flags & HINIC_RSS_ENABLE)) {
+		netif_err(nic_dev, drv, netdev,
+			  "This function doesn't support RSS, only support 1 queue pair\n");
+		return -EOPNOTSUPP;
+	}

I'm not sure if the request should fail even if requested count is actually 1.

drivers/net/ethernet/huawei/hinic/hinic_ethtool.c static void hinic_get_channels(struct net_device *netdev, · line 662

Quoted 6 lines
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +6 -0
+	if (count > nic_dev->max_qps) {
+		netif_err(nic_dev, drv, netdev,
+			  "Combined count %d exceeds limit %d\n",
+			  count, nic_dev->max_qps);
+		return -EINVAL;
+	}

As above, this check has been already performed in ethnl_set_channels() or ethtool_set_channels().
---Will fix. Thanks

drivers/net/ethernet/huawei/hinic/hinic_ethtool.c static void hinic_get_channels(struct net_device *netdev, · line 665

Quoted 2 lines
drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +2 -0
+	netif_info(nic_dev, drv, netdev, "Set max combined queue number from %d to %d\n",
+		   hinic_hwdev_num_qps(nic_dev->hwdev), count);

We have netlink notifications now, is it necessary to log successful changes?
---I think it contributes to locating defects for developers.

Michal
.