stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Khalid Manaa <khalidm@nvidia.com>,
	Tariq Toukan <tariqt@nvidia.com>,
	Saeed Mahameed <saeedm@nvidia.com>
Subject: [PATCH 5.16 26/43] net/mlx5e: Fix broken SKB allocation in HW-GRO
Date: Fri,  4 Feb 2022 10:22:33 +0100	[thread overview]
Message-ID: <20220204091918.021305558@linuxfoundation.org> (raw)
In-Reply-To: <20220204091917.166033635@linuxfoundation.org>

From: Khalid Manaa <khalidm@nvidia.com>

commit 7957837b816f11eecb9146235bb0715478f4c81f upstream.

In case the HW doesn't perform header-data split, it will write the whole
packet into the data buffer in the WQ, in this case the SHAMPO CQE handler
couldn't use the header entry to build the SKB, instead it should allocate
a new memory to build the SKB using the function:
mlx5e_skb_from_cqe_mpwrq_nonlinear.

Fixes: f97d5c2a453e ("net/mlx5e: Add handle SHAMPO cqe support")
Signed-off-by: Khalid Manaa <khalidm@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_rx.c |   26 +++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -1866,7 +1866,7 @@ mlx5e_skb_from_cqe_mpwrq_linear(struct m
 	return skb;
 }
 
-static void
+static struct sk_buff *
 mlx5e_skb_from_cqe_shampo(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,
 			  struct mlx5_cqe64 *cqe, u16 header_index)
 {
@@ -1890,7 +1890,7 @@ mlx5e_skb_from_cqe_shampo(struct mlx5e_r
 		skb = mlx5e_build_linear_skb(rq, hdr, frag_size, rx_headroom, head_size);
 
 		if (unlikely(!skb))
-			return;
+			return NULL;
 
 		/* queue up for recycling/reuse */
 		page_ref_inc(head->page);
@@ -1902,7 +1902,7 @@ mlx5e_skb_from_cqe_shampo(struct mlx5e_r
 				     ALIGN(head_size, sizeof(long)));
 		if (unlikely(!skb)) {
 			rq->stats->buff_alloc_err++;
-			return;
+			return NULL;
 		}
 
 		prefetchw(skb->data);
@@ -1913,9 +1913,7 @@ mlx5e_skb_from_cqe_shampo(struct mlx5e_r
 		skb->tail += head_size;
 		skb->len  += head_size;
 	}
-	rq->hw_gro_data->skb = skb;
-	NAPI_GRO_CB(skb)->count = 1;
-	skb_shinfo(skb)->gso_size = mpwrq_get_cqe_byte_cnt(cqe) - head_size;
+	return skb;
 }
 
 static void
@@ -1975,6 +1973,7 @@ static void mlx5e_handle_rx_cqe_mpwrq_sh
 	u32 cqe_bcnt		= mpwrq_get_cqe_byte_cnt(cqe);
 	u16 wqe_id		= be16_to_cpu(cqe->wqe_id);
 	u32 page_idx		= wqe_offset >> PAGE_SHIFT;
+	u16 head_size		= cqe->shampo.header_size;
 	struct sk_buff **skb	= &rq->hw_gro_data->skb;
 	bool flush		= cqe->shampo.flush;
 	bool match		= cqe->shampo.match;
@@ -2007,9 +2006,16 @@ static void mlx5e_handle_rx_cqe_mpwrq_sh
 	}
 
 	if (!*skb) {
-		mlx5e_skb_from_cqe_shampo(rq, wi, cqe, header_index);
+		if (likely(head_size))
+			*skb = mlx5e_skb_from_cqe_shampo(rq, wi, cqe, header_index);
+		else
+			*skb = mlx5e_skb_from_cqe_mpwrq_nonlinear(rq, wi, cqe_bcnt, data_offset,
+								  page_idx);
 		if (unlikely(!*skb))
 			goto free_hd_entry;
+
+		NAPI_GRO_CB(*skb)->count = 1;
+		skb_shinfo(*skb)->gso_size = cqe_bcnt - head_size;
 	} else {
 		NAPI_GRO_CB(*skb)->count++;
 		if (NAPI_GRO_CB(*skb)->count == 2 &&
@@ -2023,8 +2029,10 @@ static void mlx5e_handle_rx_cqe_mpwrq_sh
 		}
 	}
 
