linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/6]  net: hns3: add some fixes for -net
@ 2021-09-13 13:08 Guangbin Huang
  2021-09-13 13:08 ` [PATCH net 1/6] net: hns3: add option to turn off page pool feature Guangbin Huang
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Guangbin Huang @ 2021-09-13 13:08 UTC (permalink / raw)
  To: davem, kuba; +Cc: netdev, linux-kernel, lipeng321, huangguangbin2

This series adds some fixes for the HNS3 ethernet driver.

Jiaran Zhang (2):
  net: hns3: fix the exception when query imp info
  net: hns3: fix the timing issue of VF clearing interrupt sources

Yufeng Mo (3):
  net: hns3: pad the short tunnel frame before sending to hardware
  net: hns3: change affinity_mask to numa node range
  net: hns3: disable mac in flr process

Yunsheng Lin (1):
  net: hns3: add option to turn off page pool feature

 .../net/ethernet/hisilicon/hns3/hns3_enet.c   | 14 +++++++++++---
 .../hisilicon/hns3/hns3pf/hclge_debugfs.c     |  4 ++++
 .../hisilicon/hns3/hns3pf/hclge_main.c        | 19 +++++++++++--------
 .../hisilicon/hns3/hns3vf/hclgevf_main.c      |  6 +++---
 4 files changed, 29 insertions(+), 14 deletions(-)

-- 
2.33.0


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

* [PATCH net 1/6] net: hns3: add option to turn off page pool feature
  2021-09-13 13:08 [PATCH net 0/6] net: hns3: add some fixes for -net Guangbin Huang
@ 2021-09-13 13:08 ` Guangbin Huang
  2021-09-13 13:08 ` [PATCH net 2/6] net: hns3: pad the short tunnel frame before sending to hardware Guangbin Huang
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Guangbin Huang @ 2021-09-13 13:08 UTC (permalink / raw)
  To: davem, kuba; +Cc: netdev, linux-kernel, lipeng321, huangguangbin2

From: Yunsheng Lin <linyunsheng@huawei.com>

When page pool is added to the hns3 driver, it is always
enabled unconditionally, which means spilt page handling
in the hns3 driver is dead code.

As there is a requirement to test the performance between
spilt page handling in driver and page pool, so add a module
param to support disabling the page pool.

When the page pool is proved to perform better in most case,
the spilt page handling in driver can be removed.

Fixes: 93188e9642c3 ("net: hns3: support skb's frag page recycling based on page pool")
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 22af3d6ce178..293243bbe407 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -61,6 +61,9 @@ static unsigned int tx_sgl = 1;
 module_param(tx_sgl, uint, 0600);
 MODULE_PARM_DESC(tx_sgl, "Minimum number of frags when using dma_map_sg() to optimize the IOMMU mapping");
 
+static bool page_pool_enabled = true;
+module_param(page_pool_enabled, bool, 0400);
+
 #define HNS3_SGL_SIZE(nfrag)	(sizeof(struct scatterlist) * (nfrag) +	\
 				 sizeof(struct sg_table))
 #define HNS3_MAX_SGL_SIZE	ALIGN(HNS3_SGL_SIZE(HNS3_MAX_TSO_BD_NUM), \
@@ -4753,7 +4756,8 @@ static int hns3_alloc_ring_memory(struct hns3_enet_ring *ring)
 		goto out_with_desc_cb;
 
 	if (!HNAE3_IS_TX_RING(ring)) {
-		hns3_alloc_page_pool(ring);
+		if (page_pool_enabled)
+			hns3_alloc_page_pool(ring);
 
 		ret = hns3_alloc_ring_buffers(ring);
 		if (ret)
-- 
2.33.0


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

* [PATCH net 2/6] net: hns3: pad the short tunnel frame before sending to hardware
  2021-09-13 13:08 [PATCH net 0/6] net: hns3: add some fixes for -net Guangbin Huang
  2021-09-13 13:08 ` [PATCH net 1/6] net: hns3: add option to turn off page pool feature Guangbin Huang
