Commit a9999732 authored by MD Danish Anwar's avatar MD Danish Anwar Committed by David S. Miller

net: ti: icssg-prueth: Add multicast filtering support

Add multicast filtering support for ICSSG Driver. Multicast addresses will
be updated by __dev_mc_sync() API. icssg_prueth_add_macst () and
icssg_prueth_del_mcast() will be sync and unsync APIs for the driver
respectively.

To add a mac_address for a port, driver needs to call icssg_fdb_add_del()
and pass the mac_address and BIT(port_id) to the API. The ICSSG firmware
will then configure the rules and allow filtering.

If a mac_address is added to port0 and the same mac_address needs to be
added for port1, driver needs to pass BIT(port0) | BIT(port1) to the
icssg_fdb_add_del() API. If driver just pass BIT(port1) then the entry for
port0 will be overwritten / lost. This is a design constraint on the
firmware side.

To overcome this in the driver, to add any mac_address for let's say portX
driver first checks if the same mac_address is already added for any other
port. If yes driver calls icssg_fdb_add_del() with BIT(portX) |
BIT(other_existing_port). If not, driver calls icssg_fdb_add_del() with
BIT(portX).

The same thing is applicable for deleting mac_addresses as well. This
logic is in icssg_prueth_add_mcast / icssg_prueth_del_mcast APIs.
Signed-off-by: default avatarMD Danish Anwar <danishanwar@ti.com>
Reviewed-by: default avatarWojciech Drewek <wojciech.drewek@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cb6cf082
......@@ -439,6 +439,37 @@ const struct icss_iep_clockops prueth_iep_clockops = {
.perout_enable = prueth_perout_enable,
};
static int icssg_prueth_add_mcast(struct net_device *ndev, const u8 *addr)
{
struct prueth_emac *emac = netdev_priv(ndev);
int port_mask = BIT(emac->port_id);
port_mask |= icssg_fdb_lookup(emac, addr, 0);
icssg_fdb_add_del(emac, addr, 0, port_mask, true);
icssg_vtbl_modify(emac, 0, port_mask, port_mask, true);
return 0;
}
static int icssg_prueth_del_mcast(struct net_device *ndev, const u8 *addr)
{
struct prueth_emac *emac = netdev_priv(ndev);
int port_mask = BIT(emac->port_id);
int other_port_mask;
other_port_mask = port_mask ^ icssg_fdb_lookup(emac, addr, 0);
icssg_fdb_add_del(emac, addr, 0, port_mask, false);
icssg_vtbl_modify(emac, 0, port_mask, port_mask, false);
if (other_port_mask) {
icssg_fdb_add_del(emac, addr, 0, other_port_mask, true);
icssg_vtbl_modify(emac, 0, other_port_mask, other_port_mask, true);
}
return 0;
}
/**
* emac_ndo_open - EMAC device open
* @ndev: network adapter device
......@@ -599,6 +630,8 @@ static int emac_ndo_stop(struct net_device *ndev)
icssg_class_disable(prueth->miig_rt, prueth_emac_slice(emac));
__dev_mc_unsync(ndev, icssg_prueth_del_mcast);
atomic_set(&emac->tdown_cnt, emac->tx_ch_num);
/* ensure new tdown_cnt value is visible */
smp_mb__after_atomic();
......@@ -675,10 +708,7 @@ static void emac_ndo_set_rx_mode_work(struct work_struct *work)
return;
}
if (!netdev_mc_empty(ndev)) {
emac_set_port_state(emac, ICSSG_EMAC_PORT_MC_FLOODING_ENABLE);
return;
}
__dev_mc_sync(ndev, icssg_prueth_add_mcast, icssg_prueth_del_mcast);
}
/**
......
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