All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/7] net: hns3: bug fixes & code improvements
@ 2017-10-23 11:51 Lipeng
  2017-10-23 11:51 ` [PATCH net-next 1/7] net: hns3: fix a bug when alloc new buffer Lipeng
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Lipeng @ 2017-10-23 11:51 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-kernel, linuxarm, yisen.zhuang, salil.mehta, lipeng321

This patchset introduces various HNS3 bug fixes, optimizations and code
improvements.

Lipeng (7):
  net: hns3: fix a bug when alloc new buffer
  net: hns3: fix the bug when map buffer fail
  net: hns3: fix the ops check in hns3_get_rxnfc
  net: hns3: get vf count by pci_sriov_get_totalvfs
  net: hns3: fix the TX/RX ring.queue_index in hns3_ring_get_cfg
  net: hns3: remove redundant memset when alloc buffer
  net: hns3: fix a bug about hns3_clean_tx_ring

 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c  |  3 ++-
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c   | 16 +++++++---------
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.h   |  2 +-
 .../net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c    |  2 +-
 4 files changed, 11 insertions(+), 12 deletions(-)

-- 
1.9.1

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

* [PATCH net-next 1/7] net: hns3: fix a bug when alloc new buffer
  2017-10-23 11:51 [PATCH net-next 0/7] net: hns3: bug fixes & code improvements Lipeng
@ 2017-10-23 11:51 ` Lipeng
  2017-10-23 11:51 ` [PATCH net-next 2/7] net: hns3: fix the bug when map buffer fail Lipeng
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Lipeng @ 2017-10-23 11:51 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-kernel, linuxarm, yisen.zhuang, salil.mehta, lipeng321

When alloce new buffer to HW, should unmap the old buffer first.
This old code map the old buffer but not unmap the old buffer,
this patch fixes it.

Fixes: 76ad4f0 (net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC)

Signed-off-by: Lipeng <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
index 8383d67..3ddcd47 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
@@ -1595,7 +1595,7 @@ static int hns3_alloc_ring_buffers(struct hns3_enet_ring *ring)
 static void hns3_replace_buffer(struct hns3_enet_ring *ring, int i,
 				struct hns3_desc_cb *res_cb)
 {
-	hns3_map_buffer(ring, &ring->desc_cb[i]);
+	hns3_unmap_buffer(ring, &ring->desc_cb[i]);
 	ring->desc_cb[i] = *res_cb;
 	ring->desc[i].addr = cpu_to_le64(ring->desc_cb[i].dma);
 }
-- 
1.9.1

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

* [PATCH net-next 2/7] net: hns3: fix the bug when map buffer fail
  2017-10-23 11:51 [PATCH net-next 0/7] net: hns3: bug fixes & code improvements Lipeng
  2017-10-23 11:51 ` [PATCH net-next 1/7] net: hns3: fix a bug when alloc new buffer Lipeng
@ 2017-10-23 11:51 ` Lipeng
  2017-10-23 11:51 ` [PATCH net-next 3/7] net: hns3: fix the ops check in hns3_get_rxnfc Lipeng
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Lipeng @ 2017-10-23 11:51 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-kernel, linuxarm, yisen.zhuang, salil.mehta, lipeng321

If one buffer had been recieved to stack, driver will alloc a new buffer,
map the buffer to device and replace the old buffer. When map fail, should
only free the new alloced buffer, but not free all buffers in the ring.

Fixes: 76ad4f0 (net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC)

Signed-off-by: Lipeng <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
index 3ddcd47..58aa2dd 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
@@ -1555,7 +1555,7 @@ static int hns3_reserve_buffer_map(struct hns3_enet_ring *ring,
 	return 0;
 
 out_with_buf:
-	hns3_free_buffers(ring);
+	hns3_free_buffer(ring, cb);
 out:
 	return ret;
 }
-- 
1.9.1

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

* [PATCH net-next 3/7] net: hns3: fix the ops check in hns3_get_rxnfc
  2017-10-23 11:51 [PATCH net-next 0/7] net: hns3: bug fixes & code improvements Lipeng
  2017-10-23 11:51 ` [PATCH net-next 1/7] net: hns3: fix a bug when alloc new buffer Lipeng
  2017-10-23 11:51 ` [PATCH net-next 2/7] net: hns3: fix the bug when map buffer fail Lipeng
