Commit 7888173e authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'net-xilinx-axienet-multicast-fixes-and-improvements'

Sean Anderson says:

====================
net: xilinx: axienet: Multicast fixes and improvements

This series has a few small patches improving the handling of multicast
addresses. In particular, it makes the driver a whole lot less spammy,
and adjusts things so we aren't in promiscuous mode when we have more
than four multicast addresses (a common occurance on modern systems).

As the hardware has a 4-entry CAM, the ideal method would be to "pack"
multiple addresses into one CAM entry. Something like:

entry.address = address[0] | address[1];
entry.mask = ~(address[0] ^ address[1]);

Which would make the entry match both addresses (along with some others
that would need to be filtered in software).

Mapping addresses to entries in an efficient way is a bit tricky. If
anyone knows of an in-tree example of something like this, I'd be glad
to hear about it.
====================

Link: https://patch.msgid.link/20240822154059.1066595-1-sean.anderson@linux.devSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 5efc9623 749e67d5
...@@ -175,6 +175,8 @@ ...@@ -175,6 +175,8 @@
#define XAE_FFE_OFFSET 0x0000070C /* Frame Filter Enable */ #define XAE_FFE_OFFSET 0x0000070C /* Frame Filter Enable */
#define XAE_AF0_OFFSET 0x00000710 /* Address Filter 0 */ #define XAE_AF0_OFFSET 0x00000710 /* Address Filter 0 */
#define XAE_AF1_OFFSET 0x00000714 /* Address Filter 1 */ #define XAE_AF1_OFFSET 0x00000714 /* Address Filter 1 */
#define XAE_AM0_OFFSET 0x00000750 /* Frame Filter Mask Value Bytes 3-0 */
#define XAE_AM1_OFFSET 0x00000754 /* Frame Filter Mask Value Bytes 7-4 */
#define XAE_TX_VLAN_DATA_OFFSET 0x00004000 /* TX VLAN data table address */ #define XAE_TX_VLAN_DATA_OFFSET 0x00004000 /* TX VLAN data table address */
#define XAE_RX_VLAN_DATA_OFFSET 0x00008000 /* RX VLAN data table address */ #define XAE_RX_VLAN_DATA_OFFSET 0x00008000 /* RX VLAN data table address */
......
...@@ -437,24 +437,27 @@ static void axienet_set_multicast_list(struct net_device *ndev) ...@@ -437,24 +437,27 @@ static void axienet_set_multicast_list(struct net_device *ndev)
u32 reg, af0reg, af1reg; u32 reg, af0reg, af1reg;
struct axienet_local *lp = netdev_priv(ndev); struct axienet_local *lp = netdev_priv(ndev);
if (ndev->flags & (IFF_ALLMULTI | IFF_PROMISC) || reg = axienet_ior(lp, XAE_FMI_OFFSET);
netdev_mc_count(ndev) > XAE_MULTICAST_CAM_TABLE_NUM) { reg &= ~XAE_FMI_PM_MASK;
/* We must make the kernel realize we had to move into if (ndev->flags & IFF_PROMISC)
* promiscuous mode. If it was a promiscuous mode request
* the flag is already set. If not we set it.
*/
ndev->flags |= IFF_PROMISC;
reg = axienet_ior(lp, XAE_FMI_OFFSET);
reg |= XAE_FMI_PM_MASK; reg |= XAE_FMI_PM_MASK;
else
reg &= ~XAE_FMI_PM_MASK;
axienet_iow(lp, XAE_FMI_OFFSET, reg);
if (ndev->flags & IFF_ALLMULTI ||
netdev_mc_count(ndev) > XAE_MULTICAST_CAM_TABLE_NUM) {
reg &= 0xFFFFFF00;
axienet_iow(lp, XAE_FMI_OFFSET, reg); axienet_iow(lp, XAE_FMI_OFFSET, reg);
dev_info(&ndev->dev, "Promiscuous mode enabled.\n"); axienet_iow(lp, XAE_AF0_OFFSET, 1); /* Multicast bit */
axienet_iow(lp, XAE_AF1_OFFSET, 0);
axienet_iow(lp, XAE_AM0_OFFSET, 1); /* ditto */
axienet_iow(lp, XAE_AM1_OFFSET, 0);
axienet_iow(lp, XAE_FFE_OFFSET, 1);
i = 1;
} else if (!netdev_mc_empty(ndev)) { } else if (!netdev_mc_empty(ndev)) {
struct netdev_hw_addr *ha; struct netdev_hw_addr *ha;
reg = axienet_ior(lp, XAE_FMI_OFFSET);
reg &= ~XAE_FMI_PM_MASK;
axienet_iow(lp, XAE_FMI_OFFSET, reg);
netdev_for_each_mc_addr(ha, ndev) { netdev_for_each_mc_addr(ha, ndev) {
if (i >= XAE_MULTICAST_CAM_TABLE_NUM) if (i >= XAE_MULTICAST_CAM_TABLE_NUM)
break; break;
...@@ -467,25 +470,21 @@ static void axienet_set_multicast_list(struct net_device *ndev) ...@@ -467,25 +470,21 @@ static void axienet_set_multicast_list(struct net_device *ndev)
af1reg = (ha->addr[4]); af1reg = (ha->addr[4]);
af1reg |= (ha->addr[5] << 8); af1reg |= (ha->addr[5] << 8);
reg = axienet_ior(lp, XAE_FMI_OFFSET) & 0xFFFFFF00; reg &= 0xFFFFFF00;
reg |= i; reg |= i;
axienet_iow(lp, XAE_FMI_OFFSET, reg); axienet_iow(lp, XAE_FMI_OFFSET, reg);
axienet_iow(lp, XAE_AF0_OFFSET, af0reg); axienet_iow(lp, XAE_AF0_OFFSET, af0reg);
axienet_iow(lp, XAE_AF1_OFFSET, af1reg); axienet_iow(lp, XAE_AF1_OFFSET, af1reg);
axienet_iow(lp, XAE_AM0_OFFSET, 0xffffffff);
axienet_iow(lp, XAE_AM1_OFFSET, 0x0000ffff);
axienet_iow(lp, XAE_FFE_OFFSET, 1); axienet_iow(lp, XAE_FFE_OFFSET, 1);
i++; i++;
} }
} else {
reg = axienet_ior(lp, XAE_FMI_OFFSET);
reg &= ~XAE_FMI_PM_MASK;
axienet_iow(lp, XAE_FMI_OFFSET, reg);
dev_info(&ndev->dev, "Promiscuous mode disabled.\n");
} }
for (; i < XAE_MULTICAST_CAM_TABLE_NUM; i++) { for (; i < XAE_MULTICAST_CAM_TABLE_NUM; i++) {
reg = axienet_ior(lp, XAE_FMI_OFFSET) & 0xFFFFFF00; reg &= 0xFFFFFF00;
reg |= i; reg |= i;
axienet_iow(lp, XAE_FMI_OFFSET, reg); axienet_iow(lp, XAE_FMI_OFFSET, reg);
axienet_iow(lp, XAE_FFE_OFFSET, 0); axienet_iow(lp, XAE_FFE_OFFSET, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment