From patchwork Sun Jan 5 12:21:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 216749 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B8E1C33C8C for ; Sun, 5 Jan 2020 12:22:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 249C6218AC for ; Sun, 5 Jan 2020 12:22:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578226962; bh=aelira7b9zEQiju9PVPk3DnHxbR1mw+Sj96KyayHPNc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=srMbrv9GsKd8Aw8zW4bFWJamiJWrG5keCYwFRPVYmOa8D7HitF1/oQxKFh5p244Q2 snW905XHq6GBiNafrs2D9+pO6NoYwQh1CA2VhELfaQgX20HLzs6UXS0Lq75TSnQJX6 DWRtFa+qU8+xmLVP/2uqXmaAYHNCuVG+M5G14C20= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726192AbgAEMWl (ORCPT ); Sun, 5 Jan 2020 07:22:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:46878 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725897AbgAEMWl (ORCPT ); Sun, 5 Jan 2020 07:22:41 -0500 Received: from new-host-5.station (net-2-42-61-77.cust.vodafonedsl.it [2.42.61.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 65453215A4; Sun, 5 Jan 2020 12:22:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578226959; bh=aelira7b9zEQiju9PVPk3DnHxbR1mw+Sj96KyayHPNc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HpglUg/yA5KbzmP6MiQoy1gpPiTKkEuDapraVZSehoJgHuKJglNgSedd7YXH9XatG yYW50Xy4EE5dgDQME/QWZZHlMfBWSBeP8o1mN0nC/JZ2QtXlAdsOTfU2KNUJVngb4X 8Ur7CrtlIDaf5yf5xUJzyIFveu2pqqlvfFjLSRFQ= From: Lorenzo Bianconi To: nbd@nbd.name Cc: lorenzo.bianconi@redhat.com, linux-wireless@vger.kernel.org, Sean.Wang@mediatek.com Subject: [PATCH v2 02/18] mt76: mt76u: add mt76u_process_rx_queue utility routine Date: Sun, 5 Jan 2020 13:21:40 +0100 Message-Id: X-Mailer: git-send-email 2.21.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Introduce mt76u_process_rx_queue routine to process rx hw queue. This is a preliminary patch to support new devices (e.g. mt7663u) that rely on a hw queue for mcu messages Signed-off-by: Sean Wang Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/usb.c | 30 +++++++++++++++--------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c index fbc4c0bb0102..9b0a4104ec0e 100644 --- a/drivers/net/wireless/mediatek/mt76/usb.c +++ b/drivers/net/wireless/mediatek/mt76/usb.c @@ -468,9 +468,9 @@ mt76u_build_rx_skb(void *data, int len, int buf_size) } static int -mt76u_process_rx_entry(struct mt76_dev *dev, struct urb *urb) +mt76u_process_rx_entry(struct mt76_dev *dev, struct urb *urb, + int buf_size) { - struct mt76_queue *q = &dev->q_rx[MT_RXQ_MAIN]; u8 *data = urb->num_sgs ? sg_virt(&urb->sg[0]) : urb->transfer_buffer; int data_len = urb->num_sgs ? urb->sg[0].length : urb->actual_length; int len, nsgs = 1; @@ -484,7 +484,7 @@ mt76u_process_rx_entry(struct mt76_dev *dev, struct urb *urb) return 0; data_len = min_t(int, len, data_len - MT_DMA_HDR_LEN); - skb = mt76u_build_rx_skb(data, data_len, q->buf_size); + skb = mt76u_build_rx_skb(data, data_len, buf_size); if (!skb) return 0; @@ -493,8 +493,8 @@ mt76u_process_rx_entry(struct mt76_dev *dev, struct urb *urb) data_len = min_t(int, len, urb->sg[nsgs].length); skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, sg_page(&urb->sg[nsgs]), - urb->sg[nsgs].offset, - data_len, q->buf_size); + urb->sg[nsgs].offset, data_len, + buf_size); len -= data_len; nsgs++; } @@ -545,20 +545,19 @@ mt76u_submit_rx_buf(struct mt76_dev *dev, struct urb *urb) return usb_submit_urb(urb, GFP_ATOMIC); } -static void mt76u_rx_tasklet(unsigned long data) +static void +mt76u_process_rx_queue(struct mt76_dev *dev, struct mt76_queue *q) { - struct mt76_dev *dev = (struct mt76_dev *)data; + int qid = q - &dev->q_rx[MT_RXQ_MAIN]; struct urb *urb; int err, count; - rcu_read_lock(); - while (true) { urb = mt76u_get_next_rx_entry(dev); if (!urb) break; - count = mt76u_process_rx_entry(dev, urb); + count = mt76u_process_rx_entry(dev, urb, q->buf_size); if (count > 0) { err = mt76u_refill_rx(dev, urb, count, GFP_ATOMIC); if (err < 0) @@ -566,8 +565,17 @@ static void mt76u_rx_tasklet(unsigned long data) } mt76u_submit_rx_buf(dev, urb); } - mt76_rx_poll_complete(dev, MT_RXQ_MAIN, NULL); + if (qid == MT_RXQ_MAIN) + mt76_rx_poll_complete(dev, MT_RXQ_MAIN, NULL); +} +static void mt76u_rx_tasklet(unsigned long data) +{ + struct mt76_dev *dev = (struct mt76_dev *)data; + struct mt76_queue *q = &dev->q_rx[MT_RXQ_MAIN]; + + rcu_read_lock(); + mt76u_process_rx_queue(dev, q); rcu_read_unlock(); }