@ 2021-09-13 13:08 ` Guangbin Huang
  2021-09-13 13:08 ` [PATCH net 3/6] net: hns3: change affinity_mask to numa node range Guangbin Huang
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Guangbin Huang @ 2021-09-13 13:08 UTC (permalink / raw)
  To: davem, kuba; +Cc: netdev, linux-kernel, lipeng321, huangguangbin2

From: Yufeng Mo <moyufeng@huawei.com>

The hardware cannot handle short tunnel frames below 65 bytes,
and will cause vlan tag missing problem. So pads packet size to
65 bytes for tunnel frames to fix this bug.

Fixes: 3db084d28dc0("net: hns3: Fix for vxlan tx checksum bug")
Signed-off-by: Yufeng Mo <moyufeng@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 293243bbe407..adc54a726661 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -76,6 +76,7 @@ module_param(page_pool_enabled, bool, 0400);
 #define HNS3_OUTER_VLAN_TAG	2
 
 #define HNS3_MIN_TX_LEN		33U
+#define HNS3_MIN_TUN_PKT_LEN	65U
 
 /* hns3_pci_tbl - PCI Device ID Table
  *
@@ -1427,8 +1428,11 @@ static int hns3_set_l2l3l4(struct sk_buff *skb, u8 ol4_proto,
 			       l4.tcp->doff);
 		break;
 	case IPPROTO_UDP:
-		if (hns3_tunnel_csum_bug(skb))
-			return skb_checksum_help(skb);
+		if (hns3_tunnel_csum_bug(skb)) {
+			int ret = skb_put_padto(skb, HNS3_MIN_TUN_PKT_LEN);
+
+			return ret ? ret : skb_checksum_help(skb);
+		}
 
 		hns3_set_field(*type_cs_vlan_tso, HNS3_TXD_L4CS_B, 1);
 		hns3_set_field(*type_cs_vlan_tso, HNS3_TXD_L4T_S,
-- 
2.33.0


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

* [PATCH net 3/6] net: hns3: change affinity_mask to numa node range
  2021-09-13 13:08 [PATCH net 0/6] net: hns3: add some fixes for -net Guangbin Huang
  2021-09-13 13:08 ` [PATCH net 1/6] net: hns3: add option to turn off page pool feature Guangbin Huang
  2021-09-13 13:08 ` [PATCH net 2/6] net: hns3: pad the short tunnel frame before sending to hardware Guangbin Huang
@ 2021-09-13 13:08 ` Guangbin Huang
  2021-09-13 13:08 ` [PATCH net 4/6] net: hns3: disable mac in flr process Guangbin Huang
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Guangbin Huang @ 2021-09-13 13:08 UTC (permalink / raw)
  To: davem, kuba; +Cc: netdev, linux-kernel, lipeng321, huangguangbin2

From: Yufeng Mo <moyufeng@huawei.com>

Currently, affinity_mask is set to a single cpu. As a result,
irqbalance becomes invalid in SUBSET or EXACT mode. To solve
this problem, change affinity_mask to numa node range. In this
way, irqbalance can be performed on the cpu of the numa node.

Fixes: 0812545487ec ("net: hns3: add interrupt affinity support for misc interrupt")
Signed-off-by: Yufeng Mo <moyufeng@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c    | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index e55ba2e511b1..aed97c934bfb 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -1528,9 +1528,10 @@ static void hclge_init_kdump_kernel_config(struct hclge_dev *hdev)
 static int hclge_configure(struct hclge_dev *hdev)
 {
 	struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev);
+	const struct cpumask *cpumask = cpu_online_mask;
 	struct hclge_cfg cfg;
 	unsigned int i;
-	int ret;
+	int node, ret;
 
 	ret = hclge_get_cfg(hdev, &cfg);
 	if (ret)
@@ -1595,11 +1596,12 @@ static int hclge_configure(struct hclge_dev *hdev)
 
 	hclge_init_kdump_kernel_config(hdev);
 
-	/* Set the init affinity based on pci func number */
-	i = cpumask_weight(cpumask_of_node(dev_to_node(&hdev->pdev->dev)));
-	i = i ? PCI_FUNC(hdev->pdev->devfn) % i : 0;
-	cpumask_set_cpu(cpumask_local_spread(i, dev_to_node(&hdev->pdev->dev)),
-			&hdev->affinity_mask);
+	/* Set the affinity based on numa node */
+	node = dev_to_node(&hdev->pdev->dev);
+	if (node != NUMA_NO_NODE)
+		cpumask = cpumask_of_node(node);
+
+	cpumask_copy(&hdev->affinity_mask, cpumask);
 
 	return ret;
 }