-	di = &wi->umr.dma_info[page_idx];
-	mlx5e_fill_skb_data(*skb, rq, di, data_bcnt, data_offset);
+	if (likely(head_size)) {
+		di = &wi->umr.dma_info[page_idx];
+		mlx5e_fill_skb_data(*skb, rq, di, data_bcnt, data_offset);
+	}
 
 	mlx5e_shampo_complete_rx_cqe(rq, cqe, cqe_bcnt, *skb);
 	if (flush)



  parent reply	other threads:[~2022-02-04  9:27 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-04  9:22 [PATCH 5.16 00/43] 5.16.6-rc1 review Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 01/43] PCI: pciehp: Fix infinite loop in IRQ handler upon power fault Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 02/43] selftests: mptcp: fix ipv6 routing setup Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 03/43] net: ipa: use a bitmap for endpoint replenish_enabled Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 04/43] net: ipa: prevent concurrent replenish Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 05/43] drm/vc4: hdmi: Make sure the device is powered with CEC Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 06/43] cgroup-v1: Require capabilities to set release_agent Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 07/43] Revert "mm/gup: small refactoring: simplify try_grab_page()" Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 08/43] net: phy: Fix qca8081 with speeds lower than 2.5Gb/s Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 09/43] ovl: dont fail copy up if no fileattr support on upper Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 10/43] lockd: fix server crash on reboot of client holding lock Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 11/43] lockd: fix failure to cleanup client locks Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 12/43] net/mlx5e: IPsec: Fix crypto offload for non TCP/UDP encapsulated traffic Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 13/43] net/mlx5e: IPsec: Fix tunnel mode crypto offload for non TCP/UDP traffic Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 14/43] net/mlx5e: TC, Reject rules with drop and modify hdr action Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 15/43] net/mlx5: Bridge, take rtnl lock in init error handler Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 16/43] net/mlx5: Bridge, ensure dev_name is null-terminated Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 17/43] net/mlx5e: Fix handling of wrong devices during bond netevent Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 18/43] net/mlx5: Use del_timer_sync in fw reset flow of halting poll Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 19/43] net/mlx5e: Fix module EEPROM query Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 20/43] net/mlx5e: TC, Reject rules with forward and drop actions Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 21/43] net/mlx5: Fix offloading with ESWITCH_IPV4_TTL_MODIFY_ENABLE Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 22/43] net/mlx5e: Dont treat small ceil values as unlimited in HTB offload Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 23/43] net/mlx5: Bridge, Fix devlink deadlock on net namespace deletion Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 24/43] net/mlx5e: Avoid field-overflowing memcpy() Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 25/43] net/mlx5e: Fix wrong calculation of header index in HW_GRO Greg Kroah-Hartman
2022-02-04  9:22 ` Greg Kroah-Hartman [this message]
2022-02-04  9:22 ` [PATCH 5.16 27/43] net/mlx5: E-Switch, Fix uninitialized variable modact Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 28/43] net/mlx5e: Avoid implicit modify hdr for decap drop rule Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 29/43] ipheth: fix EOVERFLOW in ipheth_rcvbulk_callback Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 30/43] i40e: Fix reset bw limit when DCB enabled with 1 TC Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 31/43] i40e: Fix reset path while removing the driver Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 32/43] net: amd-xgbe: ensure to reset the tx_timer_active flag Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 33/43] net: amd-xgbe: Fix skb data length underflow Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 34/43] fanotify: Fix stale file descriptor in copy_event_to_user() Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 35/43] net: sched: fix use-after-free in tc_new_tfilter() Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 36/43] rtnetlink: make sure to refresh master_dev/m_ops in __rtnl_newlink() Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 37/43] net: ipa: request IPA register values be retained Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 38/43] bpf: Fix possible race in inc_misses_counter Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 39/43] cpuset: Fix the bug that subpart_cpus updated wrongly in update_cpumask() Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 40/43] e1000e: Handshake with CSME starts from ADL platforms Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 41/43] af_packet: fix data-race in packet_setsockopt / packet_setsockopt Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 42/43] tcp: fix mem under-charging with zerocopy sendmsg() Greg Kroah-Hartman
2022-02-04  9:22 ` [PATCH 5.16 43/43] tcp: add missing tcp_skb_can_collapse() test in tcp_shift_skb_data() Greg Kroah-Hartman
2022-02-04 15:20 ` [PATCH 5.16 00/43] 5.16.6-rc1 review Jon Hunter
2022-02-04 18:15 ` Florian Fainelli
2022-02-04 20:31 ` Shuah Khan
2022-02-04 22:55 ` Justin Forbes
2022-02-04 23:41 ` Guenter Roeck
2022-02-05  4:40 ` Rudi Heitbaum
2022-02-05  5:14 ` Slade Watkins
2022-02-05  6:28 ` Naresh Kamboju
2022-02-05  6:50 ` Scott Bruce
2022-02-05  8:14 ` Bagas Sanjaya
2022-02-05  9:08 ` Ron Economos

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=20220204091918.021305558@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=khalidm@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=stable@vger.kernel.org \
    --cc=tariqt@nvidia.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;
as well as URLs for NNTP newsgroup(s).