diff mbox series

[RFC,net-next,14/28] net: ethernet: ti: cpsw-proxy-client: add and register dma irq handlers

Message ID 20240518124234.2671651-15-s-vadapalli@ti.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series Add CPSW Proxy Client driver | expand

Checks

Context Check Description
netdev/series_format fail Series longer than 15 patches
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 24 this patch: 24
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: linux-omap@vger.kernel.org
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 23 this patch: 23
netdev/checkpatch warning WARNING: line length of 96 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Siddharth Vadapalli May 18, 2024, 12:42 p.m. UTC
Add the function "register_dma_irq_handlers()" to register the TX and RX
DMA Interrupt handlers for all the TX and RX DMA Channels for every Virtual
Port.

Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
---
 drivers/net/ethernet/ti/cpsw-proxy-client.c | 60 +++++++++++++++++++++
 1 file changed, 60 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/ti/cpsw-proxy-client.c b/drivers/net/ethernet/ti/cpsw-proxy-client.c
index 30d53a8e174e..b0f0e5db3a74 100644
--- a/drivers/net/ethernet/ti/cpsw-proxy-client.c
+++ b/drivers/net/ethernet/ti/cpsw-proxy-client.c
@@ -1279,6 +1279,66 @@  static int init_netdevs(struct cpsw_proxy_priv *proxy_priv)
 	return ret;
 }
 
+static irqreturn_t tx_irq_handler(int irq, void *dev_id)
+{
+	struct tx_dma_chan *tx_chn = dev_id;
+
+	disable_irq_nosync(irq);
+	napi_schedule(&tx_chn->napi_tx);
+
+	return IRQ_HANDLED;
+}
+
+static irqreturn_t rx_irq_handler(int irq, void *dev_id)
+{
+	struct rx_dma_chan *rx_chn = dev_id;
+
+	disable_irq_nosync(irq);
+	napi_schedule(&rx_chn->napi_rx);
+
+	return IRQ_HANDLED;
+}
+
+static int register_dma_irq_handlers(struct cpsw_proxy_priv *proxy_priv)
+{
+	struct device *dev = proxy_priv->dev;
+	struct rx_dma_chan *rx_chn;
+	struct tx_dma_chan *tx_chn;
+	struct virtual_port *vport;
+	u32 i, j;
+	int ret;
+
+	for (i = 0; i < proxy_priv->num_virt_ports; i++) {
+		vport = &proxy_priv->virt_ports[i];
+
+		for (j = 0; j < vport->num_tx_chan; j++) {
+			tx_chn = &vport->tx_chans[j];
+
+			ret = devm_request_irq(dev, tx_chn->irq, tx_irq_handler,
+					       IRQF_TRIGGER_HIGH, tx_chn->tx_chan_name, tx_chn);
+			if (ret) {
+				dev_err(dev, "failed to request tx irq: %u, err: %d\n",
+					tx_chn->irq, ret);
+				return ret;
+			}
+		}
+
+		for (j = 0; j < vport->num_rx_chan; j++) {
+			rx_chn = &vport->rx_chans[j];
+
+			ret = devm_request_irq(dev, rx_chn->irq, rx_irq_handler,
+					       IRQF_TRIGGER_HIGH, rx_chn->rx_chan_name, rx_chn);
+			if (ret) {
+				dev_err(dev, "failed to request rx irq: %u, err: %d\n",
+					rx_chn->irq, ret);
+				return ret;
+			}
+		}
+	}
+
+	return 0;
+}
+
 static int cpsw_proxy_client_probe(struct rpmsg_device *rpdev)
 {
 	struct cpsw_proxy_priv *proxy_priv;