Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1822905rdh; Tue, 26 Sep 2023 04:54:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvOXNiiN4GOjF5WFljgapIJzbdrYALflgXL45RoJ4hUZVhv/oMehJWBWelQcPF2+UwCcab X-Received: by 2002:a05:6830:4803:b0:6bd:d1fc:2f2f with SMTP id dg3-20020a056830480300b006bdd1fc2f2fmr10958838otb.21.1695729285024; Tue, 26 Sep 2023 04:54:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695729284; cv=none; d=google.com; s=arc-20160816; b=n2/fRnBD1YNFYkmnpCaFWwG9fUkJua395S/5h7KzM7GpW1xkoZtGatKXy7OprfsJL4 Lyagq6YMnp/k4LVW+lfl3gYgRl1M530zqivyZnREf4oIA/yRL7pA4gitOaG/HKtag0Q5 DnLJkt/XysOt7KnrIqKVeh958dqtjCz1pE9oUITkyXID6QmmqowWCJpFdHzIF42pkANV wYcmHA4Z23qvqKIXV8h2yXeYHVwuObxlhlxns+Tqms4xzMTgy3xaNnwAtVhxZ6CD97+3 269n5MLhBvR9i83VeyHVA2A4q19UPdBLgP7iTdZ2XbMTubOHti+0voIODo1V1LTLVSQl DVdg== 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=v8UKrUURSNcdVf4MbrxClDKhqtWTBrElxq5fl0/j/lM=; fh=J4St9tMjBInT3r1VVHSF1O7f2qS3KxSaZBHCVggmRHk=; b=ODlyQeu2o4USOZQ+fd2GbRL2XVyy6GmwUMzX8XcgRzJ7YcJEF+ck6YYsPgY+o5vrwY xjFRnyQcYHgiSiN9O+Ol+oJaIrEyw99jyYXbF/Y8nt8GQz7V7oqbrm6EWgfAbHa50XLb n1DIPjdnLZyj7PrVYO3bakSngfHqM0AAEQk1unRuhrpMLlceis15Tqf2qDD1xqlh2C8M MnnIS1agK7hEGS+r6lMp7PSDORDIYG/gG3+HiMBgjBLxWstIjHrED4+5xlPWcBBtffsl QpXS+TjeUl/tw6azyB3OkU1RvQ8IsxhJq/8+AVP1RCe16gCGDtJO1tTFK2myhVMzbw4J VaMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id t185-20020a6381c2000000b005697ed9a47csi11777866pgd.29.2023.09.26.04.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 04:54:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 3FDBA82DE847; Tue, 26 Sep 2023 04:50:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234160AbjIZLuc (ORCPT + 99 others); Tue, 26 Sep 2023 07:50:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233887AbjIZLu3 (ORCPT ); Tue, 26 Sep 2023 07:50:29 -0400 Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BB01101; Tue, 26 Sep 2023 04:50:17 -0700 (PDT) X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 38QBntbF7882020, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36506.realtek.com.tw[172.21.6.27]) by rtits2.realtek.com.tw (8.15.2/2.92/5.92) with ESMTPS id 38QBntbF7882020 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Sep 2023 19:49:55 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXH36506.realtek.com.tw (172.21.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Tue, 26 Sep 2023 19:49:55 +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; Tue, 26 Sep 2023 19:49:55 +0800 From: Justin Lai To: CC: , , , , , , , , Justin Lai Subject: [PATCH net-next v8 04/13] net:ethernet:realtek:rtase: Implement the interrupt routine and rtase_poll Date: Tue, 26 Sep 2023 19:49:34 +0800 Message-ID: <20230926114943.16340-5-justinlai0215@realtek.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230926114943.16340-1-justinlai0215@realtek.com> References: <20230926114943.16340-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: 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 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 (howler.vger.email [0.0.0.0]); Tue, 26 Sep 2023 04:50:33 -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 fa1b61ccc189..f8c3c317c737 100644 --- a/drivers/net/ethernet/realtek/rtase/rtase_main.c +++ b/drivers/net/ethernet/realtek/rtase/rtase_main.c @@ -575,6 +575,76 @@ 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); @@ -717,9 +787,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