mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Justin Lai <justinlai0215@realtek.com>
To: <kuba@kernel.org>
Cc: <davem@davemloft.net>, <edumazet@google.com>, <pabeni@redhat.com>,
	<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
	<andrew@lunn.ch>, <jiri@resnulli.us>, <horms@kernel.org>,
	<rkannoth@marvell.com>, <jdamato@fastly.com>,
	<pkshih@realtek.com>, <larry.chiu@realtek.com>,
	"Justin Lai" <justinlai0215@realtek.com>
Subject: [PATCH net-next v22 04/13] rtase: Implement the interrupt routine and rtase_poll
Date: Mon, 1 Jul 2024 19:53:54 +0800	[thread overview]
Message-ID: <20240701115403.7087-5-justinlai0215@realtek.com> (raw)
In-Reply-To: <20240701115403.7087-1-justinlai0215@realtek.com>

1. Implement rtase_interrupt to handle txQ0/rxQ0, txQ4~txQ7 interrupts,
and implement rtase_q_interrupt to handle txQ1/rxQ1, txQ2/rxQ2 and
txQ3/rxQ3 interrupts.
2. Implement rtase_poll to call ring_handler to process the tx or
rx packet of each ring. If the returned value is budget,it means that
there is still work of a certain ring that has not yet been completed.

Signed-off-by: Justin Lai <justinlai0215@realtek.com>
---
 .../net/ethernet/realtek/rtase/rtase_main.c   | 88 +++++++++++++++++++
 1 file changed, 88 insertions(+)

diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c b/drivers/net/ethernet/realtek/rtase/rtase_main.c
index ef0b4ff5db7c..e65f53f01bce 100755
--- a/drivers/net/ethernet/realtek/rtase/rtase_main.c
+++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c
@@ -584,6 +584,75 @@ static void rtase_hw_start(const struct net_device *dev)
 	rtase_enable_hw_interrupt(tp);
 }
 
+/*  the interrupt handler does RXQ0 and TXQ0, TXQ4~7 interrutp status
+ */
+static irqreturn_t rtase_interrupt(int irq, void *dev_instance)
+{
+	const struct rtase_private *tp;
+	struct rtase_int_vector *ivec;
+	u32 status;
+
+	ivec = dev_instance;
+	tp = ivec->tp;
+	status = rtase_r32(tp, ivec->isr_addr);
+
+	rtase_w32(tp, ivec->imr_addr, 0x0);
+	rtase_w32(tp, ivec->isr_addr, status & ~RTASE_FOVW);
+
+	if (napi_schedule_prep(&ivec->napi))
+		__napi_schedule(&ivec->napi);
+
+	return IRQ_HANDLED;
+}
+
+/*  the interrupt handler does RXQ1&TXQ1 or RXQ2&TXQ2 or RXQ3&TXQ3 interrupt
+ *  status according to interrupt vector
+ */
+static irqreturn_t rtase_q_interrupt(int irq, void *dev_instance)
+{
+	const struct rtase_private *tp;
+	struct rtase_int_vector *ivec;
+	u16 status;
+
+	ivec = dev_instance;
+	tp = ivec->tp;
+	status = rtase_r16(tp, ivec->isr_addr);
+
+	rtase_w16(tp, ivec->imr_addr, 0x0);
+	rtase_w16(tp, ivec->isr_addr, status);
+
+	if (napi_schedule_prep(&ivec->napi))
+		__napi_schedule(&ivec->napi);
+
+	return IRQ_HANDLED;
+}
+
+static int rtase_poll(struct napi_struct *napi, int budget)
+{
+	const struct rtase_int_vector *ivec;
+	const struct rtase_private *tp;
+	struct rtase_ring *ring;
+	int total_workdone = 0;
+
+	ivec = container_of(napi, struct rtase_int_vector, napi);
+	tp = ivec->tp;
+
+	list_for_each_entry(ring, &ivec->ring_list, ring_entry)
+		total_workdone += ring->ring_handler(ring, budget);
+
+	if (total_workdone >= budget)
+		return budget;
+
+	if (napi_complete_done(napi, total_workdone)) {
+		if (!ivec->index)
+			rtase_w32(tp, ivec->imr_addr, ivec->imr);
+		else
+			rtase_w16(tp, ivec->imr_addr, ivec->imr);
+	}
+
+	return total_workdone;
+}
+
 static int rtase_open(struct net_device *dev)
 {
 	struct rtase_private *tp = netdev_priv(dev);
@@ -729,9 +798,28 @@ static void rtase_rar_set(const struct rtase_private *tp, const u8 *addr)
 	rtase_w16(tp, RTASE_LBK_CTRL, RTASE_LBK_ATLD | RTASE_LBK_CLR);
 }
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+/* Polling 'interrupt' - used by things like netconsole to send skbs
+ * without having to re-enable interrupts. It's not called while
+ * the interrupt routine is executing.
+ */
+static void rtase_netpoll(struct net_device *dev)
+{
+	const struct rtase_private *tp = netdev_priv(dev);
+	const struct pci_dev *pdev = tp->pdev;
+
+	disable_irq(pdev->irq);
+	rtase_interrupt(pdev->irq, dev);
+	enable_irq(pdev->irq);
+}
+#endif
+
 static const struct net_device_ops rtase_netdev_ops = {
 	.ndo_open = rtase_open,
 	.ndo_stop = rtase_close,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+	.ndo_poll_controller = rtase_netpoll,
+#endif
 };
 
 static void rtase_get_mac_address(struct net_device *dev)
-- 
2.34.1


  parent reply	other threads:[~2024-07-01 11:56 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-01 11:53 [PATCH net-next v22 00/13] Add Realtek automotive PCIe driver Justin Lai
2024-07-01 11:53 ` [PATCH net-next v22 01/13] rtase: Add support for a pci table in this module Justin Lai
2024-07-02 16:48   ` Simon Horman
2024-07-03 17:07     ` Simon Horman
2024-07-01 11:53 ` [PATCH net-next v22 02/13] rtase: Implement the .ndo_open function Justin Lai
2024-07-03 16:52   ` Simon Horman
2024-07-01 11:53 ` [PATCH net-next v22 03/13] rtase: Implement the rtase_down function Justin Lai
2024-07-03 16:59   ` Simon Horman
2024-07-01 11:53 ` Justin Lai [this message]
2024-07-03 17:00   ` [PATCH net-next v22 04/13] rtase: Implement the interrupt routine and rtase_poll Simon Horman
2024-07-01 11:53 ` [PATCH net-next v22 05/13] rtase: Implement hardware configuration function Justin Lai
2024-07-03 17:01   ` Simon Horman
2024-07-01 11:53 ` [PATCH net-next v22 06/13] rtase: Implement .ndo_start_xmit function Justin Lai
2024-07-03 17:02   ` Simon Horman
2024-07-01 11:53 ` [PATCH net-next v22 07/13] rtase: Implement a function to receive packets Justin Lai
2024-07-03 17:02   ` Simon Horman
2024-07-01 11:53 ` [PATCH net-next v22 08/13] rtase: Implement net_device_ops Justin Lai
2024-07-03 17:03   ` Simon Horman
2024-07-03 17:04   ` Simon Horman
2024-07-01 11:53 ` [PATCH net-next v22 09/13] rtase: Implement pci_driver suspend and resume function Justin Lai
2024-07-03 17:04   ` Simon Horman
2024-07-01 11:54 ` [PATCH net-next v22 10/13] rtase: Implement ethtool function Justin Lai
2024-07-03 17:05   ` Simon Horman
2024-07-01 11:54 ` [PATCH net-next v22 11/13] rtase: Add a Makefile in the rtase folder Justin Lai
2024-07-03 17:05   ` Simon Horman
2024-07-01 11:54 ` [PATCH net-next v22 12/13] realtek: Update the Makefile and Kconfig in the realtek folder Justin Lai
2024-07-03 17:06   ` Simon Horman
2024-07-01 11:54 ` [PATCH net-next v22 13/13] MAINTAINERS: Add the rtase ethernet driver entry Justin Lai
2024-07-03 17:06   ` Simon Horman
2024-07-09 12:11 ` [PATCH net-next v22 00/13] Add Realtek automotive PCIe driver Simon Horman

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=20240701115403.7087-5-justinlai0215@realtek.com \
    --to=justinlai0215@realtek.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jdamato@fastly.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=larry.chiu@realtek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pkshih@realtek.com \
    --cc=rkannoth@marvell.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®