patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH 19.11.9 1/3] net/hns3: fix HW buffer size on MTU update
@ 2021-05-22  6:47 Min Hu (Connor)
  2021-05-22  6:47 ` [dpdk-stable] [PATCH 19.11.9 2/3] net/hns3: fix processing Tx offload flags Min Hu (Connor)
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Min Hu (Connor) @ 2021-05-22  6:47 UTC (permalink / raw)
  To: stable; +Cc: christian.ehrhardt

From: Chengchang Tang <tangchengchang@huawei.com>

[ upstream commit 25fb790f7868f8eee96f7f051a834dec01b8a369 ]

After MTU changed, the buffer used to store packets in HW should be
reallocated. And buffer size is allocated based on the maximum frame
size in the PF struct. However, the value of maximum frame size  is
not updated in time when MTU is changed. This would lead to a packet
loss for not enough buffer.

This patch update the maximum frame size before reallocating the HW
buffer. And a rollback operation is added to avoid the side effects
of buffer reallocation failures.

Fixes: 1f5ca0b460cd ("net/hns3: support some device operations")
Fixes: d51867db65c1 ("net/hns3: add initialization")
Cc: stable@dpdk.org

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

diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 3a799ed..952538d 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -2418,21 +2418,35 @@ hns3_set_mac_mtu(struct hns3_hw *hw, uint16_t new_mps)
 static int
 hns3_config_mtu(struct hns3_hw *hw, uint16_t mps)
 {
+	struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
+	uint16_t original_mps = hns->pf.mps;
+	int err;
 	int ret;
 
 	ret = hns3_set_mac_mtu(hw, mps);
 	if (ret) {
-		hns3_err(hw, "Failed to set mtu, ret = %d", ret);
+		hns3_err(hw, "failed to set mtu, ret = %d", ret);
 		return ret;
 	}
 
+	hns->pf.mps = mps;
 	ret = hns3_buffer_alloc(hw);
 	if (ret) {
-		hns3_err(hw, "Failed to allocate buffer, ret = %d", ret);
-		return ret;
+		hns3_err(hw, "failed to allocate buffer, ret = %d", ret);
+		goto rollback;
 	}
 
 	return 0;
+
+rollback:
+	err = hns3_set_mac_mtu(hw, original_mps);
+	if (err) {
+		hns3_err(hw, "fail to rollback MTU, err = %d", err);
+		return ret;
+	}
+	hns->pf.mps = original_mps;
+
+	return ret;
 }
 
 static int
@@ -2465,7 +2479,7 @@ hns3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 			 dev->data->port_id, mtu, ret);
 		return ret;
 	}
-	hns->pf.mps = (uint16_t)frame_size;
+
 	if (is_jumbo_frame)
 		dev->data->dev_conf.rxmode.offloads |=
 						DEV_RX_OFFLOAD_JUMBO_FRAME;
-- 
2.7.4


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

* [dpdk-stable] [PATCH 19.11.9 2/3] net/hns3: fix processing Tx offload flags
  2021-05-22  6:47 [dpdk-stable] [PATCH 19.11.9 1/3] net/hns3: fix HW buffer size on MTU update Min Hu (Connor)
@ 2021-05-22  6:47 ` Min Hu (Connor)
  2021-05-22  6:47 ` [dpdk-stable] [PATCH 19.11.9 3/3] net/hns3: fix handling link update Min Hu (Connor)
  2021-05-31  8:41 ` [dpdk-stable] [PATCH 19.11.9 1/3] net/hns3: fix HW buffer size on MTU update Christian Ehrhardt
  2 siblings, 0 replies; 4+ messages in thread
From: Min Hu (Connor) @ 2021-05-22  6:47 UTC (permalink / raw)
  To: stable; +Cc: christian.ehrhardt

From: Chengchang Tang <tangchengchang@huawei.com>

[ upstream commit a1d0caa92c7fe43cef7a9f6ac4772e0eecd4a011 ]

Currently, if the PKT_TX_TCP_SEG and PKT_TX_TCP_CKSUM offload flags set
in the same time, hns3 PMD can not process the descriptors correctly.

This patch fixes it by adding the processing of this situation.

