]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
net: xilinx: Reject broadcast and multicast packets in AXI Ethernet MAC
authorMichal Simek <michal.simek@amd.com>
Mon, 23 Mar 2026 16:09:15 +0000 (17:09 +0100)
committerMichal Simek <michal.simek@amd.com>
Thu, 23 Apr 2026 09:49:48 +0000 (11:49 +0200)
Set the XAE_RAF_BCSTREJ_MASK bit in the Reset and Address Filter (RAF)
register during hardware initialization to make the MAC drop incoming
frames with broadcast destination address. This avoids unnecessary
broadcast traffic processing by the CPU.

Additionally, when IPv6 is not enabled (CONFIG_IPV6), also set the
XAE_RAF_MCSTREJ_MASK bit to reject multicast frames. Multicast
rejection is skipped when IPv6 is configured because IPv6 Neighbor
Discovery and DHCPv6 rely on multicast.

Expose the RAF register (offset 0x0) in struct axi_regs which was
previously hidden in a reserved array.

Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/07ad94eb8a3a9d80273a16a7ac8c7caaba607fe2.1774282153.git.michal.simek@amd.com
drivers/net/xilinx_axi_emac.c

index e9cc5db52d25c60739bbfc73335a556a3093953e..1ea81fe1830a686512b717bd1a92b35097bd5844 100644 (file)
 #define XAE_EMMC_LINKSPD_100   0x40000000 /* Link Speed mask for 100 Mbit */
 #define XAE_EMMC_LINKSPD_1000  0x80000000 /* Link Speed mask for 1000 Mbit */
 
+/* Reset and Address Filter (RAF) Register bit definitions */
+#define XAE_RAF_MCSTREJ_MASK   0x00000002 /* Reject rx multicast dst addr */
+#define XAE_RAF_BCSTREJ_MASK   0x00000004 /* Reject rx broadcast dst addr */
+
 /* Interrupt Status/Enable/Mask Registers bit definitions */
 #define XAE_INT_RXRJECT_MASK   0x00000008 /* Rx frame rejected */
 #define XAE_INT_MGTRDY_MASK    0x00000080 /* MGT clock Lock */
@@ -153,7 +157,8 @@ static struct axidma_bd tx_bd __attribute((aligned(DMAALIGN)));
 static struct axidma_bd rx_bd __attribute((aligned(DMAALIGN)));
 
 struct axi_regs {
-       u32 reserved[3];
+       u32 raf; /* 0x0: Reset and Address Filter */
+       u32 reserved[2];
        u32 is; /* 0xC: Interrupt status */
        u32 reserved2;
        u32 ie; /* 0x14: Interrupt enable */
@@ -528,6 +533,19 @@ static int axi_ethernet_init(struct axidma_priv *priv)
        /* Set default MDIO divisor */
        writel(XAE_MDIO_DIV_DFT | XAE_MDIO_MC_MDIOEN_MASK, &regs->mdio_mc);
 
+       /*
+        * Reject broadcast and multicast frames at MAC level to reduce
+        * unnecessary traffic processing. Multicast rejection is only
+        * enabled when IPv6 is not configured because IPv6 Neighbor
+        * Discovery and DHCPv6 rely on multicast.
+        */
+       if (!IS_ENABLED(CONFIG_IPV6))
+               writel(readl(&regs->raf) | XAE_RAF_MCSTREJ_MASK |
+                      XAE_RAF_BCSTREJ_MASK, &regs->raf);
+       else
+               writel(readl(&regs->raf) | XAE_RAF_BCSTREJ_MASK,
+                      &regs->raf);
+
        debug("axiemac: InitHw done\n");
        return 0;
 }