diff mbox series

[net-next] net: ethernet: enetc: set frag flag for non-linear xdp buffers

Message ID df882eddcf76b5d0ae53c19f368a617713462fd3.1670193080.git.lorenzo@kernel.org (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: ethernet: enetc: set frag flag for non-linear xdp buffers | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 5 maintainers not CCed: bpf@vger.kernel.org ast@kernel.org daniel@iogearbox.net john.fastabend@gmail.com hawk@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Lorenzo Bianconi Dec. 4, 2022, 10:33 p.m. UTC
Set missing XDP_FLAGS_HAS_FRAGS bit in enetc_add_rx_buff_to_xdp for
non-linear xdp buffers.

Fixes: d1b15102dd16 ("net: enetc: add support for XDP_DROP and XDP_PASS")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/net/ethernet/freescale/enetc/enetc.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Vladimir Oltean Dec. 6, 2022, 12:35 p.m. UTC | #1
Hi Lorenzo,

On Sun, Dec 04, 2022 at 11:33:23PM +0100, Lorenzo Bianconi wrote:
> Set missing XDP_FLAGS_HAS_FRAGS bit in enetc_add_rx_buff_to_xdp for
> non-linear xdp buffers.
> 
> Fixes: d1b15102dd16 ("net: enetc: add support for XDP_DROP and XDP_PASS")

This can't be the Fixes: tag, struct xdp_buff didn't even have a "flags"
field when that commit was introduced.

Also, what does this change aim to achieve? It has a Fixes: tag but it's
aimed for net-next. Is it to enable multi-buff XDP support? But we also
have this in place, shouldn't that be deleted too?

		case XDP_REDIRECT:
			/* xdp_return_frame does not support S/G in the sense
			 * that it leaks the fragments (__xdp_return should not
			 * call page_frag_free only for the initial buffer).
			 * Until XDP_REDIRECT gains support for S/G let's keep
			 * the code structure in place, but dead. We drop the
			 * S/G frames ourselves to avoid memory leaks which
			 * would otherwise leave the kernel OOM.
			 */
			if (unlikely(cleaned_cnt - orig_cleaned_cnt != 1)) {
				enetc_xdp_drop(rx_ring, orig_i, i);
				rx_ring->stats.xdp_redirect_sg++;
				break;
			}
Lorenzo Bianconi Dec. 6, 2022, 1:30 p.m. UTC | #2
> Hi Lorenzo,

Hi Vladimir,

> 
> On Sun, Dec 04, 2022 at 11:33:23PM +0100, Lorenzo Bianconi wrote:
> > Set missing XDP_FLAGS_HAS_FRAGS bit in enetc_add_rx_buff_to_xdp for
> > non-linear xdp buffers.
> > 
> > Fixes: d1b15102dd16 ("net: enetc: add support for XDP_DROP and XDP_PASS")
> 
> This can't be the Fixes: tag, struct xdp_buff didn't even have a "flags"
> field when that commit was introduced.

yes, my fault, I did not check dates, I assumed this commit was done after xdp
multi-buff support. We should get rid of the Fixes tag.

> 
> Also, what does this change aim to achieve? It has a Fixes: tag but it's
> aimed for net-next. Is it to enable multi-buff XDP support? But we also
> have this in place, shouldn't that be deleted too?

I think we should get rid of the chunk below as well. I am currently working on
xdp feature support in order to allow XDP_REDIRECT for S/G xdp frames.
I will post a v2.

Regards,
Lorenzo

> 
> 		case XDP_REDIRECT:
> 			/* xdp_return_frame does not support S/G in the sense
> 			 * that it leaks the fragments (__xdp_return should not
> 			 * call page_frag_free only for the initial buffer).
> 			 * Until XDP_REDIRECT gains support for S/G let's keep
> 			 * the code structure in place, but dead. We drop the
> 			 * S/G frames ourselves to avoid memory leaks which
> 			 * would otherwise leave the kernel OOM.
> 			 */
> 			if (unlikely(cleaned_cnt - orig_cleaned_cnt != 1)) {
> 				enetc_xdp_drop(rx_ring, orig_i, i);
> 				rx_ring->stats.xdp_redirect_sg++;
> 				break;
> 			}
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
index 8671591cb750..6d08ee2233aa 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc.c
@@ -1416,6 +1416,8 @@  static void enetc_add_rx_buff_to_xdp(struct enetc_bdr *rx_ring, int i,
 	skb_frag_size_set(frag, size);
 	__skb_frag_set_page(frag, rx_swbd->page);
 
+	if (!xdp_buff_has_frags(xdp_buff))
+		xdp_buff_set_frags_flag(xdp_buff);
 	shinfo->nr_frags++;
 }