From: Salil Mehta <salil.mehta@huawei.com>
To: dledford@redhat.com
Cc: salil.mehta@huawei.com, xavier.huwei@huawei.com,
oulijun@huawei.com, yisen.zhuang@huawei.com,
mehta.salil.lnk@gmail.com, linux-rdma@vger.kernel.org,
linux-kernel@vger.kernel.org, linuxarm@huawei.com,
lipeng <lipeng321@huawei.com>
Subject: [PATCH for-next 1/8] net: hns: fix port unavailable after hnae_reserve_buffer_map fail
Date: Sat, 10 Sep 2016 05:09:23 +0100 [thread overview]
Message-ID: <20160910040930.25988-2-salil.mehta@huawei.com> (raw)
In-Reply-To: <20160910040930.25988-1-salil.mehta@huawei.com>
From: lipeng <lipeng321@huawei.com>
When hnae_reserve_buffer_map fail, it will break cycle and some
buffer description has no available memory, therefore the port will
be unavailable.
Signed-off-by: Peng Li <lipeng321@huawei.com>
Reviewed-by: Yisen Zhuang <yisen.zhuang@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
drivers/net/ethernet/hisilicon/hns/hns_enet.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index d7e1f8c..32ff270 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -747,6 +747,14 @@ static void hns_nic_rx_up_pro(struct hns_nic_ring_data *ring_data,
ndev->last_rx = jiffies;
}
+static int hns_desc_unused(struct hnae_ring *ring)
+{
+ int ntc = ring->next_to_clean;
+ int ntu = ring->next_to_use;
+
+ return ((ntc >= ntu) ? 0 : ring->desc_num) + ntc - ntu;
+}
+
static int hns_nic_rx_poll_one(struct hns_nic_ring_data *ring_data,
int budget, void *v)
{
@@ -755,17 +763,21 @@ static int hns_nic_rx_poll_one(struct hns_nic_ring_data *ring_data,
int num, bnum, ex_num;
#define RCB_NOF_ALLOC_RX_BUFF_ONCE 16
int recv_pkts, recv_bds, clean_count, err;
+ int unused_count = hns_desc_unused(ring);
num = readl_relaxed(ring->io_base + RCB_REG_FBDNUM);
rmb(); /* make sure num taken effect before the other data is touched */
recv_pkts = 0, recv_bds = 0, clean_count = 0;
+ num -= unused_count;
recv:
while (recv_pkts < budget && recv_bds < num) {
/* reuse or realloc buffers */
- if (clean_count >= RCB_NOF_ALLOC_RX_BUFF_ONCE) {
- hns_nic_alloc_rx_buffers(ring_data, clean_count);
+ if (clean_count + unused_count >= RCB_NOF_ALLOC_RX_BUFF_ONCE) {
+ hns_nic_alloc_rx_buffers(ring_data,
+ clean_count + unused_count);
clean_count = 0;
+ unused_count = hns_desc_unused(ring);
}
/* poll one pkt */
@@ -789,7 +801,7 @@ recv:
/* make all data has been write before submit */
if (recv_pkts < budget) {
ex_num = readl_relaxed(ring->io_base + RCB_REG_FBDNUM);
-
+ ex_num -= unused_count;
if (ex_num > clean_count) {
num += ex_num - clean_count;
rmb(); /*complete read rx ring bd number*/
@@ -799,8 +811,9 @@ recv:
out:
/* make all data has been write before submit */
- if (clean_count > 0)
- hns_nic_alloc_rx_buffers(ring_data, clean_count);
+ if (clean_count + unused_count > 0)
+ hns_nic_alloc_rx_buffers(ring_data,
+ clean_count + unused_count);
return recv_pkts;
}
--
1.9.1
next prev parent reply other threads:[~2016-09-10 4:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-10 4:09 [PATCH for-next 0/8] Bug Fixes and Code Improvement in HNS driver Salil Mehta
2016-09-10 4:09 ` Salil Mehta [this message]
2016-09-10 4:09 ` [PATCH for-next 2/8] net: hns: bug fix about setting coalsecs-usecs to 0 Salil Mehta
2016-09-10 4:09 ` [PATCH for-next 3/8] net: hns: add fini_process for v2 napi process Salil Mehta
[not found] ` <20160910040930.25988-1-salil.mehta-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-09-10 4:09 ` [PATCH for-next 4/8] net: hns: delete repeat read fbd num after while Salil Mehta
2016-09-10 4:09 ` [PATCH for-next 8/8] net: hns: delete redundant broadcast packet filter process Salil Mehta
2016-09-28 14:57 ` [PATCH for-next 0/8] Bug Fixes and Code Improvement in HNS driver Doug Ledford
[not found] ` <57EBDA43.3010708-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-09-28 16:06 ` Salil Mehta
2016-09-29 17:16 ` Salil Mehta
2016-09-10 4:09 ` [PATCH for-next 5/8] net: hns: fix port not available after testing loopback Salil Mehta
2016-09-10 4:09 ` [PATCH for-next 6/8] net: hns: fix the bug of forwarding table Salil Mehta
2016-09-10 4:09 ` [PATCH for-next 7/8] net: hns: bug fix about broadcast/multicast packets Salil Mehta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160910040930.25988-2-salil.mehta@huawei.com \
--to=salil.mehta@huawei.com \
--cc=dledford@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=lipeng321@huawei.com \
--cc=mehta.salil.lnk@gmail.com \
--cc=oulijun@huawei.com \
--cc=xavier.huwei@huawei.com \
--cc=yisen.zhuang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox