patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH 20.11 0/2] net/hns3: backport two bugfix
@ 2021-02-20  1:51 Huisong Li
  2021-02-20  1:51 ` [dpdk-stable] [PATCH 20.11 1/2] net/hns3: fix query order of link status and link info Huisong Li
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Huisong Li @ 2021-02-20  1:51 UTC (permalink / raw)
  To: stable, luca.boccassi
  Cc: ferruh.yigit, tangchengchang, humin29, oulijun, huangdaode

Backport following two patches to the 20.11 branch.

Chengchang Tang (1):
  net/hns3: fix stats flip overflow

Huisong Li (1):
  net/hns3: fix query order of link status and link info

 drivers/net/hns3/hns3_ethdev.c | 26 ++++++++++++++++++++------
 drivers/net/hns3/hns3_stats.c  | 14 +++++++++++---
 2 files changed, 31 insertions(+), 9 deletions(-)

-- 
2.8.1


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

* [dpdk-stable] [PATCH 20.11 1/2] net/hns3: fix query order of link status and link info
  2021-02-20  1:51 [dpdk-stable] [PATCH 20.11 0/2] net/hns3: backport two bugfix Huisong Li
@ 2021-02-20  1:51 ` Huisong Li
  2021-02-20  1:51 ` [dpdk-stable] [PATCH 20.11 2/2] net/hns3: fix stats flip overflow Huisong Li
  2021-02-22 11:59 ` [dpdk-stable] [PATCH 20.11 0/2] net/hns3: backport two bugfix Luca Boccassi
  2 siblings, 0 replies; 4+ messages in thread
From: Huisong Li @ 2021-02-20  1:51 UTC (permalink / raw)
  To: stable, luca.boccassi
  Cc: ferruh.yigit, tangchengchang, humin29, oulijun, huangdaode

[ upstream commit 7f2a320df9d237cf23bac07226a3c01faa0288a7 ]

When link information is updated in the firmware, the link information
is updated first and then the link status is updated. In a 1s periodic
task, PF driver queries the link information and then obtains link
status.
It may lead to a 1s time difference for obtaining valid link information
when the port is up. Therefore, the query order of driver should be
reversed to the order of firmware.

Fixes: 109e4dd1bd7a ("net/hns3: get link state change through mailbox")
Fixes: 59fad0f32135 ("net/hns3: support link update operation")

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Lijun Ou <oulijun@huawei.com>
---
 drivers/net/hns3/hns3_ethdev.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 8f0e5a3..ba7d6e3 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -93,7 +93,7 @@ static enum hns3_reset_level hns3_get_reset_level(struct hns3_adapter *hns,
 static int hns3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 static int hns3_vlan_pvid_configure(struct hns3_adapter *hns, uint16_t pvid,
 				    int on);
-static int hns3_update_speed_duplex(struct rte_eth_dev *eth_dev);
+static int hns3_update_link_info(struct rte_eth_dev *eth_dev);
 
 static int hns3_add_mc_addr(struct hns3_hw *hw,
 			    struct rte_ether_addr *mac_addr);
@@ -2624,8 +2624,8 @@ hns3_dev_link_update(struct rte_eth_dev *eth_dev,
 	struct rte_eth_link new_link;
 
 	if (!hns3_is_reset_pending(hns)) {
-		hns3_update_speed_duplex(eth_dev);
 		hns3_update_link_status(hw);
+		hns3_update_link_info(eth_dev);
 	}
 
 	memset(&new_link, 0, sizeof(new_link));
@@ -4384,10 +4384,9 @@ hns3_cfg_mac_speed_dup(struct hns3_hw *hw, uint32_t speed, uint8_t duplex)
 }
 
 static int
-hns3_update_speed_duplex(struct rte_eth_dev *eth_dev)
+hns3_update_fiber_link_info(struct hns3_hw *hw)
 {
-	struct hns3_adapter *hns = eth_dev->data->dev_private;
-	struct hns3_hw *hw = &hns->hw;
+	struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
 	struct hns3_pf *pf = &hns->pf;
 	uint32_t speed;
 	int ret;
@@ -4411,6 +4410,21 @@ hns3_update_speed_duplex(struct rte_eth_dev *eth_dev)
 }
 
 static int
+hns3_update_link_info(struct rte_eth_dev *eth_dev)
+{
+	struct hns3_adapter *hns = eth_dev->data->dev_private;
+	struct hns3_hw *hw = &hns->hw;
+	int ret = 0;
+
+	if (hw->mac.media_type == HNS3_MEDIA_TYPE_COPPER)
+		return 0;
+	else if (hw->mac.media_type == HNS3_MEDIA_TYPE_FIBER)
+		ret = hns3_update_fiber_link_info(hw);
+
+	return ret;
+}
+
+static int
 hns3_cfg_mac_mode(struct hns3_hw *hw, bool enable)
 {
 	struct hns3_config_mac_mode_cmd *req;
@@ -4496,8 +4510,8 @@ hns3_service_handler(void *param)
 	struct hns3_hw *hw = &hns->hw;
 
 	if (!hns3_is_reset_pending(hns)) {
-		hns3_update_speed_duplex(eth_dev);
 		hns3_update_link_status(hw);
+		hns3_update_link_info(eth_dev);
 	} else
 		hns3_warn(hw, "Cancel the query when reset is pending");
 
-- 
2.8.1


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

* [dpdk-stable] [PATCH 20.11 2/2] net/hns3: fix stats flip overflow
  2021-02-20  1:51 [dpdk-stable] [PATCH 20.11 0/2] net/hns3: backport two bugfix Huisong Li
  2021-02-20  1:51 ` [dpdk-stable] [PATCH 20.11 1/2] net/hns3: fix query order of link status and link info Huisong Li
@ 2021-02-20  1:51 ` Huisong Li
  2021-02-22 11:59 ` [dpdk-stable] [PATCH 20.11 0/2] net/hns3: backport two bugfix Luca Boccassi
  2 siblings, 0 replies; 4+ messages in thread
From: Huisong Li @ 2021-02-20  1:51 UTC (permalink / raw)
  To: stable, luca.boccassi
  Cc: ferruh.yigit, tangchengchang, humin29, oulijun, huangdaode

From: Chengchang Tang <tangchengchang@huawei.com>

[ upstream commit c27e64ee3e9b4ae6c763a4f00f72927e80e2e5f2 ]

Currently, statistics may overflow in some scenarios.

For example, if HW statistics are reset by stats reset operation,
but there are still a lot of residual packets exist in the HW
queues and these packets are error packets, flip may occurred
because the ipacket is obtained by subtracting the number of
software error packets from the number of HW received packets.

This patch verifies the calculation and returns 0 when overflow
may occur.

Fixes: 8839c5e202f3 ("net/hns3: support device stats")

Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Lijun Ou <oulijun@huawei.com>
---
 drivers/net/hns3/hns3_stats.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c
index 62a712b..48ab6a3 100644
--- a/drivers/net/hns3/hns3_stats.c
+++ b/drivers/net/hns3/hns3_stats.c
@@ -521,8 +521,15 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats)
 		if (rxq) {
 			cnt = rxq->l2_errors + rxq->pkt_len_errors;
 			rte_stats->q_errors[i] = cnt;
+			/*
+			 * If HW statistics are reset by stats_reset, but
+			 * a lot of residual packets exist in the hardware
+			 * queue and these packets are error packets, flip
+			 * overflow may occurred. So return 0 in this case.
+			 */
 			rte_stats->q_ipackets[i] =
-				stats->rcb_rx_ring_pktnum[i] - cnt;
+				stats->rcb_rx_ring_pktnum[i] > cnt ?
+				stats->rcb_rx_ring_pktnum[i] - cnt : 0;
 			rte_stats->ierrors += cnt;
 		}
 	}
@@ -535,8 +542,9 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats)
 	}
 
 	rte_stats->oerrors = 0;
-	rte_stats->ipackets  = stats->rcb_rx_ring_pktnum_rcd -
-		rte_stats->ierrors;
+	rte_stats->ipackets =
+		stats->rcb_rx_ring_pktnum_rcd > rte_stats->ierrors ?
+		stats->rcb_rx_ring_pktnum_rcd - rte_stats->ierrors : 0;
 	rte_stats->opackets  = stats->rcb_tx_ring_pktnum_rcd -
 		rte_stats->oerrors;
 	rte_stats->rx_nombuf = eth_dev->data->rx_mbuf_alloc_failed;
-- 
2.8.1


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

* Re: [dpdk-stable] [PATCH 20.11 0/2] net/hns3: backport two bugfix
  2021-02-20  1:51 [dpdk-stable] [PATCH 20.11 0/2] net/hns3: backport two bugfix Huisong Li
  2021-02-20  1:51 ` [dpdk-stable] [PATCH 20.11 1/2] net/hns3: fix query order of link status and link info Huisong Li
  2021-02-20  1:51 ` [dpdk-stable] [PATCH 20.11 2/2] net/hns3: fix stats flip overflow Huisong Li
@ 2021-02-22 11:59 ` Luca Boccassi
  2 siblings, 0 replies; 4+ messages in thread
From: Luca Boccassi @ 2021-02-22 11:59 UTC (permalink / raw)
  To: Huisong Li, stable; +Cc: tangchengchang, humin29, oulijun, huangdaode

On Sat, 2021-02-20 at 09:51 +0800, Huisong Li wrote:
> Backport following two patches to the 20.11 branch.
> 
> Chengchang Tang (1):
>   net/hns3: fix stats flip overflow
> 
> Huisong Li (1):
>   net/hns3: fix query order of link status and link info
> 
>  drivers/net/hns3/hns3_ethdev.c | 26 ++++++++++++++++++++------
>  drivers/net/hns3/hns3_stats.c  | 14 +++++++++++---
>  2 files changed, 31 insertions(+), 9 deletions(-)

Thank you, applied and pushed.

-- 
Kind regards,
Luca Boccassi

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

end of thread, other threads:[~2021-02-22 11:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-20  1:51 [dpdk-stable] [PATCH 20.11 0/2] net/hns3: backport two bugfix Huisong Li
2021-02-20  1:51 ` [dpdk-stable] [PATCH 20.11 1/2] net/hns3: fix query order of link status and link info Huisong Li
2021-02-20  1:51 ` [dpdk-stable] [PATCH 20.11 2/2] net/hns3: fix stats flip overflow Huisong Li
2021-02-22 11:59 ` [dpdk-stable] [PATCH 20.11 0/2] net/hns3: backport two bugfix Luca Boccassi

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git