summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/freescale
AgeCommit message (Collapse)Author
12 daysMerge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/netPaolo Abeni
Merge in late fixes in preparation for the net-next PR. Conflicts: net/netfilter/nf_conntrack_netlink.c cd37ab22a74e0 ("netfilter: nf_conntrack_netlink: fix inverted IPv6 tuple filter") 1ae2d094b0200 ("netfilter: ctnetlink: fix inverted IPv6 address match in dump filter") Adjacent changes: drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c 8830e65ed46de ("net: use assign_bit() where applicable") 07bd391eb957 ("octeontx2-af: Fix CQ enable state tracking after AQ writes") net/core/sock.c 31c5ea8a3296 ("ipv6: Remove IPV6_ADDRFORM.") 31b564f70d88 ("net: use the full socket in sk_mc_loop()") net/mptcp/protocol.h 0cb6910130a3 ("mptcp: remove thmac from subflow ctx") 7538fa33bb2f ("mptcp: fix subflow bitfield misuse") Signed-off-by: Paolo Abeni <pabeni@redhat.com>
13 daysnet/fsl: xgmac_mdio: Add missing newlines to error printsMarek Vasut
Add missing newlines at the end of debug prints. Signed-off-by: Marek Vasut <marex@nabladev.com> Link: https://patch.msgid.link/20261016183804.39217-1-marex@nabladev.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
13 daysRevert "enetc: Increase eMDIO MDC rate to 2.5 MHz"Marek Vasut
This reverts commit 587acb86d6465efdc03f6d8524461e6e725597b7. While the i.MX95 MDIO MDC clock is improved by the commit 587acb86d646 ("enetc: Increase eMDIO MDC rate to 2.5 MHz"), other SoCs use different base clock for their MDIO and the MDC clock on those SoCs is set out of specification by the aforementioned commit. The fix for the i.MX95 MDIO MDC has to be done differently, and will be done so in a follow up change. Until that is done, revert the commit to fix the other SoCs. Fixes: 587acb86d646 ("enetc: Increase eMDIO MDC rate to 2.5 MHz") Signed-off-by: Marek Vasut <marex@nabladev.com> Link: https://patch.msgid.link/20261016185817.54096-1-marex@nabladev.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
13 daysnet: rename skb_unshare() to skb_unclone_full()Nicolai Buchwitz
skb_unshare() only copies cloned skbs. A shared skb that is not a clone comes back unchanged, which the name doesn't suggest. The loopback selftest hooks got caught by this and hit BUG_ON(skb_shared()). Rename it to skb_unclone_full(). Like skb_unclone() it only acts on clones, but it copies the whole skb, not just the head. Suggested-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de> Reviewed-by: Ioana Ciornei <ioana.ciornei@nxp.com> # dpaa2 Link: https://patch.msgid.link/20261015-nb-skb-unclone-full-v1-1-0dfbf01f60f2@tipi-net.de Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-10-16net: enetc: fix support for PTP_EXTTS_REQUEST2 ioctlVincent Jardin
Commit 7c571ac57d9d ("net: ptp: introduce .supported_extts_flags to ptp_clock_info") moved the validation of the external timestamp request flags into the PTP core. A driver that does not set .supported_extts_flags still accepts the legacy PTP_EXTTS_REQUEST ioctl, but every PTP_EXTTS_REQUEST2 request is rejected with -EOPNOTSUPP. The ENETC timer is the QorIQ 1588 timer, set up by ptp_qoriq_init(), which programs TMR_CTRL with ETEP1 and ETEP2 cleared, so it timestamps the rising edge of its external trigger inputs. Declare that, with PTP_STRICT_FLAGS, so that a falling edge request is rejected instead of being timestamped on the rising edge. This also makes the legacy PTP_EXTTS_REQUEST ioctl strict: a request for the falling edge, or for both edges, now fails with -EOPNOTSUPP instead of being timestamped on the rising edge. That cannot be avoided: the core adds PTP_STRICT_FLAGS to every PTP_EXTTS_REQUEST2 request, so a driver has to declare it to accept them, and once declared it applies to both ioctls. Commit 3200fdd4021d ("broadcom: fix support for PTP_EXTTS_REQUEST2 ioctl") made the same change for bcm-phy-ptp. Fixes: 7c571ac57d9d ("net: ptp: introduce .supported_extts_flags to ptp_clock_info") Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Reviewed-by: Kory Maincent <kory.maincent@bootlin.com> Signed-off-by: Vincent Jardin <vjardin@free.fr> Reviewed-by: Wei Fang <wei.fang@nxp.com> Link: https://patch.msgid.link/20261009-for-upstream-qoriq-ptp-extts-flags-v2-2-0f4eeff2295d@free.fr Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-10-16dpaa2-ptp: fix support for PTP_EXTTS_REQUEST2 ioctlVincent Jardin
Commit 7c571ac57d9d ("net: ptp: introduce .supported_extts_flags to ptp_clock_info") moved the validation of the external timestamp request flags into the PTP core. A driver that does not set .supported_extts_flags still accepts the legacy PTP_EXTTS_REQUEST ioctl, but every PTP_EXTTS_REQUEST2 request is rejected with -EOPNOTSUPP. On an LX2160A board, linuxptp ts2phc arms the external timestamp channel of the 1588 timer with PTP_EXTTS_REQUEST2, gets -EOPNOTSUPP and exits, so the PHC cannot be disciplined from an external 1PPS. ptp_qoriq_init() programs TMR_CTRL with ETEP1 and ETEP2 cleared, so the timer timestamps the rising edge of its external trigger inputs. Declare that, with PTP_STRICT_FLAGS, so that a falling edge request is rejected instead of being timestamped on the rising edge. This also makes the legacy PTP_EXTTS_REQUEST ioctl strict: a request for the falling edge, or for both edges, now fails with -EOPNOTSUPP instead of being timestamped on the rising edge. That cannot be avoided: the core adds PTP_STRICT_FLAGS to every PTP_EXTTS_REQUEST2 request, so a driver has to declare it to accept them, and once declared it applies to both ioctls. Commit 3200fdd4021d ("broadcom: fix support for PTP_EXTTS_REQUEST2 ioctl") made the same change for bcm-phy-ptp. Fixes: 7c571ac57d9d ("net: ptp: introduce .supported_extts_flags to ptp_clock_info") Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Reviewed-by: Kory Maincent <kory.maincent@bootlin.com> Signed-off-by: Vincent Jardin <vjardin@free.fr> Link: https://patch.msgid.link/20261009-for-upstream-qoriq-ptp-extts-flags-v2-1-0f4eeff2295d@free.fr Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-10-01dpaa2-eth: mark DPNIs without a DPMAC as virtual devlink portsVincent Jardin
A DPNI whose endpoint is not a DPMAC has no physical connector: it may have no endpoint at all, or be connected to another DPNI or to a DPSW port. Until now, such a DPNI was still registered as a physical devlink port with number 0, so userspace saw a physical port that does not exist. Register these DPNIs as virtual devlink ports instead. A virtual port has no phys_port_name, so only the DPNIs that serve a DPMAC at probe time report one, "p<dpmac id>", and those names do not collide. Signed-off-by: Vincent Jardin <vjardin@free.fr> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20260928-for-upstream-dpaa2_ports-v2-2-1cda148530bf@free.fr Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-10-01dpaa2-eth: use the DPMAC id as the devlink physical port numberVincent Jardin
dpaa2-eth registers every DPNI as a devlink port of flavour physical without setting a port number. All DPAA2 interfaces report the same phys_port_name, p0 (see devlink port show). The DPNI endpoint can change at runtime while the attributes of a registered devlink port cannot, so log a warning when it happens. Another benefit: udev rules can match ATTR{phys_port_name} to name an interface based on its DPMAC. Signed-off-by: Vincent Jardin <vjardin@free.fr> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20260928-for-upstream-dpaa2_ports-v2-1-1cda148530bf@free.fr Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-29enetc: Increase eMDIO MDC rate to 2.5 MHzMarek Vasut
The current eMDIO MDC rate is 558 kHz on i.MX95 B0. This is very low, but also very compatible. However, for example NXP TJA1120 PHY needs at minimum 1 MHz MDC clock and 558 kHz does not work with that PHY. As a minimum change, increase the MDC clock to 2.5 MHz which matches the 802.3 specification. Also, even old PHYs like LAN8210Ai, KSZ8794, DP83822 support up to 2.5 MHz MDC clock frequency, and it covers the NXP TJA1120 as well. There is no known rationale for why the 558 kHz was picked when the eMDIO driver was added. Signed-off-by: Marek Vasut <marex@nabladev.com> Link: https://patch.msgid.link/20260924180607.60932-1-marex@nabladev.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-29net: enetc: document enetc_msg_vsi_send() return valuesDan Carpenter
Smatch combines the return values together and wants all the callers to handle the positive values so it leads to static checker warnings. Add a comment explaining the return values. Generally functions which return non-standard values should have a comment. Signed-off-by: Dan Carpenter <error27@gmail.com> Link: https://patch.msgid.link/09f24cefc214455305543a0528ceae6349c77419.1790357822.git.error27@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-24Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/netJakub Kicinski
Cross-merge networking fixes after downstream PR (net-7.3-rc5). Conflicts: drivers/net/mdio/mdio-realtek-rtl9300.c 89a8a1eef2d44 ("net: mdio: realtek-rtl9300: fix RTL931x C22 extended page selection") cc3cb8db1eef9 ("net: mdio: realtek-rtl9300: Add page tracking") https://lore.kernel.org/arUZOqy73bE2pp0w@sirena.org.uk net/8021q/vlan_dev.c cd5dd68267c4 ("vlan: ensure sufficient headroom in vlan_dev_hard_header()") ca6ff8dd70eb ("vlan: annotate data-races in vlan_dev_priv fields") Adjacent changes: net/ipv6/ip6_gre.c dd47bcf279f1 ("ip6_gre: Call ip6erspan_tunnel_unlink_md() in ip6erspan_changelink().") cce829e2aa1d ("ip6_gre: Protect ip6gre_net.tunnels[][] with mutex.") drivers/net/ethernet/meta/fbnic/fbnic_txrx.c b5d9e9d4d0c1 ("eth: fbnic: use the Rx queue napi pointer to find the napi vector") c0aca269ec07 ("eth: fbnic: Make Rx completion coalescing configurable") drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c d68acbf93531 ("net: stmmac: selftests: Support running selftests on DSA conduits") 85ca3292d7a3 ("net: stmmac: Remove ARP offload code") drivers/net/ethernet/wangxun/libwx/wx_hw.c 3173cba11701 ("net: libwx: fix races in Tx timestamp handling") 7042c8c193e5 ("net: libwx: rename wx_pf_flags to wx_flags") Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-22fsl/fman: Fix clk reference leak in read_dts_node()Wentao Liang
of_clk_get() returns a clock with its reference count incremented, but read_dts_node() only uses it to read the rate and never calls clk_put(). The clock is not stored anywhere, so the reference cannot be released later either. Release the clock once its rate has been read, which also covers the error path taken when the rate is zero. Fixes: 414fd46e7762 ("fsl/fman: Add FMan support") Cc: stable@vger.kernel.org Signed-off-by: Wentao Liang <vulab@iscas.ac.cn> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20260917110135.2148068-1-vulab@iscas.ac.cn Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-19net: use assign_bit() where applicablePeng Fan
Convert open-coded if/else with set_bit/clear_bit and their non-atomic __set_bit/__clear_bit variants to the assign_bit/__assign_bit API. Done with Coccinelle semantic patch: // set_bit -> clear_bit => assign_bit @@ expression cond, bit, addr; @@ -if (cond) - set_bit(bit, addr); -else - clear_bit(bit, addr); +assign_bit(bit, addr, cond); // clear_bit -> set_bit => assign_bit @@ expression cond, bit, addr; @@ -if (cond) - clear_bit(bit, addr); -else - set_bit(bit, addr); +assign_bit(bit, addr, !cond); // __set_bit -> __clear_bit => __assign_bit @@ expression cond, bit, addr; @@ -if (cond) - __set_bit(bit, addr); -else - __clear_bit(bit, addr); +__assign_bit(bit, addr, cond); // __clear_bit -> __set_bit => __assign_bit @@ expression cond, bit, addr; @@ -if (cond) - __clear_bit(bit, addr); -else - __set_bit(bit, addr); +__assign_bit(bit, addr, !cond); Signed-off-by: Peng Fan <peng.fan@nxp.com> Reviewed-by: Ratheesh Kannoth <rkannoth@marvell.com> Link: https://patch.msgid.link/20260917-net-assign-bit-v1-1-e9c97965e080@nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-18net: dpaa2: ptp: fix device node reference leak on removeGuangshuo Li
dpaa2_ptp_probe() gets a referenced device node with of_find_compatible_node() and stores it in dev->of_node. The probe failure paths release this reference with of_node_put(). However, after a successful probe, dpaa2_ptp_remove() tears down the PTP and MC resources without dropping the device node reference. Release dev->of_node during driver removal and clear the pointer after dropping the reference. This issue was found by manual code inspection. Cc: stable+noautosel@kernel.org # untested fix to a driver init path Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com> Link: https://patch.msgid.link/20260916030015.2818545-1-lgs201920130244@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-18net: fs_enet: fix platform info memory leak on removeGuangshuo Li
fs_enet_probe() allocates the platform information structure with kzalloc_obj() and stores it in fep->fpi. The probe failure paths release this allocation with kfree(). However, after a successful probe, fs_enet_remove() tears down the network device without freeing fep->fpi, leaving the platform information structure allocated after driver removal. Free fep->fpi before releasing the network device. This issue was found by manual code inspection. Cc: stable+noautosel@kernel.org # untested fix to a driver init path Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20260916031414.2875022-1-lgs201920130244@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-09-15net: enetc: add ndo_get_vf_config() supportWei Fang
Without ndo_get_vf_config(), userspace tools such as 'ip link show' cannot query the current VF configuration from the PF. To support this, extend struct enetc_vf_state to track the per-VF VLAN and spoofchk settings, and update the corresponding setter callbacks to persist their state when the hardware is programmed. enetc_pf_get_vf_config() reads back the persisted state and reports MAC address, VLAN parameters, spoofchk, and trust state through struct ifla_vf_info. Signed-off-by: Wei Fang <wei.fang@nxp.com> Link: https://patch.msgid.link/20260909100733.1139689-16-wei.fang@oss.nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-15net: enetc: add PSI-to-VSI link status notification support for VFWei Fang
Let ENETC v4 VFs track PF link status through the PSI-to-VSI messaging channel. Add two enetc_si_ops hooks, vf_reg_link_status_notifier and vf_unreg_link_status_notifier, populated only in enetc4_vsi_ops; rev1 hardware is unaffected. A dedicated MSI-X vector on the VF handles incoming PSI-to-VSI messages. Its handler schedules a work item on an ordered workqueue that reads the notification via VSIMSGRR, updates the carrier state and sets congestion mode from the PF TX PAUSE state in the message. Reading VSIMSGRR also acknowledges the PF so it can send the next message. The workqueue is set up in enetc_vf_probe() and torn down in enetc_vf_remove(). On a VF, enetc_phylink_connect() registers the notifier with the PF and enetc_close() unregisters it. On registration the PF immediately sends the current link status and then broadcasts every later transition; if registration fails, fall back to the LS1028A behaviour and assert carrier unconditionally. Register the notifier only after the Tx/Rx resources are allocated in enetc_open(), because once registered the PF may queue si->msg_task via a link-up message. An error unwind cannot drain that work item, since enetc_open() and the work item both take the RTNL lock and waiting would deadlock; and as __LINK_STATE_START is set before ndo_open() runs, netif_running() stays true during the unwind, so the queued work could still call netif_carrier_on() and leave carrier 'on' after a failed open. Signed-off-by: Wei Fang <wei.fang@nxp.com> Link: https://patch.msgid.link/20260909100733.1139689-15-wei.fang@oss.nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-15net: enetc: implement ndo_set_rx_mode_async for ENETC v4 VFWei Fang
An ENETC VF sends MAC filter changes to the PF over the VSI mailbox, whose send path may sleep for up to 200ms waiting for completion. Since the legacy ndo_set_rx_mode runs in atomic context, use ndo_set_rx_mode_async instead, which runs from a workqueue under rtnl_lock and receives pre-snapshotted unicast and multicast address lists from the core. Add two helpers built on the VSI mailbox: - enetc_vf_set_mac_promisc() sends a promiscuous mode message for a given filter type (unicast, multicast or both). - enetc_vf_set_mac_hash_filter() sends the 64-bit MAC hash filter table, built from the snapshotted address lists. The callback picks the configuration from the current netdev flags: - IFF_PROMISC: enable promiscuous mode for both unicast and multicast. - IFF_ALLMULTI: enable multicast promiscuous mode, disable unicast promiscuous mode and apply a unicast hash filter. - otherwise: disable promiscuous mode and apply both unicast and multicast hash filters. These requests are subject to the PF-side ENETC_VF_FLAG_TRUSTED check. For an untrusted VF (the default) the PF denies promiscuous mode and unicast hash filtering, so only the multicast hash filter is applied, limited to ENETC_VF_MC_HASH_BITS_MAX buckets. Mark a VF trusted via 'ip link set <pf> vf N trust on' for the full behaviour. Set IFF_UNICAST_FLT for ENETC v4 VFs so the stack does not needlessly fall back to full promiscuous mode; whether a unicast hash filter is actually programmed still depends on the PF trust policy. Since a denied request always fails, map -EOPNOTSUPP, -EACCES and -EPERM to 0 so the core does not retry an operation that can never succeed. ENETC v1 (LS1028A) does not support VF-to-PF MAC filter messaging and keeps using the legacy ndev ops. On VF removal, disable promiscuous mode and clear the MAC filters, so that stale configuration does not persist if the VF is later bound to another driver. Signed-off-by: Wei Fang <wei.fang@nxp.com> Link: https://patch.msgid.link/20260909100733.1139689-14-wei.fang@oss.nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-15net: enetc: add VF support for i.MX94 and i.MX95Wei Fang
Add VF support for the i.MX94 and i.MX95 platforms. Compared to the LS1028A ENETC, the VF device ID is updated to 0xef00, so add it to the VF driver's PCI device ID table. Also add the enetc4 SI ops and VF driver data, and wire up .sriov_configure for the enetc4 PF driver so that VFs can be created and torn down on these SoCs. The number of VFs is not decided by the driver. It is determined by each ENETC instance's SR-IOV hardware capability, reported through the PCI SR-IOV TotalVFs field and configured by the SoC integration and device tree. The driver derives it from pci_sriov_get_totalvfs() in enetc_init_sriov_resources(); an instance that advertises zero VFs simply cannot enable SR-IOV. So there is no driver-side revision or device-ID check bounding the VF count. For reference, the per-instance VF capability on these SoCs is: - i.MX95 (v4.1): each ENETC instance supports 2 VFs. - i.MX94 (v4.3) has two kinds of ENETC: - standalone ENETC, the same instance type as on i.MX95, but on i.MX94 it advertises no VFs; - internal ENETC connected to the CPU port of the NETC switch, which supports 3 VFs. Signed-off-by: Wei Fang <wei.fang@nxp.com> Link: https://patch.msgid.link/20260909100733.1139689-13-wei.fang@oss.nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-15net: enetc: restore VF MAC promiscuous mode after FLR for ENETC v4Wei Fang
On ENETC v4, when VF performs a PCI FLR, it resets PSIPMMR[SIn_MAC_UP] and PSIPMMR[SIn_MAC_MP] bits, which control the unicast and multicast promiscuous mode for the corresponding SI. The reset (default) value of these bits enables promiscuous mode, meaning that after a VF FLR, the SI is left in promiscuous mode regardless of the configuration set by the PF driver prior to the reset. This is a potential security vulnerability: a malicious VM could deliberately trigger a VF FLR to force promiscuous mode on its SI, allowing it to capture network traffic not destined for that VF. To mitigate this, make the following changes: - Add ENETC_VF_FLAG_UC_PROMISC and ENETC_VF_FLAG_MC_PROMISC to enetc_vf_flags to track the PF-managed promiscuous mode state for each VF. - Update enetc_msg_set_vf_mac_promisc_mode() to keep these flags in sync whenever a VF requests a promiscuous mode change via messaging. - Update enetc_pf_set_vf_trust() to clear both promisc flags when a VF is untrusted, so that a subsequent FLR cannot restore promiscuous mode that the PF has already revoked. - Add a vf_flr_handler callback to enetc_pf_ops. The ENETC v4 implementation re-applies the tracked UC/MC promiscuous mode settings to the hardware after each FLR, ensuring the hardware state matches the PF-managed policy rather than the insecure reset default. - Add enetc_vf_flr_handler() in enetc_msg.c to detect FLR events via the PSIIDR register and dispatch to the vf_flr_handler callback. Invoke it at the start of enetc_msg_task() before processing VF messages. - Enable FLR interrupts in PSIIER only when a vf_flr_handler callback is registered, keeping ENETC v1 behavior unchanged. Signed-off-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Claudiu Manoil <claudiu.manoil@nxp.com> Link: https://patch.msgid.link/20260909100733.1139689-12-wei.fang@oss.nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-15net: enetc: simplify and rename PSIIER enable/disable helpersWei Fang
The PSIIER register controls two categories of interrupt sources: message-receive (MR) interrupts, which fire when a VF sends a mailbox message to the PSI, and VF FLR interrupts, which fire when a VF performs a Function Level Reset. The current helpers enetc_msg_enable_mr_int() and enetc_msg_disable_mr_int() use a read-modify-write sequence to update only the MR bits in PSIIER, intending to preserve any other bits that may be set. However, VF FLR interrupt support is not yet implemented, so PSIIER only ever holds MR interrupt bits at this point. The read-modify-write is therefore unnecessary overhead. Simplify enetc_disable_psiier_interrupts() to write 0 directly to PSIIER, disabling all interrupt sources at once, and simplify enetc_enable_psiier_interrupts() to write the MR mask directly without reading the current register value first. Rename both helpers from the MR-specific names to names that reflect their true scope, i.e. managing all PSIIER interrupt sources rather than just the MR bits. This prepares the code for a future patch that adds VF FLR interrupt support, at which point enetc_enable_psiier_interrupts() will be extended to also set the corresponding FLR bits. Signed-off-by: Wei Fang <wei.fang@nxp.com> Link: https://patch.msgid.link/20260909100733.1139689-11-wei.fang@oss.nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-15net: enetc: add MAC address filtering support for VFs of ENETC v4Wei Fang
ENETC v4 VF hardware supports MAC address filtering, but the underlying resources (the PSIPMMR register and per-SI hash filter tables) are owned by the PF. Add VSI-to-PSI mailbox messages so a VF can request MAC filter configuration from the PF, using two new command IDs under the existing MAC filter class (0x20): 1. ENETC_MSG_SET_MAC_HASH_TABLE (cmd_id 3): program the unicast and/or multicast MAC hash filter table. Unicast filtering is only allowed for a trusted VF, since it could be used to receive traffic destined for other SIs. Multicast filtering is allowed even for an untrusted VF, but limited to ENETC_VF_MC_HASH_BITS_MAX (8) buckets, enough for basic operation such as IPv6 neighbor discovery and mDNS; a trusted VF may use all 64 buckets. 2. ENETC_MSG_SET_MAC_PROMISC_MODE (cmd_id 5): enable or disable unicast/ multicast promiscuous mode, and optionally flush the hash filter table. Enabling promiscuous mode requires a trusted VF; flushing the table alone does not. The PSIPMMR register is a shared resource accessed by both enetc4_pf_set_rx_mode() and the VF message handler via a non-atomic read-modify-write, so protect these accesses with si->gen_lock to avoid lost updates on SMP. When a VF loses trusted status via ndo_set_vf_trust(), clear its unicast hash filter and disable promiscuous mode so it cannot receive traffic beyond its allowed scope. Signed-off-by: Wei Fang <wei.fang@nxp.com> Link: https://patch.msgid.link/20260909100733.1139689-10-wei.fang@oss.nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-15net: enetc: move mac_filter from struct enetc_pf to struct enetc_siWei Fang
The mac_filter array currently resides in struct enetc_pf and is used to track unicast and multicast MAC address filters for the PF. Since struct enetc_si is the common structure shared between the PF and VF drivers, move mac_filter into struct enetc_si to prepare for MAC filter support in the VF driver. Signed-off-by: Wei Fang <wei.fang@nxp.com> Link: https://patch.msgid.link/20260909100733.1139689-9-wei.fang@oss.nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-15net: enetc: add .ndo_set_vf_mac() to the enetc v4 driverWei Fang
Add .ndo_set_vf_mac() to the enetc v4 driver to configure the MAC addresses of VFs. Signed-off-by: Wei Fang <wei.fang@nxp.com> Link: https://patch.msgid.link/20260909100733.1139689-8-wei.fang@oss.nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-15net: enetc: relocate enetc_pf_set_vf_mac() for common PF supportWei Fang
Move enetc_pf_set_vf_mac() into enetc-pf-common driver as a generic interface for both ENETC v1 and v4 PF driver to use. Signed-off-by: Wei Fang <wei.fang@nxp.com> Link: https://patch.msgid.link/20260909100733.1139689-7-wei.fang@oss.nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-15net: enetc: use enetc_set_si_hw_addr() to set VF MAC addressWei Fang
Prepare for moving enetc_pf_set_vf_mac() into the enetc-pf-common driver by replacing enetc_pf_set_primary_mac_addr() with enetc_set_si_hw_addr(). This makes the VF primary MAC configuration path generic and allows future enetc v4 PF driver to reuse the same interface. Signed-off-by: Wei Fang <wei.fang@nxp.com> Link: https://patch.msgid.link/20260909100733.1139689-6-wei.fang@oss.nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-15net: enetc: add link speed message support to PF driverWei Fang
When a VF is driven by DPDK, its user space application needs accurate link speed information to make correct forwarding and configuration decisions. Add link speed message support so the PF replies with the current link speed when it receives a get-link-speed message from a VF. Use a new message class 0x81 (ENETC_MSG_CLASS_ID_LINK_SPEED). The PSI-to-VSI message is 16 bits: the high 8 bits are the class ID and the low 8 bits are the speed code, so up to 255 speed values are supported (ENETC_MSG_SPEED_MAX = 0xff). Instead of enumerating every speed above 5Gbps, use a formula so future high speeds need no enum or switch changes: speed_code = (link_speed - 5000) / 1000 + ENETC_MSG_SPEED_5G The speed is read via phylink_ethtool_ksettings_get() rather than the speed passed to the mac_link_up() callback. When the MAC has a PCS layer, mac_link_up() reports the PCS link speed, which may differ from the external PHY link speed; phylink_ethtool_ksettings_get() returns the actual external link speed. Unlike the link status message (class 0x80), the get-link-speed message is only permitted for trusted VFs. Reading the speed requires the PF to take rtnl_lock(), so an untrusted VF spamming this query could cause rtnl_lock contention and starve routine network configuration on the host. An untrusted VF therefore receives a permission-deny response; a VF can be marked trusted via 'ip link set <pf> vf N trust on'. Note that link speed change notification is not supported yet. Signed-off-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Claudiu Manoil <claudiu.manoil@nxp.com> Link: https://patch.msgid.link/20260909100733.1139689-5-wei.fang@oss.nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-15net: enetc: add link status message support to PF driverWei Fang
Add a mechanism for VFs to learn the PF link state, using message class 0x80 (ENETC_MSG_CLASS_ID_LINK_STATUS) with three VSI-to-PSI commands: 1. ENETC_MSG_GET_CURRENT_LINK_STATUS: the VF queries the current PF link status synchronously. This is intended for DPDK-owned VFs and is not used by the Linux VF driver. 2. ENETC_MSG_REGISTER_LINK_CHANGE_NOTIFIER: the VF registers for link change notification. The PF then reports the current link status and notifies the VF on every later link change. 3. ENETC_MSG_UNREGISTER_LINK_CHANGE_NOTIFIER: the VF unregisters. The PSI-to-VSI notification is 16 bits wide: the upper 8 bits carry the class ID and the lower 8 bits the class code. Bit 0 of the class code indicates the link state (1 = down, 0 = up) and bit 1 indicates whether TX PAUSE is enabled on the PF. The TX PAUSE state is included so a VF can decide whether to enable congestion mode on its RX BD rings, which only works when the PF can actually send PAUSE frames. Notifications are sent through the ENETC_PSIMSGSR register. Since sending a notification may take a long time, as it polls the per-VF message status bits, the actual transmission is deferred to an ordered workqueue rather than running in the phylink link_up/link_down callbacks. The link_status_ms_mask tracks the VFs registered for notification and is cleared when SR-IOV is disabled. Export enetc_pf_notify_vf_link_up() and enetc_pf_notify_vf_link_down() for the PF phylink callbacks. Through this, VFs can perceive the link status and report it to upper layers such as the kernel network stack, containers and virtual machines. Currently only the ENETC v4 driver supports this feature; v1 does not. And the SR-IOV feature of ENETC v4 will be added by subsequent patches. Signed-off-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Claudiu Manoil <claudiu.manoil@nxp.com> Link: https://patch.msgid.link/20260909100733.1139689-4-wei.fang@oss.nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-15net: enetc: move msg_task and msg_int_name to struct enetc_siWei Fang
The ENETC PF currently uses msg_task and msg_int_name in struct enetc_pf to handle VSI-to-PSI mailbox messages via a workqueue and a dedicated interrupt. PSI-to-VSI message support will be added to the VF driver, which will require the same mechanism: a message interrupt and a workqueue handler. Since struct enetc_si is the common structure shared between PF and VF, move msg_task and msg_int_name from struct enetc_pf to struct enetc_si to allow both drivers to use them without duplication. Also relocate the ENETC_INT_NAME_MAX macro definition ahead of struct enetc_si so it can be used for the msg_int_name array declaration. Signed-off-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Claudiu Manoil <claudiu.manoil@nxp.com> Link: https://patch.msgid.link/20260909100733.1139689-3-wei.fang@oss.nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-15net: enetc: add trusted VF supportClaudiu Manoil
Some mailbox messages require a higher privilege level to be executed on behalf of the requesting VF. Introduce a trusted VF flag (ENETC_VF_FLAG_TRUSTED) and wire up the ndo_set_vf_trust callback via enetc_pf_set_vf_trust(), which is shared between the enetc and enetc4 PF drivers. Trust is a PF/host-side policy bound to the VF index, decoupled from whether SR-IOV is enabled. It may be set on a slot before SR-IOV is enabled so a trusted VF can apply configuration right at init time, and it is intentionally preserved across an SR-IOV disable/enable cycle. The bounds check uses pf->total_vfs, the hardware maximum and the size of pf->vf_state[], so pre-configuring an uninstantiated slot is in-bounds. If a slot may be reassigned to another guest, the admin clears trust with "ip link set <dev> vf <N> trust off". The first message gated on trust is the VF primary MAC address change. An untrusted VF that attempts to set its own MAC address will receive a ENETC_MSG_CLASS_ID_PERMISSION_DENY response and the hardware will not be programmed. This prevents a malicious VM from setting the VF address to the MAC address of other VFs or the PF and eavesdropping on the traffic of other SIs, and it stops a malicious VM from arbitrarily changing the VF MAC address to achieve MAC address spoofing and bypass security policies. This does not regress VF bring-up. The PF programs a valid primary MAC into every VF slot at probe, and the VF loads it from its own SIPMAR0/1 registers. Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com> Signed-off-by: Wei Fang <wei.fang@nxp.com> Link: https://patch.msgid.link/20260909100733.1139689-2-wei.fang@oss.nxp.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-15net: fec: Handle optional IRQ lookup errors correctlybui duc phuc
Handle errors from platform_get_irq_byname_optional() explicitly while preserving the existing fallback to platform_get_irq() when the named IRQ is not available. Propagate errors other than -ENXIO from the optional IRQ lookup instead of silently falling back to the indexed IRQ lookup. In particular, silently ignoring -EPROBE_DEFER can cause the driver to continue probing instead of deferring as required. Reviewed-by: Wei Fang <wei.fang@nxp.com> Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> Link: https://patch.msgid.link/20260911040021.12289-2-phucduc.bui@gmail.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-15net: fec: Propagate PTP initialization errorsbui duc phuc
Change fec_ptp_init() to return an error code instead of silently ignoring failures during PTP initialization. The PPS IRQ is not required for the FEC/PTP functionality, so its absence should not make the probe fail. However, an unavailable optional IRQ should be distinguished from an actual error returned during the IRQ lookup. If a platform does not support the PPS IRQ, it can omit the IRQ from its device tree and the optional lookup will return -ENXIO. Propagate other errors from the IRQ lookup instead of silently ignoring them. In particular, silently ignoring -EPROBE_DEFER can cause the driver to continue probing instead of deferring as required. Also propagate failures from devm_request_irq() and ptp_clock_register(). Update the function declaration in fec.h accordingly. Found by manual code inspection. Reviewed-by: Wei Fang <wei.fang@nxp.com> Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> Link: https://patch.msgid.link/20260911040021.12289-1-phucduc.bui@gmail.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-04treewide: refresh kmalloc_obj() conversionsKees Cook
This is another run of the Coccinelle script for converting kmalloc() family of allocations to kmalloc_obj() via the existing rules in scripts/coccinelle/api/kmalloc_objs.cocci This catches both the set of kmalloc() uses added since the first kmalloc_obj() conversions in v7.0 and adds a large group missed in the first pass due to Coccinelle not interacting well with the cleanup.h scoped_...() family of macros[1]. I worked around this with spatch's "--macro-file" argument to a file with all the scoped_...() macros mapped to Coccinelle's YACFE_ITERATOR[2] as that was the closest viable control flow indicator I could find. Build tested allmodconfig on x86, arm64, arm, loongarch, mips, powerpc, riscv, and s390 with no new warnings. Link: https://lore.kernel.org/lkml/202609021314.8A9C0B8@keescook/ [1] Link: https://github.com/coccinelle/coccinelle/blob/master/standard.h [2] Signed-off-by: Kees Cook <kees+treewide@kernel.org>
2026-08-27net: fec: only stop PTP if it was initializedbui duc phuc
fec_ptp_init() is only called when fep->bufdesc_ex is available. However, fec_probe() unconditionally calls fec_ptp_stop() on the failed_init path, and fec_drv_remove() unconditionally calls fec_ptp_stop() during device removal. Check fep->bufdesc_ex before calling fec_ptp_stop() in both paths to avoid stopping PTP when it was not initialized. Fixes: 32cba57ba74b ("net: fec: introduce fec_ptp_stop and use in probe fail path") Reviewed-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> Link: https://patch.msgid.link/20260826103428.32807-1-phucduc.bui@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-08-24net: enetc: restore RX ring congestion mode for ENETC v4Wei Fang
ENETC v4 has the same problem as ENETC v1: the RX BD ring congestion mode (CM) is only configured in the phylink .mac_link_up() callback, so it is cleared when enetc_reconfigure() rebuilds the RX BD rings at runtime (for example when enabling or disabling PTP RX hardware timestamping) without a link status change, and it is never restored. As a result, the MAC can no longer generate PAUSE frames on ingress congestion and flow control stops working. Fix it in the same way as ENETC v1. Track the desired CM state in the software flag ENETC_RXBDR_CM. Route enetc4_set_tx_pause() through the shared helper enetc_set_congestion_mode(), which sets or clears the flag according to tx_pause and updates the ENETC_RBMR_CM bit under si->gen_lock. When the RX BD rings are (re)enabled, enetc_enable_rxbdr() consults this flag and restores the CM bit accordingly, so flow control survives ring reconfiguration even when the link status does not change. Fixes: f5b9a1cde0a2 ("net: enetc: add PTP synchronization support for ENETC v4") Signed-off-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20260821064140.1315611-3-wei.fang@oss.nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-08-24net: enetc: restore RX ring congestion mode after ring reconfigurationWei Fang
The RX ring congestion mode (CM) is only configured in the phylink .mac_link_up() callback enetc_pl_mac_link_up(), which sets the ENETC_RBMR_CM bit when tx_pause is enabled. This callback runs only when the link status changes. However, enetc_reconfigure() tears down and re-creates the RX BD rings at runtime without any link status change, for example when attaching or detaching an XDP program, or when enabling/disabling PTP RX hardware timestamping. The rings are rebuilt from a cleared RBMR, so the CM bit is lost. Since the link status does not change, enetc_pl_mac_link_up() is not called again and the CM bit is never restored. As a result, the ENETC MAC can no longer generate PAUSE frames on ingress congestion, and flow control stops working after such a reconfiguration. Track the desired CM state in a software flag ENETC_RXBDR_CM. Set or clear this flag in enetc_pl_mac_link_up() according to tx_pause. When the RX BD rings are (re)enabled, enetc_enable_rxbdr() consults this flag and restores the ENETC_RBMR_CM bit accordingly, so flow control survives ring reconfiguration even when the link status does not change. RBMR is now written as a whole word from enetc_enable_rxbdr() rather than by read-modify-write from several call sites. Serialize the remaining RBMR read-modify-write paths, the congestion mode update and the RX VLAN offload update, with the new si->gen_lock so they cannot race each other. Fixes: 5093406c784f ("net: enetc: implement ring reconfiguration procedure for PTP RX timestamping") Signed-off-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20260821064140.1315611-2-wei.fang@oss.nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-08-17net: add READ_ONCE()/WRITE_ONCE() annotations for dev->num_tcEric Dumazet
Several fast-path and control-path lockless readers access dev->num_tc (e.g., skb_tx_hash(), netdev_txq_to_tc(), netdev_get_num_tc(), and qdisc/driver lookups) while concurrent writers update dev->num_tc during TC setup, device reset, or channel configuration. Add READ_ONCE() and WRITE_ONCE() annotations to prevent compiler reordering and load/store tearing when accessing dev->num_tc. Update inline helpers in netdevice.h (netdev_get_num_tc(), netdev_set_prio_tc_map(), and netdev_get_sb_channel()) as well as writers and lockless readers in core networking code and drivers. Signed-off-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20260812085440.3917924-3-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-07-30net: ethernet: remove conditional return with no effectSang-Heon Jeon
Both branches of the check return the same value, so the check has no effect. Remove it and return the value directly. This is the result of running the Coccinelle script from scripts/coccinelle/misc/cond_return_no_effect.cocci. Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Reviewed-by: Arthur Kiyanovski <akiyano@amazon.com> Reviewed-by: Ioana Ciornei <ioana.ciornei@nxp.com> # for dpaa2-switch Link: https://patch.msgid.link/20260725150852.859188-3-ekffu200098@gmail.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-07-27net: enetc: use kzalloc_flex() for enetc_psfp_gate allocationWei Fang
Replace the open-coded struct_size() + kzalloc() pattern with the kzalloc_flex() helper when allocating struct enetc_psfp_gate. This removes the intermediate entries_size local variable and makes the allocation site more concise. Signed-off-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Joe Damato <joe@dama.to> Link: https://patch.msgid.link/20260720014317.1059359-15-wei.fang@oss.nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-07-27net: enetc: use alloc_etherdev_mqs() to create netdev for VF driverWei Fang
The VF driver uses alloc_etherdev_mq() with ENETC_MAX_NUM_TXQS as the queue count, which forces the TX and RX queue counts to be equal and uses a compile-time constant rather than the actual hardware capability. After enetc_get_si_caps() is called, si->num_tx_rings and si->num_rx_rings reflect the actual number of rings assigned to the VF by the PF. For the ENETC VF on LS1028A and the upcoming i.MX95/94, their SoCs have no more than 6 CPUs, and the number of TX/RX rings allocated to the VF is less than 8. Therefore, switch to alloc_etherdev_mqs() so that the TX and RX queue counts are set independently, each capped at ENETC_MAX_NUM_TXQS, based on the actual number of rings assigned to the VF by the PF. Note that if future SoCs have more than 6 CPUs and more than 6 RX rings allocated to VFs, the size of the int_vector array in struct enetc_ndev_priv will need to be modified. Similarly, if more than 8 TX rings are allocated to each int_vector, ENETC_MAX_NUM_TXQS will also need to be modified. Signed-off-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Joe Damato <joe@dama.to> Link: https://patch.msgid.link/20260720014317.1059359-14-wei.fang@oss.nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-07-27net: enetc: remove redundant num_vsi field from enetc_port_capsWei Fang
The num_vsi field in struct enetc_port_caps is populated by reading the NUM_VSI field of the ECAPR1 register, which reports the number of VSIs supported by the ENETC4 port. When CONFIG_PCI_IOV is enabled, this value always matches pf->total_vfs, which is obtained from the read-only PCI_SRIOV_TOTAL_VF register via pci_sriov_get_totalvfs() during probe. Both ECAPR1[NUM_VSI] and PCI_SRIOV_TOTAL_VF are derived from the same IERB register EaVFRIDAR[NUM_VF] (a 4-bit field), so they are guaranteed to be equal. When CONFIG_PCI_IOV is disabled, pci_sriov_get_totalvfs() returns 0, but this is benign since pci_enable_sriov() is also stubbed to return -ENODEV, so no VF can be created, and enetc4_enable_all_si() only enables the PF SI (PSI). Since pf->total_vfs already reflects the number of VFs that can actually be used, and is the established convention in the sibling FSL_ENETC PF driver, there is no need to read and cache num_vsi separately in the port capabilities structure. Remove the num_vsi field from enetc_port_caps, and replace all uses of pf->caps.num_vsi with pf->total_vfs in the ring allocation, SI enable, and debugfs code paths. Note that in the MSI-X configuration, it is still necessary to obtain the actual number of VSIs from ECAPR1. Signed-off-by: Wei Fang <wei.fang@nxp.com> Link: https://patch.msgid.link/20260720014317.1059359-13-wei.fang@oss.nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-07-27net: enetc: move enetc_set_si_vlan_promisc() to enetc_pf_common.cWei Fang
The PSIPVMR in ENETC v4 has the same bit layout and functionality as the PSIPVMR register in ENETC v1: bit n (n <= 15) controls VLAN promiscuous mode for SI n. The only difference between the two hardware generations is the register address offset. Since the register functionality is identical, the VLAN promiscuous mode setting code can be shared between ENETC v1 and v4 drivers. Move enetc_set_si_vlan_promisc() from enetc_pf.c to enetc_pf_common.c and export it so that it can be shared between the two drivers. Add a revision check using is_enetc_rev1() to select the correct register offset (ENETC_PSIPVMR for v1 and ENETC4_PSIPVMR for v4) while keeping the same logic. Remove the v4-specific enetc4_pf_set_si_vlan_promisc() from enetc4_pf.c and replace its call site with the new common enetc_set_si_vlan_promisc() to eliminate code duplication. Signed-off-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Joe Damato <joe@dama.to> Link: https://patch.msgid.link/20260720014317.1059359-12-wei.fang@oss.nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-07-27net: enetc: refactor SI VLAN promiscuous mode configurationWei Fang
Remove the enetc_set_vlan_promisc(), enetc_enable_si_vlan_promisc() and enetc_disable_si_vlan_promisc() functions, and introduce a new unified function enetc_set_si_vlan_promisc() to enable or disable VLAN promiscuous mode for a specific SI. This simplifies the logic and makes the interface more straightforward. The vlan_promisc_simap field in struct enetc_pf is no longer needed to track the current state. As ENETC V4 only changes the address offset of PSIPVMR register compared to V1 without any functional difference, enetc_set_si_vlan_promisc() can be moved to enetc_pf_common.c in the future with minor adjustments to be reused by the ENETC V4 driver Signed-off-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Joe Damato <joe@dama.to> Link: https://patch.msgid.link/20260720014317.1059359-11-wei.fang@oss.nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-07-27net: enetc: open-code enetc4_set_default_si_vlan_promisc()Wei Fang
The function enetc4_set_default_si_vlan_promisc() is only called once, from enetc4_configure_port_si(). Open-code the loop at the call site and remove the single-use wrapper. Signed-off-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Joe Damato <joe@dama.to> Link: https://patch.msgid.link/20260720014317.1059359-10-wei.fang@oss.nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-07-27net: enetc: remove invalid code from enetc4_pl_mac_link_up()Wei Fang
When adding phylink MAC operations support to the NETC switch driver, Russell King pointed out several pieces of invalid logic in the .mac_link_up() implementation (see [1] and [2]): 1) Half-duplex backpressure is not supported by the kernel, Ethernet relies on packet dropping for congestion management. 2) phylink_autoneg_inband() is unnecessary, as RGMII in-band status is not supported. 3) TX and RX pause are disabled in half-duplex mode, so there is no need to override them in .mac_link_up(). The same invalid logic is also present in enetc4_pl_mac_link_up(), so remove the invalid code from it. Given enetc4_set_hd_flow_control() is removed, pf->caps.half_duplex has also become useless and should therefore be removed as well. Link: https://lore.kernel.org/imx/acEIQqI-_oyCym8O@shell.armlinux.org.uk/ # 1 Link: https://lore.kernel.org/imx/acEFwqmAvWls_9Ef@shell.armlinux.org.uk/ # 2 Signed-off-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com> Link: https://patch.msgid.link/20260720014317.1059359-9-wei.fang@oss.nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-07-27net: enetc: differentiate phylink capabilities for pseudo-MAC and standalone MACClaudiu Manoil
The ENETC pseudo-MACs are proprietary internal links that do not implement any standard MII interface, so restrict their supported PHY interface modes to PHY_INTERFACE_MODE_INTERNAL only. Since pseudo-MACs can operate at any speed between 10Mbps and 25Gbps in multiples of 10Mbps, set their MAC capabilities to cover the full range of standard full-duplex speeds: 10/100/1000/2500/5000/10000/ 20000/25000 Mbps. For standalone ENETC (v4), expand the supported interface modes to include 10GBASER in addition to the existing RGMII, SGMII, 1000BASEX, 2500BASEX and USXGMII modes, with MAC capabilities up to 10G. MAC_1000 is replaced with MAC_1000FD to explicitly exclude 1000M half-duplex, which is not supported. Note that 10GBASE-R mode of ENETC v4 has not supported yet, the current patch adds PHY_INTERFACE_MODE_10GBASER simply as preparation for the upcoming support of the 10GBASE-R mode. Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com> Signed-off-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com> Link: https://patch.msgid.link/20260720014317.1059359-8-wei.fang@oss.nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-07-27net: enetc: simplify enetc4_set_port_speed()Wei Fang
Since phylink may pass SPEED_UNKNOWN to mac_link_up, handle it explicitly by defaulting to SPEED_10, then replace the switch statement with a direct call to PCR_PSPEED_VAL(). Also update PCR_PSPEED_VAL() to use FIELD_PREP() for proper field masking instead of an open-coded shift. Signed-off-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com> Link: https://patch.msgid.link/20260720014317.1059359-7-wei.fang@oss.nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-07-27net: enetc: use PCI device name for debugfs directoryWei Fang
enetc_create_debugfs() is called right after register_netdev(), at which point ndev->name still holds the format "eth%d" (e.g., eth0) rather than the final assigned name (e.g., via udev rules). Use pci_name() instead of netdev_name() to name the debugfs directory. The PCI device name is unique, stable, and available from the start, making it a more reliable identifier for the debugfs entry. Therefore, the observable debugfs path from something like /sys/kernel/debug/eth0/mac_filter to a PCI BDF-style path such as /sys/kernel/debug/0002:00:00.0/mac_filter. Signed-off-by: Wei Fang <wei.fang@nxp.com> Reviewed-by: Joe Damato <joe@dama.to> Link: https://patch.msgid.link/20260720014317.1059359-6-wei.fang@oss.nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-07-27net: enetc: improve MAFT entry management with bitmap trackingWei Fang
Replace the counter-based MAFT entry tracking (num_mfe/mac_filter_num) with a bitmap (maft_eid_bitmap) stored in struct ntmp_user, which is a more appropriate place for NTMP resource management. The bitmap approach brings two improvements. First, the entry deletion in enetc4_pf_clear_maft_entries() now checks the return value of ntmp_maft_delete_entry() and only clears the corresponding bit on success, keeping hardware and software state in sync. Previously, the counter was reset unconditionally regardless of whether the hardware deletion actually succeeded. Second, entry allocation in enetc4_pf_add_maft_entries() uses ntmp_lookup_free_eid() to find available IDs dynamically, with an upfront capacity check via bitmap_weight() to avoid partial failures. The MAFT entry count is moved into ntmp_user.maft_num_entries and initialized once during enetc4_init_ntmp_user(). Helper functions enetc4_ntmp_bitmap_init() and enetc4_ntmp_bitmap_free() manage the bitmap lifetime. The debugfs show function is updated accordingly to iterate over set bits under rtnl_lock(). Signed-off-by: Wei Fang <wei.fang@nxp.com> Link: https://patch.msgid.link/20260720014317.1059359-5-wei.fang@oss.nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-07-27net: enetc: convert ndo_set_rx_mode() to ndo_set_rx_mode_async()Wei Fang
The current ndo_set_rx_mode() is called under netif_addr_lock spinlock with BHs disabled, which prevents drivers from sleeping. To work around this limitation, the enetc driver uses a dedicated workqueue to defer MAC address list updates to a sleepable context. Since commit 3554b4345d85 ("net: introduce ndo_set_rx_mode_async and netdev_rx_mode_work") introduced the ndo_set_rx_mode_async() callback, drivers can now handle address list updates directly in a sleepable context. Therefore, convert the enetc driver to use ndo_set_rx_mode_async() and remove the dedicated workqueue and the deferred work item accordingly. Signed-off-by: Wei Fang <wei.fang@nxp.com> Link: https://patch.msgid.link/20260720014317.1059359-4-wei.fang@oss.nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>