Fixes: fb6eb9009f41 ("net/hns3: fix Tx checksum with fixed header length")
Cc: stable@dpdk.org

Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_rxtx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index 1deaf4e..7f24edf 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -2222,6 +2222,7 @@ hns3_parse_l4_cksum_params(struct rte_mbuf *m, uint32_t *type_cs_vlan_tso_len)
 	uint32_t tmp;
 	/* Enable L4 checksum offloads */
 	switch (ol_flags & PKT_TX_L4_MASK) {
+	case PKT_TX_TCP_CKSUM | PKT_TX_TCP_SEG:
 	case PKT_TX_TCP_CKSUM:
 		tmp = *type_cs_vlan_tso_len;
 		tmp |= hns3_gen_field_val(HNS3_TXD_L4T_M, HNS3_TXD_L4T_S,
-- 
2.7.4


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

* [dpdk-stable] [PATCH 19.11.9 3/3] net/hns3: fix handling link update
  2021-05-22  6:47 [dpdk-stable] [PATCH 19.11.9 1/3] net/hns3: fix HW buffer size on MTU update Min Hu (Connor)
  2021-05-22  6:47 ` [dpdk-stable] [PATCH 19.11.9 2/3] net/hns3: fix processing Tx offload flags Min Hu (Connor)
@ 2021-05-22  6:47 ` Min Hu (Connor)
  2021-05-31  8:41 ` [dpdk-stable] [PATCH 19.11.9 1/3] net/hns3: fix HW buffer size on MTU update Christian Ehrhardt
  2 siblings, 0 replies; 4+ messages in thread
From: Min Hu (Connor) @ 2021-05-22  6:47 UTC (permalink / raw)
  To: stable; +Cc: christian.ehrhardt

From: Chengwen Feng <fengchengwen@huawei.com>

[ upstream commit fae9b062b01397339c02c88ebee11dd5f7af3e3c ]

The link fails code should be parsed using the structure
hns3_mbx_vf_to_pf_cmd, else it will parse fail.

Fixes: 109e4dd1bd7a ("net/hns3: get link state change through mailbox")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_mbx.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c
index 896ad25..d44a4d1 100644
--- a/drivers/net/hns3/hns3_mbx.c
+++ b/drivers/net/hns3/hns3_mbx.c
@@ -315,8 +315,8 @@ hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code)
 }
 
 static void
-hns3_handle_link_change_event(struct hns3_hw *hw,
-			      struct hns3_mbx_pf_to_vf_cmd *req)
+hns3pf_handle_link_change_event(struct hns3_hw *hw,
+				struct hns3_mbx_vf_to_pf_cmd *req)
 {
 #define LINK_STATUS_OFFSET     1
 #define LINK_FAIL_CODE_OFFSET  2
@@ -455,7 +455,14 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw)
 			hns3_mbx_handler(hw);
 			break;
 		case HNS3_MBX_PUSH_LINK_STATUS:
-			hns3_handle_link_change_event(hw, req);
+			/*
+			 * This message is reported by the firmware and is
+			 * reported in 'struct hns3_mbx_vf_to_pf_cmd' format.
+			 * Therefore, we should cast the req variable to
+			 * 'struct hns3_mbx_vf_to_pf_cmd' and then process it.
+			 */
+			hns3pf_handle_link_change_event(hw,
+				(struct hns3_mbx_vf_to_pf_cmd *)req);
 			break;
 		default:
 			hns3_err(hw, "received unsupported(%d) mbx msg",
-- 
2.7.4


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

* Re: [dpdk-stable] [PATCH 19.11.9 1/3] net/hns3: fix HW buffer size on MTU update
  2021-05-22  6:47 [dpdk-stable] [PATCH 19.11.9 1/3] net/hns3: fix HW buffer size on MTU update Min Hu (Connor)
  2021-05-22  6:47 ` [dpdk-stable] [PATCH 19.11.9 2/3] net/hns3: fix processing Tx offload flags Min Hu (Connor)
  2021-05-22  6:47 ` [dpdk-stable] [PATCH 19.11.9 3/3] net/hns3: fix handling link update Min Hu (Connor)
@ 2021-05-31  8:41 ` Christian Ehrhardt
  2 siblings, 0 replies; 4+ messages in thread
From: Christian Ehrhardt @ 2021-05-31  8:41 UTC (permalink / raw)
  To: Min Hu (Connor); +Cc: dpdk stable

On Sat, May 22, 2021 at 8:47 AM Min Hu (Connor) <humin29@huawei.com> wrote:
>
> From: Chengchang Tang <tangchengchang@huawei.com>
>
> [ upstream commit 25fb790f7868f8eee96f7f051a834dec01b8a369 ]

Thank you for the backports, queued patches 1-3 for 19.11.9 now

> After MTU changed, the buffer used to store packets in HW should be
> reallocated. And buffer size is allocated based on the maximum frame
> size in the PF struct. However, the value of maximum frame size  is
> not updated in time when MTU is changed. This would lead to a packet
> loss for not enough buffer.
>
> This patch update the maximum frame size before reallocating the HW
> buffer. And a rollback operation is added to avoid the side effects
> of buffer reallocation failures.
>
> Fixes: 1f5ca0b460cd ("net/hns3: support some device operations")
> Fixes: d51867db65c1 ("net/hns3: add initialization")
> Cc: stable@dpdk.org
>
> Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
> Signed-off-by: Lijun Ou <oulijun@huawei.com>
> ---
>  drivers/net/hns3/hns3_ethdev.c | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
> index 3a799ed..952538d 100644
> --- a/drivers/net/hns3/hns3_ethdev.c
> +++ b/drivers/net/hns3/hns3_ethdev.c
> @@ -2418,21 +2418,35 @@ hns3_set_mac_mtu(struct hns3_hw *hw, uint16_t new_mps)
>  static int
>  hns3_config_mtu(struct hns3_hw *hw, uint16_t mps)
>  {
> +       struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
> +       uint16_t original_mps = hns->pf.mps;
> +       int err;
>         int ret;
>
>         ret = hns3_set_mac_mtu(hw, mps);
>         if (ret) {
> -               hns3_err(hw, "Failed to set mtu, ret = %d", ret);
> +               hns3_err(hw, "failed to set mtu, ret = %d", ret);
>                 return ret;
>         }
>
> +       hns->pf.mps = mps;
>         ret = hns3_buffer_alloc(hw);
>         if (ret) {
> -               hns3_err(hw, "Failed to allocate buffer, ret = %d", ret);
> -               return ret;
> +               hns3_err(hw, "failed to allocate buffer, ret = %d", ret);
> +               goto rollback;
>         }
>
>         return 0;
> +
> +rollback:
> +       err = hns3_set_mac_mtu(hw, original_mps);
> +       if (err) {
> +               hns3_err(hw, "fail to rollback MTU, err = %d", err);
> +               return ret;
> +       }
> +       hns->pf.mps = original_mps;
> +
> +       return ret;
>  }
>
>  static int
> @@ -2465,7 +2479,7 @@ hns3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
>                          dev->data->port_id, mtu, ret);
>                 return ret;
>         }
> -       hns->pf.mps = (uint16_t)frame_size;
> +
>         if (is_jumbo_frame)
>                 dev->data->dev_conf.rxmode.offloads |=
>                                                 DEV_RX_OFFLOAD_JUMBO_FRAME;
> --
> 2.7.4
>


-- 
Christian Ehrhardt
Staff Engineer, Ubuntu Server
Canonical Ltd

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

end of thread, other threads:[~2021-05-31  8:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-22  6:47 [dpdk-stable] [PATCH 19.11.9 1/3] net/hns3: fix HW buffer size on MTU update Min Hu (Connor)
2021-05-22  6:47 ` [dpdk-stable] [PATCH 19.11.9 2/3] net/hns3: fix processing Tx offload flags Min Hu (Connor)
2021-05-22  6:47 ` [dpdk-stable] [PATCH 19.11.9 3/3] net/hns3: fix handling link update Min Hu (Connor)
2021-05-31  8:41 ` [dpdk-stable] [PATCH 19.11.9 1/3] net/hns3: fix HW buffer size on MTU update Christian Ehrhardt

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