@ 2017-10-23 11:51 ` Lipeng
  2017-10-23 11:51 ` [PATCH net-next 4/7] net: hns3: get vf count by pci_sriov_get_totalvfs Lipeng
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Lipeng @ 2017-10-23 11:51 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-kernel, linuxarm, yisen.zhuang, salil.mehta, lipeng321

1# patch: 07d2995 net: hns3: add support for ETHTOOL_GRXFH.
2# patch: 5668abd net: hns3: add support for set_ringparam.

1# patch adds ae_algo->ops->get_rss_tuple to hns3_get_rxnfc
and 2# patch delete ae_algo->ops->get_tc_size
from hns3_get_rxnfc.This patch fix the ops check in hns3_get_rxnfc.

Signed-off-by: Lipeng <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
index 6c469e4..5cd163b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
@@ -717,7 +717,7 @@ static int hns3_get_rxnfc(struct net_device *netdev,
 {
 	struct hnae3_handle *h = hns3_get_handle(netdev);
 
-	if (!h->ae_algo || !h->ae_algo->ops || !h->ae_algo->ops->get_tc_size)
+	if (!h->ae_algo || !h->ae_algo->ops || !h->ae_algo->ops->get_rss_tuple)
 		return -EOPNOTSUPP;
 
 	switch (cmd->cmd) {
-- 
1.9.1

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

* [PATCH net-next 4/7] net: hns3: get vf count by pci_sriov_get_totalvfs
  2017-10-23 11:51 [PATCH net-next 0/7] net: hns3: bug fixes & code improvements Lipeng
                   ` (2 preceding siblings ...)
  2017-10-23 11:51 ` [PATCH net-next 3/7] net: hns3: fix the ops check in hns3_get_rxnfc Lipeng
@ 2017-10-23 11:51 ` Lipeng
  2017-10-23 11:51 ` [PATCH net-next 5/7] net: hns3: fix the TX/RX ring.queue_index in hns3_ring_get_cfg Lipeng
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Lipeng @ 2017-10-23 11:51 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-kernel, linuxarm, yisen.zhuang, salil.mehta, lipeng321

This patch gets vf count by standard function pci_sriov_get_totalvfs,
instead of info from NIC HW.

Signed-off-by: Lipeng <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 8508521..4431241 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -837,7 +837,6 @@ static int hclge_parse_func_status(struct hclge_dev *hdev,
 	else
 		hdev->flag &= ~HCLGE_FLAG_MAIN;
 
-	hdev->num_req_vfs = status->vf_num / status->pf_num;
 	return 0;
 }
 
@@ -4361,6 +4360,8 @@ static int hclge_pci_init(struct hclge_dev *hdev)
 		goto err_clr_master;
 	}
 
+	hdev->num_req_vfs = pci_sriov_get_totalvfs(pdev);
+
 	return 0;
 err_clr_master:
 	pci_clear_master(pdev);
-- 
1.9.1

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

* [PATCH net-next 5/7] net: hns3: fix the TX/RX ring.queue_index in hns3_ring_get_cfg
  2017-10-23 11:51 [PATCH net-next 0/7] net: hns3: bug fixes & code improvements Lipeng
                   ` (3 preceding siblings ...)
  2017-10-23 11:51 ` [PATCH net-next 4/7] net: hns3: get vf count by pci_sriov_get_totalvfs Lipeng
@ 2017-10-23 11:51 ` Lipeng
  2017-10-23 11:51 ` [PATCH net-next 6/7] net: hns3: remove redundant memset when alloc buffer Lipeng
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Lipeng @ 2017-10-23 11:51 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-kernel, linuxarm, yisen.zhuang, salil.mehta, lipeng321

The interface hns3_ring_get_cfg only update TX ring queue_index,
but do not update RX ring queue_index. This patch fixes it.

Fixes: 76ad4f0 (net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC)

Signed-off-by: Lipeng <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
index 58aa2dd..14de0f7 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
@@ -2506,16 +2506,16 @@ static int hns3_ring_get_cfg(struct hnae3_queue *q, struct hns3_nic_priv *priv,
 
 	if (ring_type == HNAE3_RING_TYPE_TX) {
 		ring_data[q->tqp_index].ring = ring;
+		ring_data[q->tqp_index].queue_index = q->tqp_index;
 		ring->io_base = (u8 __iomem *)q->io_base + HNS3_TX_REG_OFFSET;
 	} else {
 		ring_data[q->tqp_index + queue_num].ring = ring;
+		ring_data[q->tqp_index + queue_num].queue_index = q->tqp_index;
 		ring->io_base = q->io_base;
 	}
 
 	hnae_set_bit(ring->flag, HNAE3_RING_TYPE_B, ring_type);
 
-	ring_data[q->tqp_index].queue_index = q->tqp_index;
-
 	ring->tqp = q;
 	ring->desc = NULL;
 	ring->desc_cb = NULL;
-- 
1.9.1

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

* [PATCH net-next 6/7] net: hns3: remove redundant memset when alloc buffer
  2017-10-23 11:51 [PATCH net-next 0/7] net: hns3: bug fixes & code improvements Lipeng
                   ` (4 preceding siblings ...)
  2017-10-23 11:51 ` [PATCH net-next 5/7] net: hns3: fix the TX/RX ring.queue_index in hns3_ring_get_cfg Lipeng
@ 2017-10-23 11:51 ` Lipeng
  2017-10-23 11:51 ` [PATCH net-next 7/7] net: hns3: fix a bug about hns3_clean_tx_ring Lipeng
  2017-10-24  0:17 ` [PATCH net-next 0/7] net: hns3: bug fixes & code improvements David Miller
  7 siblings, 0 replies; 9+ messages in thread
From: Lipeng @ 2017-10-23 11:51 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-kernel, linuxarm, yisen.zhuang, salil.mehta, lipeng321

HW will use packet length to write packets to buffer or read
packets from buffer. There is a redundant memset when alloc buffer,
the memset have no sense and will increase time-consuming.
This patch removes it.

Fixes: 76ad4f0 (net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC)

Signed-off-by: Lipeng <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
index 14de0f7..06af3c8 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
@@ -1444,8 +1444,6 @@ static int hns3_alloc_buffer(struct hns3_enet_ring *ring,
 	cb->length = hnae_page_size(ring);
 	cb->type = DESC_TYPE_PAGE;
 
-	memset(cb->buf, 0, cb->length);
-
 	return 0;
 }
 
-- 
1.9.1

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

* [PATCH net-next 7/7] net: hns3: fix a bug about hns3_clean_tx_ring
  2017-10-23 11:51 [PATCH net-next 0/7] net: hns3: bug fixes & code improvements Lipeng
                   ` (5 preceding siblings ...)
  2017-10-23 11:51 ` [PATCH net-next 6/7] net: hns3: remove redundant memset when alloc buffer Lipeng
@ 2017-10-23 11:51 ` Lipeng
  2017-10-24  0:17 ` [PATCH net-next 0/7] net: hns3: bug fixes & code improvements David Miller
  7 siblings, 0 replies; 9+ messages in thread
From: Lipeng @ 2017-10-23 11:51 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-kernel, linuxarm, yisen.zhuang, salil.mehta, lipeng321

The return value of hns3_clean_tx_ring means tx ring clean result.
Return true means clean complete and there is no more pakcet need
clean. Retrun false means there is packets need clean and napi need
poll again. The last return of hns3_clean_tx_ring is
"return !!budget" as budget will decrease when clean a buffer.

If there is no valid BD in TX ring, return 0 for hns3_clean_tx_ring
will cause napi poll again and never complete the napi poll. This
patch fixes the bug.

Fixes: 76ad4f0 (net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC)

Signed-off-by: Lipeng <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c | 6 +++---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
index 06af3c8..537f6c3 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c
@@ -1629,7 +1629,7 @@ static int is_valid_clean_head(struct hns3_enet_ring *ring, int h)
 	return u > c ? (h > c && h <= u) : (h > c || h <= u);
 }
 
-int hns3_clean_tx_ring(struct hns3_enet_ring *ring, int budget)
+bool hns3_clean_tx_ring(struct hns3_enet_ring *ring, int budget)
 {
 	struct net_device *netdev = ring->tqp->handle->kinfo.netdev;
 	struct netdev_queue *dev_queue;
@@ -1640,7 +1640,7 @@ int hns3_clean_tx_ring(struct hns3_enet_ring *ring, int budget)
 	rmb(); /* Make sure head is ready before touch any data */
 
 	if (is_ring_empty(ring) || head == ring->next_to_clean)
-		return 0; /* no data to poll */
+		return true; /* no data to poll */
 
 	if (!is_valid_clean_head(ring, head)) {
 		netdev_err(netdev, "wrong head (%d, %d-%d)\n", head,
@@ -1649,7 +1649,7 @@ int hns3_clean_tx_ring(struct hns3_enet_ring *ring, int budget)
 		u64_stats_update_begin(&ring->syncp);
 		ring->stats.io_err_cnt++;
 		u64_stats_update_end(&ring->syncp);
-		return -EIO;
+		return true;
 	}
 
 	bytes = 0;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.h
index 6228b26..58dc30b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.h
@@ -594,7 +594,7 @@ static inline void hns3_write_reg(void __iomem *base, u32 reg, u32 value)
 
 void hns3_ethtool_set_ops(struct net_device *netdev);
 
-int hns3_clean_tx_ring(struct hns3_enet_ring *ring, int budget);
+bool hns3_clean_tx_ring(struct hns3_enet_ring *ring, int budget);
 int hns3_init_all_ring(struct hns3_nic_priv *priv);
 int hns3_uninit_all_ring(struct hns3_nic_priv *priv);
 netdev_tx_t hns3_nic_net_xmit(struct sk_buff *skb, struct net_device *netdev);
-- 
1.9.1

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

* Re: [PATCH net-next 0/7] net: hns3: bug fixes & code improvements
  2017-10-23 11:51 [PATCH net-next 0/7] net: hns3: bug fixes & code improvements Lipeng
                   ` (6 preceding siblings ...)
  2017-10-23 11:51 ` [PATCH net-next 7/7] net: hns3: fix a bug about hns3_clean_tx_ring Lipeng
@ 2017-10-24  0:17 ` David Miller
  7 siblings, 0 replies; 9+ messages in thread
From: David Miller @ 2017-10-24  0:17 UTC (permalink / raw)
  To: lipeng321; +Cc: netdev, linux-kernel, linuxarm, yisen.zhuang, salil.mehta

From: Lipeng <lipeng321@huawei.com>
Date: Mon, 23 Oct 2017 19:51:00 +0800

> This patchset introduces various HNS3 bug fixes, optimizations and code
> improvements.

Series applied.

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

end of thread, other threads:[~2017-10-24  0:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-23 11:51 [PATCH net-next 0/7] net: hns3: bug fixes & code improvements Lipeng
2017-10-23 11:51 ` [PATCH net-next 1/7] net: hns3: fix a bug when alloc new buffer Lipeng
2017-10-23 11:51 ` [PATCH net-next 2/7] net: hns3: fix the bug when map buffer fail Lipeng
2017-10-23 11:51 ` [PATCH net-next 3/7] net: hns3: fix the ops check in hns3_get_rxnfc Lipeng
2017-10-23 11:51 ` [PATCH net-next 4/7] net: hns3: get vf count by pci_sriov_get_totalvfs Lipeng
2017-10-23 11:51 ` [PATCH net-next 5/7] net: hns3: fix the TX/RX ring.queue_index in hns3_ring_get_cfg Lipeng
2017-10-23 11:51 ` [PATCH net-next 6/7] net: hns3: remove redundant memset when alloc buffer Lipeng
2017-10-23 11:51 ` [PATCH net-next 7/7] net: hns3: fix a bug about hns3_clean_tx_ring Lipeng
2017-10-24  0:17 ` [PATCH net-next 0/7] net: hns3: bug fixes & code improvements David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.