Commit 24ab724f authored by Ioana Ciornei's avatar Ioana Ciornei Committed by David S. Miller

dpaa2-switch: use the port index in the IRQ handler

The MC firmware supplies us the switch interface index for which an
interrupt was triggered. Use this to our advantage instead of looping
through all the switch ports and doing unnecessary work.
Signed-off-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1ca6cf5e
...@@ -594,7 +594,7 @@ static int dpaa2_switch_port_change_mtu(struct net_device *netdev, int mtu) ...@@ -594,7 +594,7 @@ static int dpaa2_switch_port_change_mtu(struct net_device *netdev, int mtu)
return 0; return 0;
} }
static int dpaa2_switch_port_carrier_state_sync(struct net_device *netdev) static int dpaa2_switch_port_link_state_update(struct net_device *netdev)
{ {
struct ethsw_port_priv *port_priv = netdev_priv(netdev); struct ethsw_port_priv *port_priv = netdev_priv(netdev);
struct dpsw_link_state state; struct dpsw_link_state state;
...@@ -693,10 +693,10 @@ static int dpaa2_switch_port_open(struct net_device *netdev) ...@@ -693,10 +693,10 @@ static int dpaa2_switch_port_open(struct net_device *netdev)
} }
/* sync carrier state */ /* sync carrier state */
err = dpaa2_switch_port_carrier_state_sync(netdev); err = dpaa2_switch_port_link_state_update(netdev);
if (err) { if (err) {
netdev_err(netdev, netdev_err(netdev,
"dpaa2_switch_port_carrier_state_sync err %d\n", err); "dpaa2_switch_port_link_state_update err %d\n", err);
goto err_carrier_sync; goto err_carrier_sync;
} }
...@@ -1419,22 +1419,13 @@ bool dpaa2_switch_port_dev_check(const struct net_device *netdev) ...@@ -1419,22 +1419,13 @@ bool dpaa2_switch_port_dev_check(const struct net_device *netdev)
return netdev->netdev_ops == &dpaa2_switch_port_ops; return netdev->netdev_ops == &dpaa2_switch_port_ops;
} }
static void dpaa2_switch_links_state_update(struct ethsw_core *ethsw)
{
int i;
for (i = 0; i < ethsw->sw_attr.num_ifs; i++) {
dpaa2_switch_port_carrier_state_sync(ethsw->ports[i]->netdev);
dpaa2_switch_port_set_mac_addr(ethsw->ports[i]);
}
}
static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg) static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg)
{ {
struct device *dev = (struct device *)arg; struct device *dev = (struct device *)arg;
struct ethsw_core *ethsw = dev_get_drvdata(dev); struct ethsw_core *ethsw = dev_get_drvdata(dev);
struct ethsw_port_priv *port_priv;
u32 status = ~0; u32 status = ~0;
int err; int err, if_id;
err = dpsw_get_irq_status(ethsw->mc_io, 0, ethsw->dpsw_handle, err = dpsw_get_irq_status(ethsw->mc_io, 0, ethsw->dpsw_handle,
DPSW_IRQ_INDEX_IF, &status); DPSW_IRQ_INDEX_IF, &status);
...@@ -1443,9 +1434,13 @@ static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg) ...@@ -1443,9 +1434,13 @@ static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg)
goto out; goto out;
} }
if (status & DPSW_IRQ_EVENT_LINK_CHANGED) if_id = (status & 0xFFFF0000) >> 16;
dpaa2_switch_links_state_update(ethsw); port_priv = ethsw->ports[if_id];
if (status & DPSW_IRQ_EVENT_LINK_CHANGED) {
dpaa2_switch_port_link_state_update(port_priv->netdev);
dpaa2_switch_port_set_mac_addr(port_priv);
}
out: out:
err = dpsw_clear_irq_status(ethsw->mc_io, 0, ethsw->dpsw_handle, err = dpsw_clear_irq_status(ethsw->mc_io, 0, ethsw->dpsw_handle,
DPSW_IRQ_INDEX_IF, status); DPSW_IRQ_INDEX_IF, status);
......
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