Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp470882rdb; Thu, 2 Nov 2023 08:46:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG7D4RMtUvGoThfD9KB/5wnos0M2U2WD7lg5V9rbZ7ZeyZZk06v1zpaBJbC4YyAydjrxxcn X-Received: by 2002:a05:6a00:1504:b0:6be:5a1a:3bb8 with SMTP id q4-20020a056a00150400b006be5a1a3bb8mr23333822pfu.28.1698940001574; Thu, 02 Nov 2023 08:46:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698940001; cv=none; d=google.com; s=arc-20160816; b=pPSqOHvSKR/z42Ux7DfSmaujh1c/QhzhQ9TMkuV0dNuYChRp1CosTlx34y8TpE9UHx CaLn5LLb6EsS0QPUrQ8poYAoNxN8QXR9Wok/vs7eEi8P2uNOlyvR2vpFuIb1buNVjI3C r4V7PpY+y791dioo7D9ZB2z3TkSOhG8aLHv6pyjPoTZMviZE7JmYctCV68Hcne99jbHZ 1SQM5Pdnxy9Ye5vr609tfyv/4niK6m3NfX1aZvubVsw3cxxYL1E13mOfwrTMqztEJmbT JEKkFK8AwwC98O6/zuoJZHzFlKroffQnj83YfHuTe0/bV5DAx3vAV+mX6/YIr4mZZxVn hfNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=15FCAQiGKeBbVx+BX3zagqnBS8KuCep9P6xmFb+7TB4=; fh=J4St9tMjBInT3r1VVHSF1O7f2qS3KxSaZBHCVggmRHk=; b=SiZ/ZTzcdB/MuT1RiRPQvMX+zvsUZsrB5MPxQufvHx6pS5mTR+CxLdQQ56kJxGRhvz 5MOS1wsRlcJ8S9yI/bBIVgJGLq/lBNrQX9XfLTMdJS23SZAE/7me7TKLpWej80K4MYW+ aJYwW2tcJGj1RYGJEIYKaTmFKjvRu8CB/RWnY11xhS1ohxGBIGReMnggupdq6nr0IPvS sx1mj2xeGEY7IUKF2jn8wr2tITYf5DUyN7NUyt6S9yuSNpQF6PJ7QfTtBkM/KExHx1Xv 0A9FSRNY/oLYdpOtD9TzwII0hir/jNXBBtl+N41lXoOVI4vZZIYAcdAwHDEO3kxhhdL4 aJ4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id t21-20020aa78f95000000b006c339f9f3a1si26169pfs.240.2023.11.02.08.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 08:46:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 22A79827C193; Thu, 2 Nov 2023 08:46:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377024AbjKBPqL (ORCPT + 99 others); Thu, 2 Nov 2023 11:46:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376853AbjKBPpr (ORCPT ); Thu, 2 Nov 2023 11:45:47 -0400 Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 092A618C; Thu, 2 Nov 2023 08:45:42 -0700 (PDT) X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 3A2FjGXM13125147, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36505.realtek.com.tw[172.21.6.25]) by rtits2.realtek.com.tw (8.15.2/2.95/5.92) with ESMTPS id 3A2FjGXM13125147 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Nov 2023 23:45:17 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXH36505.realtek.com.tw (172.21.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.32; Thu, 2 Nov 2023 23:45:17 +0800 Received: from RTDOMAIN (172.21.210.160) by RTEXMBS04.realtek.com.tw (172.21.6.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Thu, 2 Nov 2023 23:45:16 +0800 From: Justin Lai To: CC: , , , , , , , , Justin Lai Subject: [PATCH net-next v10 04/13] net:ethernet:realtek:rtase: Implement the interrupt routine and rtase_poll Date: Thu, 2 Nov 2023 23:44:56 +0800 Message-ID: <20231102154505.940783-5-justinlai0215@realtek.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231102154505.940783-1-justinlai0215@realtek.com> References: <20231102154505.940783-1-justinlai0215@realtek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [172.21.210.160] X-ClientProxiedBy: RTEXH36505.realtek.com.tw (172.21.6.25) To RTEXMBS04.realtek.com.tw (172.21.6.97) X-KSE-ServerInfo: RTEXMBS04.realtek.com.tw, 9 X-KSE-AntiSpam-Interceptor-Info: license violation X-KSE-Antivirus-Attachment-Filter-Interceptor-Info: license violation X-KSE-ServerInfo: RTEXH36505.realtek.com.tw, 9 X-KSE-AntiSpam-Interceptor-Info: fallback X-KSE-Antivirus-Interceptor-Info: fallback X-KSE-AntiSpam-Interceptor-Info: fallback X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 02 Nov 2023 08:46:19 -0700 (PDT) 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 --- .../net/ethernet/realtek/rtase/rtase_main.c | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/drivers/net/ethernet/realtek/rtase/rtase_main.c b/drivers/net/ethernet/realtek/rtase/rtase_main.c index 5719841585bb..968150b2730c 100644 --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c @@ -585,6 +585,76 @@ 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 & ~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); @@ -726,9 +796,28 @@ static void rtase_rar_set(const struct rtase_private *tp, const u8 *addr) rtase_w16(tp, RTASE_LBK_CTRL, LBK_ATLD | 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