-- 
2.33.0


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

* [PATCH net 4/6] net: hns3: disable mac in flr process
  2021-09-13 13:08 [PATCH net 0/6] net: hns3: add some fixes for -net Guangbin Huang
                   ` (2 preceding siblings ...)
  2021-09-13 13:08 ` [PATCH net 3/6] net: hns3: change affinity_mask to numa node range Guangbin Huang
@ 2021-09-13 13:08 ` Guangbin Huang
  2021-09-13 13:08 ` [PATCH net 5/6] net: hns3: fix the exception when query imp info Guangbin Huang
  2021-09-13 13:08 ` [PATCH net 6/6] net: hns3: fix the timing issue of VF clearing interrupt sources Guangbin Huang
  5 siblings, 0 replies; 7+ messages in thread
From: Guangbin Huang @ 2021-09-13 13:08 UTC (permalink / raw)
  To: davem, kuba; +Cc: netdev, linux-kernel, lipeng321, huangguangbin2

From: Yufeng Mo <moyufeng@huawei.com>

The firmware will not disable mac in flr process. Therefore, the driver
needs to proactively disable mac during flr, which is the same as the
function reset.

Fixes: 35d93a30040c ("net: hns3: adjust the process of PF reset")
Signed-off-by: Yufeng Mo <moyufeng@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index aed97c934bfb..f1e46ba799f9 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -8127,11 +8127,12 @@ static void hclge_ae_stop(struct hnae3_handle *handle)
 	hclge_clear_arfs_rules(hdev);
 	spin_unlock_bh(&hdev->fd_rule_lock);
 
-	/* If it is not PF reset, the firmware will disable the MAC,
+	/* If it is not PF reset or FLR, the firmware will disable the MAC,
 	 * so it only need to stop phy here.
 	 */
 	if (test_bit(HCLGE_STATE_RST_HANDLING, &hdev->state) &&
-	    hdev->reset_type != HNAE3_FUNC_RESET) {
+	    hdev->reset_type != HNAE3_FUNC_RESET &&
+	    hdev->reset_type != HNAE3_FLR_RESET) {
 		hclge_mac_stop_phy(hdev);
 		hclge_update_link_status(hdev);
 		return;
-- 
2.33.0


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

* [PATCH net 5/6] net: hns3: fix the exception when query imp info
  2021-09-13 13:08 [PATCH net 0/6] net: hns3: add some fixes for -net Guangbin Huang
                   ` (3 preceding siblings ...)
  2021-09-13 13:08 ` [PATCH net 4/6] net: hns3: disable mac in flr process Guangbin Huang
@ 2021-09-13 13:08 ` Guangbin Huang
  2021-09-13 13:08 ` [PATCH net 6/6] net: hns3: fix the timing issue of VF clearing interrupt sources Guangbin Huang
  5 siblings, 0 replies; 7+ messages in thread
From: Guangbin Huang @ 2021-09-13 13:08 UTC (permalink / raw)
  To: davem, kuba; +Cc: netdev, linux-kernel, lipeng321, huangguangbin2

From: Jiaran Zhang <zhangjiaran@huawei.com>

When the command for querying imp info is issued to the firmware,
if the firmware does not support the command, the returned value
of bd num is 0.
Add protection mechanism before alloc memory to prevent apply for
0-length memory.

Fixes: 0b198b0d80ea ("net: hns3: refactor dump m7 info of debugfs")
Signed-off-by: Jiaran Zhang <zhangjiaran@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
index 68ed1715ac52..87d96f82c318 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c
@@ -1724,6 +1724,10 @@ hclge_dbg_get_imp_stats_info(struct hclge_dev *hdev, char *buf, int len)
 	}
 
 	bd_num = le32_to_cpu(req->bd_num);
+	if (!bd_num) {
+		dev_err(&hdev->pdev->dev, "imp statistics bd number is 0!\n");
+		return -EINVAL;
+	}
 
 	desc_src = kcalloc(bd_num, sizeof(struct hclge_desc), GFP_KERNEL);
 	if (!desc_src)
-- 
2.33.0


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

* [PATCH net 6/6] net: hns3: fix the timing issue of VF clearing interrupt sources
  2021-09-13 13:08 [PATCH net 0/6] net: hns3: add some fixes for -net Guangbin Huang
                   ` (4 preceding siblings ...)
  2021-09-13 13:08 ` [PATCH net 5/6] net: hns3: fix the exception when query imp info Guangbin Huang
@ 2021-09-13 13:08 ` Guangbin Huang
  5 siblings, 0 replies; 7+ messages in thread
