Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: wei.fang@oss.nxp.com
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH v3 net-next 02/14] net: enetc: extract common helpers for MAC hash filter configuration
Date: Sat, 04 Jul 2026 10:43:43 +0000	[thread overview]
Message-ID: <20260704104344.1AE861F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260703101328.550714-3-wei.fang@oss.nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but when the exact match MAC filter fails to be programmed, the fallback to hash table (HT) filtering configures the hardware with a corrupted hash bitmask.
--

commit 7a34e5eaa6513d77933432617ababa625bd03ac3
Author: Wei Fang <wei.fang@nxp.com>

    net: enetc: extract common helpers for MAC hash filter configuration
    
    The PSIUMHFR and PSIMMHFR registers in ENETC v4 have the same bit layout
    as in ENETC v1. The only difference between the two hardware generations
    is the register address offsets.
    
    Since the register functionality is identical, the MAC hash filter
    configuration code can be shared between the ENETC v1 and v4 drivers.
    Extract two new common helper functions, enetc_set_si_uc_hash_filter()
    and enetc_set_si_mc_hash_filter(), into enetc_pf_common.c.

> diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
> index a97d2e2dd07b7..db2a800a7aaf0 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c

[ ... ]

> @@ -135,7 +108,7 @@ static void enetc_sync_mac_filters(struct enetc_pf *pf)
>  		if (em) {
>  			int err;
>  
> -			enetc_clear_mac_ht_flt(si, 0, UC);
> +			enetc_set_si_uc_hash_filter(si, 0, 0);
>  
>  			err = enetc_set_mac_flt_entry(si, pos, f->mac_addr,
>  						      BIT(0));
> @@ -147,11 +120,15 @@ static void enetc_sync_mac_filters(struct enetc_pf *pf)
>  				 err);
>  		}
>  
> +		bitmap_to_arr64(&hash, f->mac_hash_table,
> +				ENETC_MADDR_HASH_TBL_SZ);
>  		/* hash table filter, clear EM filter for UC entries */
> -		if (i == UC)
> +		if (i == UC) {
>  			enetc_clear_mac_flt_entry(si, pos);
> -
> -		enetc_set_mac_ht_flt(si, 0, i, *f->mac_hash_table);
> +			enetc_set_si_uc_hash_filter(si, 0, hash);
> +		} else {
> +			enetc_set_si_mc_hash_filter(si, 0, hash);
> +		}
>  	}
>  }

[Severity: High]
This isn't a bug introduced by this patch, but when the exact match (EM) MAC
filter fails to be programmed, the fallback to hash table (HT) filtering
appears to configure the hardware with a corrupted hash bitmask.

Because mac_addr and mac_hash_table share a union in struct enetc_mac_filter:

	union {
		char mac_addr[ETH_ALEN];
		DECLARE_BITMAP(mac_hash_table, ENETC_MADDR_HASH_TBL_SZ);
	};

and the exact match path populated mac_addr, doesn't f->mac_hash_table now
just contain the raw bytes of the MAC address?

If so, won't bitmap_to_arr64() (and the prior enetc_set_mac_ht_flt() code)
read the raw MAC address bytes as if they were a bitmap of hash indices?
This seems like it would result in the hardware being programmed with a
corrupted MAC hash filter, leading to silently dropping incoming packets for
the correct MAC address.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260703101328.550714-1-wei.fang@oss.nxp.com?part=2

  reply	other threads:[~2026-07-04 10:43 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-03 10:13 [PATCH v3 net-next 00/14] net: enetc: cleanups and improvements wei.fang
2026-07-03 10:13 ` [PATCH v3 net-next 01/14] net: enetc: extract common helpers for MAC promiscuous mode setting wei.fang
2026-07-03 10:13 ` [PATCH v3 net-next 02/14] net: enetc: extract common helpers for MAC hash filter configuration wei.fang
2026-07-04 10:43   ` sashiko-bot [this message]
2026-07-03 10:13 ` [PATCH v3 net-next 03/14] net: enetc: convert ndo_set_rx_mode() to ndo_set_rx_mode_async() wei.fang
2026-07-03 10:13 ` [PATCH v3 net-next 04/14] net: enetc: improve MAFT entry management with bitmap tracking wei.fang
2026-07-03 10:13 ` [PATCH v3 net-next 05/14] net: enetc: use PCI device name for debugfs directory wei.fang
2026-07-03 10:13 ` [PATCH v3 net-next 06/14] net: enetc: simplify enetc4_set_port_speed() wei.fang
2026-07-03 10:13 ` [PATCH v3 net-next 07/14] net: enetc: differentiate phylink capabilities for pseudo-MAC and standalone MAC wei.fang
2026-07-04 10:43   ` sashiko-bot
2026-07-06  1:25     ` Wei Fang (OSS)
2026-07-03 10:13 ` [PATCH v3 net-next 08/14] net: enetc: remove invalid code from enetc4_pl_mac_link_up() wei.fang
2026-07-03 10:13 ` [PATCH v3 net-next 09/14] net: enetc: open-code enetc4_set_default_si_vlan_promisc() wei.fang
2026-07-03 10:13 ` [PATCH v3 net-next 10/14] net: enetc: refactor SI VLAN promiscuous mode configuration wei.fang
2026-07-04 10:43   ` sashiko-bot
2026-07-06  1:42     ` Wei Fang (OSS)
2026-07-06  1:45     ` Wei Fang (OSS)
2026-07-03 10:13 ` [PATCH v3 net-next 11/14] net: enetc: move enetc_set_si_vlan_promisc() to enetc_pf_common.c wei.fang
2026-07-03 10:13 ` [PATCH v3 net-next 12/14] net: enetc: remove redundant num_vsi field from enetc_port_caps wei.fang
2026-07-04 10:43   ` sashiko-bot
2026-07-06  2:27     ` Wei Fang (OSS)
2026-07-03 10:13 ` [PATCH v3 net-next 13/14] net: enetc: use alloc_etherdev_mqs() to create netdev for VF driver wei.fang
2026-07-04 10:43   ` sashiko-bot
2026-07-03 10:13 ` [PATCH v3 net-next 14/14] net: enetc: use kzalloc_flex() for enetc_psfp_gate allocation wei.fang
2026-07-04 10:43   ` sashiko-bot

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=20260704104344.1AE861F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wei.fang@oss.nxp.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