All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ioana Ciornei <ciorneiioana@gmail.com>
To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org
Cc: laurentiu.tudor@nxp.com, Ioana Ciornei <ioana.ciornei@nxp.com>
Subject: [PATCH net-next 2/8] dpaa2-switch: use the port index in the IRQ handler
Date: Tue,  3 Aug 2021 19:57:39 +0300	[thread overview]
Message-ID: <20210803165745.138175-3-ciorneiioana@gmail.com> (raw)
In-Reply-To: <20210803165745.138175-1-ciorneiioana@gmail.com>

From: Ioana Ciornei <ioana.ciornei@nxp.com>

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: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 .../ethernet/freescale/dpaa2/dpaa2-switch.c   | 27 ++++++++-----------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index 42d31a4a7da6..f8b7601dc9e4 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -594,7 +594,7 @@ static int dpaa2_switch_port_change_mtu(struct net_device *netdev, int mtu)
 	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 dpsw_link_state state;
@@ -693,10 +693,10 @@ static int dpaa2_switch_port_open(struct net_device *netdev)
 	}
 
 	/* sync carrier state */
-	err = dpaa2_switch_port_carrier_state_sync(netdev);
+	err = dpaa2_switch_port_link_state_update(netdev);
 	if (err) {
 		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;
 	}
 
@@ -1419,22 +1419,13 @@ bool dpaa2_switch_port_dev_check(const struct net_device *netdev)
 	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)
 {
 	struct device *dev = (struct device *)arg;
 	struct ethsw_core *ethsw = dev_get_drvdata(dev);
+	struct ethsw_port_priv *port_priv;
 	u32 status = ~0;
-	int err;
+	int err, if_id;
 
 	err = dpsw_get_irq_status(ethsw->mc_io, 0, ethsw->dpsw_handle,
 				  DPSW_IRQ_INDEX_IF, &status);
@@ -1443,9 +1434,13 @@ static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg)
 		goto out;
 	}
 
-	if (status & DPSW_IRQ_EVENT_LINK_CHANGED)
-		dpaa2_switch_links_state_update(ethsw);
+	if_id = (status & 0xFFFF0000) >> 16;
+	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:
 	err = dpsw_clear_irq_status(ethsw->mc_io, 0, ethsw->dpsw_handle,
 				    DPSW_IRQ_INDEX_IF, status);
-- 
2.31.1


  parent reply	other threads:[~2021-08-03 16:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-03 16:57 [PATCH net-next 0/8] dpaa2-switch: integrate the MAC endpoint support Ioana Ciornei
2021-08-03 16:57 ` [PATCH net-next 1/8] dpaa2-switch: request all interrupts sources on the DPSW Ioana Ciornei
2021-08-03 16:57 ` Ioana Ciornei [this message]
2021-08-03 16:57 ` [PATCH net-next 3/8] dpaa2-switch: do not enable the DPSW at probe time Ioana Ciornei
2021-08-03 16:57 ` [PATCH net-next 4/8] dpaa2-switch: no need to check link state right after ndo_open Ioana Ciornei
2021-08-03 16:57 ` [PATCH net-next 5/8] bus: fsl-mc: extend fsl_mc_get_endpoint() to pass interface ID Ioana Ciornei
2021-08-03 16:57 ` [PATCH net-next 6/8] dpaa2-switch: integrate the MAC endpoint support Ioana Ciornei
2021-08-03 16:57 ` [PATCH net-next 7/8] dpaa2-switch: add a prefix to HW ethtool stats Ioana Ciornei
2021-08-03 16:57 ` [PATCH net-next 8/8] dpaa2-switch: export MAC statistics in ethtool Ioana Ciornei
2021-08-04  9:00 ` [PATCH net-next 0/8] dpaa2-switch: integrate the MAC endpoint support patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210803165745.138175-3-ciorneiioana@gmail.com \
    --to=ciorneiioana@gmail.com \
    --cc=davem@davemloft.net \
    --cc=ioana.ciornei@nxp.com \
    --cc=kuba@kernel.org \
    --cc=laurentiu.tudor@nxp.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.