From: Guangbin Huang @ 2021-09-13 13:08 UTC (permalink / raw)
  To: davem, kuba; +Cc: netdev, linux-kernel, lipeng321, huangguangbin2

From: Jiaran Zhang <zhangjiaran@huawei.com>

Currently, the VF does not clear the interrupt source immediately after
receiving the interrupt. As a result, if the second interrupt task is
triggered when processing the first interrupt task, clearing the
interrupt source before exiting will clear the interrupt sources of the
two tasks at the same time. As a result, no interrupt is triggered for
the second task. The VF detects the missed message only when the next
interrupt is generated.

Clearing it immediately after executing check_evt_cause ensures that:
1. Even if two interrupt tasks are triggered at the same time, they can
be processed.
2. If the second task is triggered during the processing of the first
task and the interrupt source is not cleared, the interrupt is reported
after vector0 is enabled.

Fixes: b90fcc5bd904 ("net: hns3: add reset handling for VF when doing Core/Global/IMP reset")
Signed-off-by: Jiaran Zhang <zhangjiaran@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
index 82e727020120..a69e892277b3 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
@@ -2465,6 +2465,8 @@ static irqreturn_t hclgevf_misc_irq_handle(int irq, void *data)
 
 	hclgevf_enable_vector(&hdev->misc_vector, false);
 	event_cause = hclgevf_check_evt_cause(hdev, &clearval);
+	if (event_cause != HCLGEVF_VECTOR0_EVENT_OTHER)
+		hclgevf_clear_event_cause(hdev, clearval);
 
 	switch (event_cause) {
 	case HCLGEVF_VECTOR0_EVENT_RST:
@@ -2477,10 +2479,8 @@ static irqreturn_t hclgevf_misc_irq_handle(int irq, void *data)
 		break;
 	}
 
-	if (event_cause != HCLGEVF_VECTOR0_EVENT_OTHER) {
-		hclgevf_clear_event_cause(hdev, clearval);
+	if (event_cause != HCLGEVF_VECTOR0_EVENT_OTHER)
 		hclgevf_enable_vector(&hdev->misc_vector, true);
-	}
 
 	return IRQ_HANDLED;
 }
-- 
2.33.0


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

end of thread, other threads:[~2021-09-13 13:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-13 13:08 [PATCH net 0/6] net: hns3: add some fixes for -net Guangbin Huang
2021-09-13 13:08 ` [PATCH net 1/6] net: hns3: add option to turn off page pool feature Guangbin Huang
2021-09-13 13:08 ` [PATCH net 2/6] net: hns3: pad the short tunnel frame before sending to hardware Guangbin Huang
2021-09-13 13:08 ` [PATCH net 3/6] net: hns3: change affinity_mask to numa node range Guangbin Huang
2021-09-13 13:08 ` [PATCH net 4/6] net: hns3: disable mac in flr process Guangbin Huang
2021-09-13 13:08 ` [PATCH net 5/6] net: hns3: fix the exception when query imp info Guangbin Huang
2021-09-13 13:08 ` [PATCH net 6/6] net: hns3: fix the timing issue of VF clearing interrupt sources Guangbin Huang

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).