netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2] hinic: add set_channels ethtool_ops support
@ 2020-05-28 18:36 Luo bin
  2020-05-29 17:44 ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Luo bin @ 2020-05-28 18:36 UTC (permalink / raw)
  To: davem
  Cc: linux-kernel, netdev, luoxianjun, luobin9, yin.yinshi, cloud.wangxiaoyun

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

Signed-off-by: Luo bin <luobin9@huawei.com>
---
 .../net/ethernet/huawei/hinic/hinic_ethtool.c | 46 +++++++++++++++----
 .../net/ethernet/huawei/hinic/hinic_main.c    |  2 +-
 drivers/net/ethernet/huawei/hinic/hinic_tx.c  |  5 ++
 3 files changed, 44 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c b/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c
index ace18d258049..9796c1fbe132 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c
@@ -619,14 +619,43 @@ 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_other = 0;
-	channels->max_combined = 0;
-	channels->rx_count = hinic_hwdev_num_qps(hwdev);
-	channels->tx_count = hinic_hwdev_num_qps(hwdev);
-	channels->other_count = 0;
-	channels->combined_count = 0;
+	channels->max_combined = nic_dev->max_qps;
+	channels->combined_count = hinic_hwdev_num_qps(hwdev);
+}
+
+static 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;
+	}
+
+	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);
+
+		nic_dev->hwdev->nic_cap.num_qps = count;
+
+		err = hinic_open(netdev);
+		if (err) {
+			netif_err(nic_dev, drv, netdev,
+				  "Failed to open netdev\n");
+			return -EFAULT;
+		}
+	} else {
+		nic_dev->hwdev->nic_cap.num_qps = count;
+	}
+
+	return 0;
 }
 
 static int hinic_get_rss_hash_opts(struct hinic_dev *nic_dev,
@@ -1219,6 +1248,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,
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_main.c b/drivers/net/ethernet/huawei/hinic/hinic_main.c
index c8ab129a7ae8..e9e6f4c9309a 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_main.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_main.c
@@ -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;
@@ -1031,6 +1030,7 @@ 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;
 
 	sema_init(&nic_dev->mgmt_lock, 1);
 
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_tx.c b/drivers/net/ethernet/huawei/hinic/hinic_tx.c
index 4c66a0bc1b28..6da761d7a6ef 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_tx.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_tx.c
@@ -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);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next v2] hinic: add set_channels ethtool_ops support
  2020-05-28 18:36 [PATCH net-next v2] hinic: add set_channels ethtool_ops support Luo bin
@ 2020-05-29 17:44 ` Jakub Kicinski
  2020-05-30  1:30   ` luobin (L)
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2020-05-29 17:44 UTC (permalink / raw)
  To: Luo bin
  Cc: davem, linux-kernel, netdev, luoxianjun, yin.yinshi, cloud.wangxiaoyun

On Thu, 28 May 2020 18:36:33 +0000 Luo bin wrote:
> add support to change TX/RX queue number with ethtool -L
> 
> Signed-off-by: Luo bin <luobin9@huawei.com>

Luo bin, your patches continue to come with Date: header being in the
past. Also suspiciously no time zone offset. Can you address this?

> +static 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;
> +	}

This check has been added to the core since the last version of you
patch:

	/* ensure there is at least one RX and one TX channel */
	if (!channels.combined_count &&
	    (!channels.rx_count || !channels.tx_count))
		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);
> +
> +		nic_dev->hwdev->nic_cap.num_qps = count;
> +
> +		err = hinic_open(netdev);
> +		if (err) {
> +			netif_err(nic_dev, drv, netdev,
> +				  "Failed to open netdev\n");
> +			return -EFAULT;
> +		}
> +	} else {
> +		nic_dev->hwdev->nic_cap.num_qps = count;
> +	}
> +
> +	return 0;
>  }


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next v2] hinic: add set_channels ethtool_ops support
  2020-05-29 17:44 ` Jakub Kicinski
@ 2020-05-30  1:30   ` luobin (L)
  0 siblings, 0 replies; 3+ messages in thread
From: luobin (L) @ 2020-05-30  1:30 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, linux-kernel, netdev, luoxianjun, yin.yinshi, cloud.wangxiaoyun

On 2020/5/30 1:44, Jakub Kicinski wrote:

> On Thu, 28 May 2020 18:36:33 +0000 Luo bin wrote:
>> add support to change TX/RX queue number with ethtool -L
>>
>> Signed-off-by: Luo bin <luobin9@huawei.com>
> Luo bin, your patches continue to come with Date: header being in the
> past. Also suspiciously no time zone offset. Can you address this?
>
>> +static 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;
>> +	}
> This check has been added to the core since the last version of you
> patch:
>
> 	/* ensure there is at least one RX and one TX channel */
> 	if (!channels.combined_count &&
> 	    (!channels.rx_count || !channels.tx_count))
> 		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);
>> +
>> +		nic_dev->hwdev->nic_cap.num_qps = count;
>> +
>> +		err = hinic_open(netdev);
>> +		if (err) {
>> +			netif_err(nic_dev, drv, netdev,
>> +				  "Failed to open netdev\n");
>> +			return -EFAULT;
>> +		}
>> +	} else {
>> +		nic_dev->hwdev->nic_cap.num_qps = count;
>> +	}
>> +
>> +	return 0;
>>   }
> Will fix. Thanks.
> .

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-30  1:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 18:36 [PATCH net-next v2] hinic: add set_channels ethtool_ops support Luo bin
2020-05-29 17:44 ` Jakub Kicinski
2020-05-30  1:30   ` luobin (L)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).