From patchwork Sat Dec 18 23:54:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 526860 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8ECB3C433EF for ; Sat, 18 Dec 2021 23:54:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235011AbhLRXyW (ORCPT ); Sat, 18 Dec 2021 18:54:22 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25282 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234384AbhLRXyR (ORCPT ); Sat, 18 Dec 2021 18:54:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=gY5sGuQPIVMDU44/2pC7gMhps+WU8nE0gGBCpIqOlgQ=; b=Ws9w0O5N+di9y39ZKUstO9eSg7fNXIaykYmg0CiUV4T+13FiJ7jKldoWOumuMetdS8t9 mV/gIH2DuvmiBlDIyHrGswIR+GzI0Xd7uFUJiyck/o5gNqaPXGwitQCWH4R9R4EFxwqWJK No0GFevUCnPwPZv8oI17cDDLpSCHJogiTmBqbyztvNF84Xh0UhPMcxzSjZ8r3f50xgoLcx 1A2jTvafUo1F9ZOBQqO0/gt0VTBRuF/cWQO7ewosdj1fqZcgFPFltJ6VC5PYpitxwCSbI3 42qFFTwyhjO/Gcn50LOUdieqnjS8uTM39q74BB4gcmW3m/JeIH/EvcYERHi5fPYQ== Received: by filterdrecv-75ff7b5ffb-bcbbj with SMTP id filterdrecv-75ff7b5ffb-bcbbj-1-61BE74A8-17 2021-12-18 23:54:16.475387188 +0000 UTC m=+9336800.790258411 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-2-1 (SG) with ESMTP id CRHLIZYzR-6quDBgjG8pYQ Sat, 18 Dec 2021 23:54:16.302 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 8422570054A; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 01/23] wilc1000: don't hold txq_spinlock while initializing AC queue limits Date: Sat, 18 Dec 2021 23:54:16 +0000 (UTC) Message-Id: <20211218235404.3963475-2-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvD47APGjFyEg/9qMgvPPi1SQklD09yHMagrC+uTlKXz5TBABfx8jUJafCMbaOMKdvK0PKVlW4v9n1tSZ6MgedAC/nUrKT8tEU4XWAIn2XfedCPZ+GIs5c/butuVbfK0syQTJAvpkxaB8ESZo4yXE/TynUrlMWePwGPGlCrvHwJw5bmsnYNQeaYiUqY6LhRGeAQ== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The wilc_tx_queue_status queue is relatively large and there is absolutely no need to initialize it while holding a spinlock. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/netdev.h | 1 - .../net/wireless/microchip/wilc1000/wlan.c | 32 +++++++++++-------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h b/drivers/net/wireless/microchip/wilc1000/netdev.h index b9a88b3e322f1..fd0cb01e538a2 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.h +++ b/drivers/net/wireless/microchip/wilc1000/netdev.h @@ -202,7 +202,6 @@ struct wilc_tx_queue_status { u16 end_index; u16 cnt[NQUEUES]; u16 sum; - bool initialized; }; struct wilc { diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 1aa4236a2fe41..721e6131125e8 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -12,6 +12,8 @@ #define WAKE_UP_TRIAL_RETRY 10000 +static const u8 factors[NQUEUES] = {1, 1, 1, 1}; + static inline bool is_wilc1000(u32 id) { return (id & (~WILC_CHIP_REV_FIELD)) == WILC_1000_BASE_ID; @@ -283,10 +285,23 @@ static int wilc_wlan_txq_add_cfg_pkt(struct wilc_vif *vif, u8 *buffer, return 1; } +static void init_q_limits(struct wilc *wl) +{ + struct wilc_tx_queue_status *q = &wl->tx_q_limit; + int i; + + for (i = 0; i < AC_BUFFER_SIZE; i++) + q->buffer[i] = i % NQUEUES; + + for (i = 0; i < NQUEUES; i++) { + q->cnt[i] = AC_BUFFER_SIZE * factors[i] / NQUEUES; + q->sum += q->cnt[i]; + } + q->end_index = AC_BUFFER_SIZE - 1; +} + static bool is_ac_q_limit(struct wilc *wl, u8 q_num) { - u8 factors[NQUEUES] = {1, 1, 1, 1}; - u16 i; unsigned long flags; struct wilc_tx_queue_status *q = &wl->tx_q_limit; u8 end_index; @@ -294,17 +309,6 @@ static bool is_ac_q_limit(struct wilc *wl, u8 q_num) bool ret = false; spin_lock_irqsave(&wl->txq_spinlock, flags); - if (!q->initialized) { - for (i = 0; i < AC_BUFFER_SIZE; i++) - q->buffer[i] = i % NQUEUES; - - for (i = 0; i < NQUEUES; i++) { - q->cnt[i] = AC_BUFFER_SIZE * factors[i] / NQUEUES; - q->sum += q->cnt[i]; - } - q->end_index = AC_BUFFER_SIZE - 1; - q->initialized = 1; - } end_index = q->end_index; q->cnt[q->buffer[end_index]] -= factors[q->buffer[end_index]]; @@ -1485,6 +1489,8 @@ int wilc_wlan_init(struct net_device *dev) goto fail; } + init_q_limits(wilc); + if (!wilc->tx_buffer) wilc->tx_buffer = kmalloc(WILC_TX_BUFF_SIZE, GFP_KERNEL); From patchwork Sat Dec 18 23:54:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 525827 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC5C1C4321E for ; Sat, 18 Dec 2021 23:54:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235029AbhLRXyY (ORCPT ); Sat, 18 Dec 2021 18:54:24 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25214 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234587AbhLRXyS (ORCPT ); Sat, 18 Dec 2021 18:54:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=lEJOszgCw0TFSxZvSVioKcU+0PoQE8Pc6r25UeeIg7A=; b=S/B1mMakfozT+C0PYycwp9fQiE8/uAqHELHPIMeGMZV+snaVjZ0NTDJn3pPnWMziw3/5 m88sAqBYj6v9D2ZARJ+P7RJLv927q8ESqxGi+OIEWB02+RtC/Q/S+Fxn2kWsxzGMPsHYRB 00JYKb1A2bdrUKTnWOA28QN4AWMwYxDpUsntvqKycFliOOb/adXCwXH2NT+aHfx3NtN1S9 3zZoM7dYZMjI/+RXJNqZVLU+YQmUJo7ID7cH3OZ3Z6jdVPQyat87OHrfsKflWbZC+IZVKK E9qDzoHYRJ1JYunc2W3zwsuQaoLxBcje+Z04v8lgZ/RWxQyTrRvuy9LHg3bkLiVQ== Received: by filterdrecv-7bf5c69d5-fb76v with SMTP id filterdrecv-7bf5c69d5-fb76v-1-61BE74A8-A 2021-12-18 23:54:16.307699886 +0000 UTC m=+1581798.970762200 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-1-1 (SG) with ESMTP id BtctVw9tSLegk_x0es2y0w Sat, 18 Dec 2021 23:54:16.141 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 8704D7005B6; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 02/23] wilc1000: switch txq_event from completion to waitqueue Date: Sat, 18 Dec 2021 23:54:16 +0000 (UTC) Message-Id: <20211218235404.3963475-3-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvF2Lvk30d1zpJ0jP8DPK7uiSg+PB55J4rl/Xo2H8/0KuHpLlqO9wlby2SgTh3Y8nZTUBZLKX+W8sCnEKQLRwfT/rC0sly3dGPiq+OqFwQEeSh8GcBdCjth4cU2uVKSeYA/7oYTDKGmH0uW2DqJ1BhsMpAbrx+nJo6LDELKu49Z4Q/3nndoWt18u+0pv6c2GhzA== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Completion structs are essentially counting semaphores: every complete() call wakes up exactly one thread, either immediately (when there are waiters queued) or in the future (when a waiter arrives). This isn't really the appropriate synchronization structure for the wilc1000 transmit queue handler (wilc_wlan_handle_txq) because it will consume zero, one, or more packets on each call. Instead, use a waitqueue as a condition variable: wake_up_interruptible() wakes up the tx queue handler from a call to wait_event_interruptible() whenever something interesting happens and it then takes the appropriate action. This has a couple of benefits: - Since the transmit queue handler often transfers multiple packets to the chip on each call, repeated calls to wait_for_completion() when there is no actual work to do are avoided. - When the transmit queue handler cannot transfer any packets at all, it'll simply give up the current time slice and then tries again. Previously, the transmit would stall until a new packet showed up (which potentially could cause extended stalls). It would be even better to wait for a "tx queue not full" interrupt but, sadly, I'm told the wilc1000 firmware doesn't provide that. - There is no longer any need for wilc_wlan_txq_filter_dup_tcp_ack() to adjust the completion structs wait count by calling wait_for_completion_timeout() for each dropped packet. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/cfg80211.c | 2 +- drivers/net/wireless/microchip/wilc1000/netdev.c | 13 +++++++++---- drivers/net/wireless/microchip/wilc1000/netdev.h | 2 +- drivers/net/wireless/microchip/wilc1000/wlan.c | 12 ++---------- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.c b/drivers/net/wireless/microchip/wilc1000/cfg80211.c index 8d8378bafd9b0..be387a8abb6af 100644 --- a/drivers/net/wireless/microchip/wilc1000/cfg80211.c +++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.c @@ -1692,7 +1692,7 @@ static void wlan_init_locks(struct wilc *wl) spin_lock_init(&wl->txq_spinlock); mutex_init(&wl->txq_add_to_head_cs); - init_completion(&wl->txq_event); + init_waitqueue_head(&wl->txq_event); init_completion(&wl->cfg_event); init_completion(&wl->sync_event); init_completion(&wl->txq_thread_started); diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c b/drivers/net/wireless/microchip/wilc1000/netdev.c index 03e3485d7e7fa..4dd7c8137c204 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.c +++ b/drivers/net/wireless/microchip/wilc1000/netdev.c @@ -144,10 +144,12 @@ static int wilc_txq_task(void *vp) int ret; u32 txq_count; struct wilc *wl = vp; + long timeout; complete(&wl->txq_thread_started); while (1) { - wait_for_completion(&wl->txq_event); + wait_event_interruptible(wl->txq_event, + (wl->txq_entries > 0 || wl->close)); if (wl->close) { complete(&wl->txq_thread_started); @@ -170,6 +172,11 @@ static int wilc_txq_task(void *vp) } srcu_read_unlock(&wl->srcu, srcu_idx); } + if (ret == WILC_VMM_ENTRY_FULL_RETRY) { + timeout = msecs_to_jiffies(1); + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(timeout); + } } while (ret == WILC_VMM_ENTRY_FULL_RETRY && !wl->close); } return 0; @@ -419,12 +426,11 @@ static void wlan_deinitialize_threads(struct net_device *dev) wl->close = 1; - complete(&wl->txq_event); - if (wl->txq_thread) { kthread_stop(wl->txq_thread); wl->txq_thread = NULL; } + wake_up_interruptible(&wl->txq_event); } static void wilc_wlan_deinitialize(struct net_device *dev) @@ -446,7 +452,6 @@ static void wilc_wlan_deinitialize(struct net_device *dev) wl->hif_func->disable_interrupt(wl); mutex_unlock(&wl->hif_cs); } - complete(&wl->txq_event); wlan_deinitialize_threads(dev); deinit_irq(dev); diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h b/drivers/net/wireless/microchip/wilc1000/netdev.h index fd0cb01e538a2..65cf296a8689e 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.h +++ b/drivers/net/wireless/microchip/wilc1000/netdev.h @@ -235,7 +235,7 @@ struct wilc { struct completion cfg_event; struct completion sync_event; - struct completion txq_event; + wait_queue_head_t txq_event; struct completion txq_thread_started; struct task_struct *txq_thread; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 721e6131125e8..fafeabe2537a3 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -75,7 +75,7 @@ static void wilc_wlan_txq_add_to_tail(struct net_device *dev, u8 q_num, spin_unlock_irqrestore(&wilc->txq_spinlock, flags); - complete(&wilc->txq_event); + wake_up_interruptible(&wilc->txq_event); } static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, u8 q_num, @@ -94,7 +94,7 @@ static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, u8 q_num, spin_unlock_irqrestore(&wilc->txq_spinlock, flags); mutex_unlock(&wilc->txq_add_to_head_cs); - complete(&wilc->txq_event); + wake_up_interruptible(&wilc->txq_event); } #define NOT_TCP_ACK (-1) @@ -196,7 +196,6 @@ static void wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) struct wilc *wilc = vif->wilc; struct tcp_ack_filter *f = &vif->ack_filter; u32 i = 0; - u32 dropped = 0; unsigned long flags; spin_lock_irqsave(&wilc->txq_spinlock, flags); @@ -226,7 +225,6 @@ static void wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) tqe->tx_complete_func(tqe->priv, tqe->status); kfree(tqe); - dropped++; } } } @@ -239,12 +237,6 @@ static void wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) f->pending_base = 0; spin_unlock_irqrestore(&wilc->txq_spinlock, flags); - - while (dropped > 0) { - wait_for_completion_timeout(&wilc->txq_event, - msecs_to_jiffies(1)); - dropped--; - } } void wilc_enable_tcp_ack_filter(struct wilc_vif *vif, bool value) From patchwork Sat Dec 18 23:54:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 525829 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D85A3C433F5 for ; Sat, 18 Dec 2021 23:54:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234979AbhLRXyR (ORCPT ); Sat, 18 Dec 2021 18:54:17 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25300 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232124AbhLRXyR (ORCPT ); Sat, 18 Dec 2021 18:54:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=v7mhVC8oOz6jVz3FqzbpHDEQb0xvpcFgFAT/KNJ3tFk=; b=WJFXWzdfsC+OIXaa1TNfd8VY4OQ2FWZf1DjV8liOWlGms/iixnxWf2IYxLyoeTwTp+3O 9ArahNQ+sZXvIjuDpwp2BK77RAnPBOtAh4Q8iYeR0wjBle+ocyLm3rbmSQ8i3zvyd3x8DN t6UiHLThfQyfXQUnnLyfrMR/5AZlk9ohYmgOWXoCCm3P/h5gmEvPsWmIZ99IZo1B+Vcv4Z PPwrz+2enC0XolwrrurT6wMwHAFks0NgwNgrJlc+gr08rGd4CDHrDaHTtzO+5iecG6B3rI +tKFvlelVI7ACUX6HIPNYljIHcr4f5ZeZw2M9MBgAgq52dYHBFF2u9GC/R1B2d9g== Received: by filterdrecv-64fcb979b9-5m6bg with SMTP id filterdrecv-64fcb979b9-5m6bg-1-61BE74A8-15 2021-12-18 23:54:16.521131114 +0000 UTC m=+8294248.488193823 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-5-0 (SG) with ESMTP id 9_004Y47RlWVNmE_OdvBYw Sat, 18 Dec 2021 23:54:16.323 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 89CAD700694; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 03/23] wilc1000: move receive-queue stats from txq to wilc structure Date: Sat, 18 Dec 2021 23:54:16 +0000 (UTC) Message-Id: <20211218235404.3963475-4-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvOefZa1KROfX6WNE6WJTSIBXCw4Y8gXfoILR78bvyRBoeZwMCihyeVhcXVgjU00tWHB+j8HM7ZkWNzKPPFf4W9KOn+57a+34yRWUsFRi7ZwnyRcMIEw/21aLUvpLOBi69LuA3FqVKyB9uoUyNq1n1fhpC6YhgPjp0alCtp5REcFYi5u1/XnjkyV5Z0OmNk/S6A== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This is in preparation of switching the transmit queue to struct sk_buffs. There is no functional change other than moving the location of the structure. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/netdev.h | 1 + .../net/wireless/microchip/wilc1000/wlan.c | 28 +++++++++---------- .../net/wireless/microchip/wilc1000/wlan.h | 1 - 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h b/drivers/net/wireless/microchip/wilc1000/netdev.h index 65cf296a8689e..ce79bdcc28000 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.h +++ b/drivers/net/wireless/microchip/wilc1000/netdev.h @@ -254,6 +254,7 @@ struct wilc { struct txq_handle txq[NQUEUES]; int txq_entries; + struct txq_fw_recv_queue_stat fw[NQUEUES]; struct wilc_tx_queue_status tx_q_limit; struct rxq_entry_t rxq_head; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index fafeabe2537a3..2d103131b2e93 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -373,32 +373,32 @@ static inline int ac_balance(struct wilc *wl, u8 *ratio) return -EINVAL; for (i = 0; i < NQUEUES; i++) - if (wl->txq[i].fw.count > max_count) - max_count = wl->txq[i].fw.count; + if (wl->fw[i].count > max_count) + max_count = wl->fw[i].count; for (i = 0; i < NQUEUES; i++) - ratio[i] = max_count - wl->txq[i].fw.count; + ratio[i] = max_count - wl->fw[i].count; return 0; } static inline void ac_update_fw_ac_pkt_info(struct wilc *wl, u32 reg) { - wl->txq[AC_BK_Q].fw.count = FIELD_GET(BK_AC_COUNT_FIELD, reg); - wl->txq[AC_BE_Q].fw.count = FIELD_GET(BE_AC_COUNT_FIELD, reg); - wl->txq[AC_VI_Q].fw.count = FIELD_GET(VI_AC_COUNT_FIELD, reg); - wl->txq[AC_VO_Q].fw.count = FIELD_GET(VO_AC_COUNT_FIELD, reg); - - wl->txq[AC_BK_Q].fw.acm = FIELD_GET(BK_AC_ACM_STAT_FIELD, reg); - wl->txq[AC_BE_Q].fw.acm = FIELD_GET(BE_AC_ACM_STAT_FIELD, reg); - wl->txq[AC_VI_Q].fw.acm = FIELD_GET(VI_AC_ACM_STAT_FIELD, reg); - wl->txq[AC_VO_Q].fw.acm = FIELD_GET(VO_AC_ACM_STAT_FIELD, reg); + wl->fw[AC_BK_Q].count = FIELD_GET(BK_AC_COUNT_FIELD, reg); + wl->fw[AC_BE_Q].count = FIELD_GET(BE_AC_COUNT_FIELD, reg); + wl->fw[AC_VI_Q].count = FIELD_GET(VI_AC_COUNT_FIELD, reg); + wl->fw[AC_VO_Q].count = FIELD_GET(VO_AC_COUNT_FIELD, reg); + + wl->fw[AC_BK_Q].acm = FIELD_GET(BK_AC_ACM_STAT_FIELD, reg); + wl->fw[AC_BE_Q].acm = FIELD_GET(BE_AC_ACM_STAT_FIELD, reg); + wl->fw[AC_VI_Q].acm = FIELD_GET(VI_AC_ACM_STAT_FIELD, reg); + wl->fw[AC_VO_Q].acm = FIELD_GET(VO_AC_ACM_STAT_FIELD, reg); } static inline u8 ac_change(struct wilc *wilc, u8 *ac) { do { - if (wilc->txq[*ac].fw.acm == 0) + if (wilc->fw[*ac].acm == 0) return 0; (*ac)++; } while (*ac < NQUEUES); @@ -920,7 +920,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) kfree(tqe); } while (--entries); for (i = 0; i < NQUEUES; i++) - wilc->txq[i].fw.count += ac_pkt_num_to_chip[i]; + wilc->fw[i].count += ac_pkt_num_to_chip[i]; acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/wireless/microchip/wilc1000/wlan.h index eb7978166d73e..9b33262909e2f 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.h +++ b/drivers/net/wireless/microchip/wilc1000/wlan.h @@ -341,7 +341,6 @@ struct txq_fw_recv_queue_stat { struct txq_handle { struct txq_entry_t txq_head; u16 count; - struct txq_fw_recv_queue_stat fw; }; struct rxq_entry_t { From patchwork Sat Dec 18 23:54:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 526859 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16FA5C43217 for ; Sat, 18 Dec 2021 23:54:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235042AbhLRXyZ (ORCPT ); Sat, 18 Dec 2021 18:54:25 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25336 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234858AbhLRXyS (ORCPT ); Sat, 18 Dec 2021 18:54:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=0hlvidBJdhIlrLaOHqRVQf+FcgIZ6mOxvt9oZ5jAdx0=; b=vQ9EnhDfneo5BqECP/eh1ztxPZq24D5XUBEaQAsws/L7qQ1jRNwgl5i3Gt9LaGrt0Txq p/bSHsC2I5KuElmBo/qIt/Da9Kx/KRpmMzXUT68KapI2JHMOmNGamups9cBzWd5R6DpEmC 97DzFXmAmYjTbOcY/ooOHab/jItIWv3rXLATYzeX7nwuvelkmWJRVAm8OOREo/F4jAhlnL AflfqxNeopq11JwrY3EoJLKPZikm1H3vjW8sMw7Z7/xSK3BrmLxZGkmSiO99RmiwwNcswm 6PUqJmQTQaXL+9BZ0qhU45sZkiXpaPNMqhAEqPHaWDRfszCy5P1o+kcKLgrlT+hw== Received: by filterdrecv-75ff7b5ffb-wdd5z with SMTP id filterdrecv-75ff7b5ffb-wdd5z-1-61BE74A8-17 2021-12-18 23:54:16.568724745 +0000 UTC m=+9336864.670000613 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-1-1 (SG) with ESMTP id 6K7gRl6-Tv2qCxjFpmNq-A Sat, 18 Dec 2021 23:54:16.367 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 8D75D70086E; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 04/23] wilc1000: factor common code in wilc_wlan_cfg_set() and wilc_wlan_cfg_get() Date: Sat, 18 Dec 2021 23:54:16 +0000 (UTC) Message-Id: <20211218235404.3963475-5-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvE+Fbp/MICLbrzIynlqvh2mpwH/4CJ7Fl+jG2+wFUWQcq78AkswDBm0MGRp9lFxQYYmrW1+AHjdJjCedyCNvjiNb8nCXqQ7QUPbB6eefetRuWwuUEZ0WirGQdzlvZPjYxPQ9yGv8YzOIkZIEgSPuHnnp/SsFuMQCiHd0oz2KyfiASjhlz2/ucxjmhUYynDgurA== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The functions are almost identical, so factor the common code into new function wilc_wlan_cfg_apply_wid(). No functional change. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/wlan.c | 65 ++++++++----------- 1 file changed, 27 insertions(+), 38 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 2d103131b2e93..1c487342c1a88 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -1276,8 +1276,14 @@ static int wilc_wlan_cfg_commit(struct wilc_vif *vif, int type, return 0; } -int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, - u32 buffer_size, int commit, u32 drv_handler) +/** + * Add a WID set/query to the current config packet and optionally + * submit the resulting packet to the chip and wait for its reply. + * Returns 0 on failure, positive number on success. + */ +static int wilc_wlan_cfg_apply_wid(struct wilc_vif *vif, int start, u16 wid, + u8 *buffer, u32 buffer_size, int commit, + u32 drv_handler, bool set) { u32 offset; int ret_size; @@ -1289,8 +1295,12 @@ int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, wilc->cfg_frame_offset = 0; offset = wilc->cfg_frame_offset; - ret_size = wilc_wlan_cfg_set_wid(wilc->cfg_frame.frame, offset, - wid, buffer, buffer_size); + if (set) + ret_size = wilc_wlan_cfg_set_wid(wilc->cfg_frame.frame, offset, + wid, buffer, buffer_size); + else + ret_size = wilc_wlan_cfg_get_wid(wilc->cfg_frame.frame, offset, + wid); offset += ret_size; wilc->cfg_frame_offset = offset; @@ -1299,9 +1309,11 @@ int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, return ret_size; } - netdev_dbg(vif->ndev, "%s: seqno[%d]\n", __func__, wilc->cfg_seq_no); + netdev_dbg(vif->ndev, "%s: %s seqno[%d]\n", + __func__, set ? "set" : "get", wilc->cfg_seq_no); - if (wilc_wlan_cfg_commit(vif, WILC_CFG_SET, drv_handler)) + if (wilc_wlan_cfg_commit(vif, set ? WILC_CFG_SET : WILC_CFG_QUERY, + drv_handler)) ret_size = 0; if (!wait_for_completion_timeout(&wilc->cfg_event, @@ -1317,41 +1329,18 @@ int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, return ret_size; } +int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, + u32 buffer_size, int commit, u32 drv_handler) +{ + return wilc_wlan_cfg_apply_wid(vif, start, wid, buffer, buffer_size, + commit, drv_handler, true); +} + int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, u16 wid, int commit, u32 drv_handler) { - u32 offset; - int ret_size; - struct wilc *wilc = vif->wilc; - - mutex_lock(&wilc->cfg_cmd_lock); - - if (start) - wilc->cfg_frame_offset = 0; - - offset = wilc->cfg_frame_offset; - ret_size = wilc_wlan_cfg_get_wid(wilc->cfg_frame.frame, offset, wid); - offset += ret_size; - wilc->cfg_frame_offset = offset; - - if (!commit) { - mutex_unlock(&wilc->cfg_cmd_lock); - return ret_size; - } - - if (wilc_wlan_cfg_commit(vif, WILC_CFG_QUERY, drv_handler)) - ret_size = 0; - - if (!wait_for_completion_timeout(&wilc->cfg_event, - WILC_CFG_PKTS_TIMEOUT)) { - netdev_dbg(vif->ndev, "%s: Timed Out\n", __func__); - ret_size = 0; - } - wilc->cfg_frame_offset = 0; - wilc->cfg_seq_no += 1; - mutex_unlock(&wilc->cfg_cmd_lock); - - return ret_size; + return wilc_wlan_cfg_apply_wid(vif, start, wid, NULL, 0, + commit, drv_handler, false); } int wilc_send_config_pkt(struct wilc_vif *vif, u8 mode, struct wid *wids, From patchwork Sat Dec 18 23:54:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 525818 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BAEBC433EF for ; Sat, 18 Dec 2021 23:55:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235468AbhLRXza (ORCPT ); Sat, 18 Dec 2021 18:55:30 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25456 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234932AbhLRXyV (ORCPT ); Sat, 18 Dec 2021 18:54:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=GqFSvl17lDTvbBkqniXjLg21Lj+A9xy5Bmx0Sh9Xsc0=; b=hoUAcEMO4F7cwMOYwc8Q3bWflwUOAgK1HQvQo4sozgyHqYfsFSf1Su/+oVvGFr6IznZX lasxxr3rv82mBcs/4i7y7BJf2+sePPqpOqk5GiaPW5hJ5cJysj/Bm1a1NbFBrIv3Kv0Jte gvsVivpjZU/IgE5NZFsWM31G4XLf06DTV+dhYHXW+dcz8QrM4DTBtOCDBM0xwLfcMILwMG 2ESSlPWlCy8Et8zP55jWzCtyk0MeJHP8bh2Ee3KNqwWcQJkPmf5TNYrEF1JQY/evxkGwJX Yv22mYvlfIuIa9QSnhBqX6kB5CD/P5SblMzAZWte/tb4yH9u2FKtGdCEMsbMp6eg== Received: by filterdrecv-75ff7b5ffb-z69hd with SMTP id filterdrecv-75ff7b5ffb-z69hd-1-61BE74A8-28 2021-12-18 23:54:16.715682125 +0000 UTC m=+9336865.920225564 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-2-1 (SG) with ESMTP id Vu7kSu5CSAKaB3hoZI8cpw Sat, 18 Dec 2021 23:54:16.584 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 902BF7008F3; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 05/23] wilc1000: add wilc_wlan_tx_packet_done() function Date: Sat, 18 Dec 2021 23:54:16 +0000 (UTC) Message-Id: <20211218235404.3963475-6-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvOwSrDGIbdKBFbkIAY3ejM6MX+RbkuA1BWsYq1JOMGFKUXzgeTseLK1B3B5De35HnXyaaO9rTwg8vXLIjTX83bkzQAPAmSeUC3oJ1XbEuQ0waxXSc4dtaLdl+SO1khkwmygU3ekxlPf7MCbp2P6VXmFZ0PmoDiwEa1L9zqkZZoRfz9UuQ9fkVhlsYJmLoL/2pQ== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Factor common tx packet-done handling code into a function. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/wlan.c | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 1c487342c1a88..caaa03c8e5df8 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -190,6 +190,16 @@ static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe) spin_unlock_irqrestore(&wilc->txq_spinlock, flags); } +static void wilc_wlan_tx_packet_done(struct txq_entry_t *tqe, int status) +{ + tqe->status = status; + if (tqe->tx_complete_func) + tqe->tx_complete_func(tqe->priv, tqe->status); + if (tqe->ack_idx != NOT_TCP_ACK && tqe->ack_idx < MAX_PENDING_ACKS) + tqe->vif->ack_filter.pending_acks[tqe->ack_idx].txqe = NULL; + kfree(tqe); +} + static void wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) { struct wilc_vif *vif = netdev_priv(dev); @@ -220,11 +230,7 @@ static void wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) tqe = f->pending_acks[i].txqe; if (tqe) { wilc_wlan_txq_remove(wilc, tqe->q_num, tqe); - tqe->status = 1; - if (tqe->tx_complete_func) - tqe->tx_complete_func(tqe->priv, - tqe->status); - kfree(tqe); + wilc_wlan_tx_packet_done(tqe, 1); } } } @@ -911,13 +917,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) tqe->buffer, tqe->buffer_size); offset += vmm_sz; i++; - tqe->status = 1; - if (tqe->tx_complete_func) - tqe->tx_complete_func(tqe->priv, tqe->status); - if (tqe->ack_idx != NOT_TCP_ACK && - tqe->ack_idx < MAX_PENDING_ACKS) - vif->ack_filter.pending_acks[tqe->ack_idx].txqe = NULL; - kfree(tqe); + wilc_wlan_tx_packet_done(tqe, 1); } while (--entries); for (i = 0; i < NQUEUES; i++) wilc->fw[i].count += ac_pkt_num_to_chip[i]; @@ -1236,11 +1236,8 @@ void wilc_wlan_cleanup(struct net_device *dev) wilc->quit = 1; for (ac = 0; ac < NQUEUES; ac++) { - while ((tqe = wilc_wlan_txq_remove_from_head(wilc, ac))) { - if (tqe->tx_complete_func) - tqe->tx_complete_func(tqe->priv, 0); - kfree(tqe); - } + while ((tqe = wilc_wlan_txq_remove_from_head(wilc, ac))) + wilc_wlan_tx_packet_done(tqe, 0); } while ((rqe = wilc_wlan_rxq_remove(wilc))) From patchwork Sat Dec 18 23:54:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 525828 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB59BC433FE for ; Sat, 18 Dec 2021 23:54:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235016AbhLRXyX (ORCPT ); Sat, 18 Dec 2021 18:54:23 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25378 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234896AbhLRXyS (ORCPT ); Sat, 18 Dec 2021 18:54:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=xruF0/wdRiftakYKJKiX4VcckLBgAfUgvUqV7IHx2E4=; b=dvStbokSfDMpTQUXRJu+YAjUI9UwxMp2MHMiyY/9ALhBCn1Y2Peu1dDN5dADoF07cGGA DFqgjXTfrqNRIIlFGTHClbyjiQpTLlqt3o5ciPLWhYIR5PwfymNblYUN4DMdbVdMDFOfoY iSfRY/qTu/mZ1bjS9zysqfptkdjVDLXrQaaymQYk19rzyUAisp87w39OCNGy9QHi+cwPw4 z+bR5sIytIlsRVlW5S64VBkomFmB3fprqVpBJY5Gl2Us8JxiyJbYuXYbzSa8EFkpgfZ05f 38epAeVY373jOHwYvQdhrXQHk7MJypEu4fPA6RM5LxwYWW4bEm0eLTjO3g4FQg6w== Received: by filterdrecv-656998cfdd-gwqfx with SMTP id filterdrecv-656998cfdd-gwqfx-1-61BE74A8-1D 2021-12-18 23:54:16.730054846 +0000 UTC m=+7604790.136767512 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-6-0 (SG) with ESMTP id cnPWmkt0R9uhsSnxU4r7cQ Sat, 18 Dec 2021 23:54:16.575 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 93A9B700A10; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 06/23] wilc1000: move tx packet drop code into its own function Date: Sat, 18 Dec 2021 23:54:16 +0000 (UTC) Message-Id: <20211218235404.3963475-7-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvHMIlWy+OoiMKxiCzvO9KY39A4krq0DN1w2fLd3tpplREjmFMJN8N3lh1YratNtlBhMv13mzJqt8RyMczEzAcbWzTk+EJgYUYAgJTNT0hzNOD3RTvuVNgnd3nh4jFABUgfVxrne31wwBsqeeAH9dbz9OymSfDglWtY7pWLfLWePE7W3xD6YH1Ke/Rzbu/I1xIA== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This is just to improve code clarity. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index caaa03c8e5df8..a9bfd71b0e667 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -200,6 +200,14 @@ static void wilc_wlan_tx_packet_done(struct txq_entry_t *tqe, int status) kfree(tqe); } +static void wilc_wlan_txq_drop_net_pkt(struct txq_entry_t *tqe) +{ + struct wilc *wilc = tqe->vif->wilc; + + wilc_wlan_txq_remove(wilc, tqe->q_num, tqe); + wilc_wlan_tx_packet_done(tqe, 1); +} + static void wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) { struct wilc_vif *vif = netdev_priv(dev); @@ -228,10 +236,8 @@ static void wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) struct txq_entry_t *tqe; tqe = f->pending_acks[i].txqe; - if (tqe) { - wilc_wlan_txq_remove(wilc, tqe->q_num, tqe); - wilc_wlan_tx_packet_done(tqe, 1); - } + if (tqe) + wilc_wlan_txq_drop_net_pkt(tqe); } } f->pending_acks_idx = 0; From patchwork Sat Dec 18 23:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 526850 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AADFC433F5 for ; Sat, 18 Dec 2021 23:55:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235227AbhLRXz2 (ORCPT ); Sat, 18 Dec 2021 18:55:28 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25498 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234933AbhLRXyU (ORCPT ); Sat, 18 Dec 2021 18:54:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=RT9YbsVtdR4GzUV4QohWzyGBC/fSE3abgungjw0gKpI=; b=DI2HiQJ/zFWwPLhZv+3T3Rl+KuFLuimYbfKdO+q6+UnCb3EfqWCEZoGGKbAowvAnB4bi GRCDd0FRQl5EkyFRKcAQZbdGeXQHhoMYZng524VREnBd7U/zyCFWzxusrnM5j/C0lRjqz2 m/rMxD3xza4bl0bYTByPnfU5z+zT2HOmW9eGNDiVkZrOMXeMbYU84okzxmVUYUSigLVKRS dRCTLS5Ma2rZcdk3YVoRHdIya2pzWZrqilQOcakp0/Khmerpw7g1dMCO/wYcdna7H/7VAc WPyb0LSSUoeogwdKMexKnR+i3mt9TrQF0pIx6W30QZLVt09eLDB+n2sCsCe76lUg== Received: by filterdrecv-7bf5c69d5-p7gjg with SMTP id filterdrecv-7bf5c69d5-p7gjg-1-61BE74A8-19 2021-12-18 23:54:16.810393089 +0000 UTC m=+1581803.434338992 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-3-0 (SG) with ESMTP id Zo3TXZV0SyWEp2hsODIFTg Sat, 18 Dec 2021 23:54:16.680 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 96FCC700F5D; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 07/23] wilc1000: increment tx_dropped stat counter on tx packet drop Date: Sat, 18 Dec 2021 23:54:17 +0000 (UTC) Message-Id: <20211218235404.3963475-8-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvED/zcavR1sH7nYvL46KWWXmyIJ8qnkI45lXgEPjy7Xft66PMj7o6uG1hrNLoSTcAe0/27A0i6YO161kES7Da+tApeSd7UOFDRgvUicIUqHKXLnEGiZU7qxMKVCwj3vAWK0BKRzt5IofQGOLUbmoRvk4m5PbfEIcWU4+i45E8/SD9tu8/BVl+amilRS/yEMbOA== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Packet drops are important events so we should remember to count them. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index a9bfd71b0e667..b85ceda8409e6 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -202,7 +202,10 @@ static void wilc_wlan_tx_packet_done(struct txq_entry_t *tqe, int status) static void wilc_wlan_txq_drop_net_pkt(struct txq_entry_t *tqe) { - struct wilc *wilc = tqe->vif->wilc; + struct wilc_vif *vif = tqe->vif; + struct wilc *wilc = vif->wilc; + + vif->ndev->stats.tx_dropped++; wilc_wlan_txq_remove(wilc, tqe->q_num, tqe); wilc_wlan_tx_packet_done(tqe, 1); From patchwork Sat Dec 18 23:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 526855 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07817C433FE for ; Sat, 18 Dec 2021 23:54:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234587AbhLRXy0 (ORCPT ); Sat, 18 Dec 2021 18:54:26 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25468 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234901AbhLRXyT (ORCPT ); Sat, 18 Dec 2021 18:54:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=QAh24Ex5HQMwz2LcHEFWDu0hjRaIliWenvyP2BPryNQ=; b=RihxgcCN7Rp8Skq01adkqBvOMORTUxGQHEzj0nnhO+qYCB4gwzn1n2npuBBAIlD5K+0A DFs90Fovz24xQE5DLDpVZwP6I4wOcWTbuNu0AzOLV0L0cOLe+cIqPWmH3oHb0uZc/Xo7gL dBmUcK5n30roGWdlMOK7GZKOVkH58opBaYQtAgsGlQZ/k+kIJbSqrvlBhgnYRPo77WjRO3 DNSHkCwwiObZpiv4fZ+Ac9TXR1YfbJxnJA0ht31E23poKCCqC8bArqBK5rjwa1fz7STIdR Hht4S8gtMn69vJB/NhqhxMq1wXokSdqEvyy8F8cFNuPcxkSWXZtY2pLoC5kchrmA== Received: by filterdrecv-656998cfdd-phncc with SMTP id filterdrecv-656998cfdd-phncc-1-61BE74A8-1D 2021-12-18 23:54:16.838337232 +0000 UTC m=+7604818.024584014 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-5-1 (SG) with ESMTP id MZ7uISucQJa4P7omMBWJmg Sat, 18 Dec 2021 23:54:16.696 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 99A23700F78; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 08/23] wilc1000: fix management packet type inconsistency Date: Sat, 18 Dec 2021 23:54:17 +0000 (UTC) Message-Id: <20211218235404.3963475-9-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvBgWXtrCB5OF5sDb1M3PEtEXGAnFYO34+OEM+j2yxQqTLIGNhi5Sbe1v3retJL1jACmWBuhInLXrqxzUtEf/z7H8ANDeXBXpQ7/t3BXfF+jgCJgN2LYyscpIBd5FY77AD11zOD2U2G8qy5QgPW/Sm0fJnimgsBpQhtDYPOFZcT9A63hHKGKv6vIBj3rEYWEHwA== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The queue type for management packets was initialized to AC_BE_Q (best-effort queue) but the packet was then actually added to the AC_VO_Q queue (voice, or highest-priority queue). This fixes the inconsistency by setting the type to AC_VO_Q. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index b85ceda8409e6..c72eb4244508c 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -507,7 +507,7 @@ int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer, tqe->buffer_size = buffer_size; tqe->tx_complete_func = tx_complete_fn; tqe->priv = priv; - tqe->q_num = AC_BE_Q; + tqe->q_num = AC_VO_Q; tqe->ack_idx = NOT_TCP_ACK; tqe->vif = vif; wilc_wlan_txq_add_to_tail(dev, AC_VO_Q, tqe); From patchwork Sat Dec 18 23:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 526854 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 979ABC433FE for ; Sat, 18 Dec 2021 23:54:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235304AbhLRXyz (ORCPT ); Sat, 18 Dec 2021 18:54:55 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25506 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234921AbhLRXyT (ORCPT ); Sat, 18 Dec 2021 18:54:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=O3QMGZ1TvKipgmU3yhr6SELaovZiIL63KEeJdy55Z1k=; b=OY4XOiqWy4g4NuCxzxUWsIERVRqtbR/Vsmg4r36Sf+uM67W98s5AHbI/LWZY+p1Vaibm v2EZ5rNeFqe4C7ZKFeM4cWOLdbfIJn0ABqIWetPBr87iRzlUCxZn0KlamvzS8jEUqJKscn k1IVkIpW6h6pJ1Fur1zZR802l8dBPcPoMsI3gQ9axYqgj6PqamX6h9ETwGvlgvRoYUGzY7 0aV2ed+QW7lUiIf8qWfWjCX6VpSkkxtBwmIOqOzhTPtXXjaKNrlvp2DcJtJbfC8dKdvy8o wLh8wWL8L5vTAtGAuSO6JAlOjkb2eTuzKCzaLtYNvx8kpaA/cQhzGr3z7A26BLbw== Received: by filterdrecv-64fcb979b9-stcmh with SMTP id filterdrecv-64fcb979b9-stcmh-1-61BE74A8-22 2021-12-18 23:54:16.88213613 +0000 UTC m=+8294196.226541698 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-5-1 (SG) with ESMTP id iu8-LAMbQYqFOg-98uBZbw Sat, 18 Dec 2021 23:54:16.713 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 9C64B701006; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 09/23] wilc1000: prepare wilc_wlan_tx_packet_done() for sk_buff changes Date: Sat, 18 Dec 2021 23:54:17 +0000 (UTC) Message-Id: <20211218235404.3963475-10-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvAfbdWDGErp6E4oqXVKd+cceFveB6IDBKFu3rp69X9F2FiZ9fQfAqOO1RbtdIA4+0CcRNBr4n6XptBkjISGTceoEcNv9fOY/I9T0t4ZU0/GwpDp4Gcc47meHyTFgZZNqMasCxFa3cw1Oo7L9cSxncQxhzlv0Ko/ecFydapKRxxGDKCJCDmrF4eYk/zoQ6g9Ydg== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This patch just adds some helper variables. I suppose they improve readability, but the real reason for this patch is to make the forthcoming sk_buff rework patch shorter and more obvious. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index c72eb4244508c..eeb9961adfa34 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -192,11 +192,14 @@ static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe) static void wilc_wlan_tx_packet_done(struct txq_entry_t *tqe, int status) { + struct wilc_vif *vif = tqe->vif; + int ack_idx = tqe->ack_idx; + tqe->status = status; if (tqe->tx_complete_func) tqe->tx_complete_func(tqe->priv, tqe->status); - if (tqe->ack_idx != NOT_TCP_ACK && tqe->ack_idx < MAX_PENDING_ACKS) - tqe->vif->ack_filter.pending_acks[tqe->ack_idx].txqe = NULL; + if (ack_idx != NOT_TCP_ACK && ack_idx < MAX_PENDING_ACKS) + vif->ack_filter.pending_acks[ack_idx].txqe = NULL; kfree(tqe); } From patchwork Sat Dec 18 23:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 525825 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 422ECC3525C for ; Sat, 18 Dec 2021 23:54:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235089AbhLRXyc (ORCPT ); Sat, 18 Dec 2021 18:54:32 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25520 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234923AbhLRXyT (ORCPT ); Sat, 18 Dec 2021 18:54:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=NYxaYzHm1pIpxmKQkLLEhojKZgPDBGN2Wz7Q273Yc1A=; b=HG0x7g6AYvBW7Kwh69dG78sBh0H6cqqwRR63mdBuojCcEwr7oMSkE9ma9RABy+ZzYXez UGUmEI00PI8tnksPs6KOX7fJOHSyUteSHQQhCGxcKL/N3gtUSoXao08lGfSaSmdN11S7YT 8k/qNKBUKVERPNlbNV7nSYd0JXY91M5YInsgxVz/g/MRrX7ltX8mE4pdlByW2HiaKYe0Oe xOE2yBuODvcZ7ml/ii+hCjl+4/jONDuM3e5KTK4LDbiQD+OVfO+q7+o9euJRMQAR730Am2 BbPQCI17a+KWSaSnzbeUuQATzwAiJwrgSPjbeYmM8Q0GyxnBqpAa3y7DF8JqmMzw== Received: by filterdrecv-656998cfdd-ptr8m with SMTP id filterdrecv-656998cfdd-ptr8m-1-61BE74A8-19 2021-12-18 23:54:16.906807421 +0000 UTC m=+7604818.766390139 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-4-0 (SG) with ESMTP id 75uavCaHQAmRTtDVHItOng Sat, 18 Dec 2021 23:54:16.730 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 9FD617010AC; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 10/23] wilc1000: factor initialization of tx queue-specific packet fields Date: Sat, 18 Dec 2021 23:54:17 +0000 (UTC) Message-Id: <20211218235404.3963475-11-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvOXjTHfbwtHLXBF2RyVqEni302Z8u6SJC5T3FxD4jowv+cJ16LpDOrzQDdqo0IpEgm6aZBeAWbpDKVt10kxoQSbw4yTV1jN276qz+MHS6encYZIoSI0UwyI8kFXjGL2RA+v9ZUSeyQ19HXVWpb9HBisXo/mlgQ9mui7iS/wtZRZ0C14kagNZ9HgMqWteZlaT6Q== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This ensures that the fields are initialized consistently for all packets on the tx queues. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/wlan.c | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index eeb9961adfa34..dd669f9ea88a8 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -12,8 +12,12 @@ #define WAKE_UP_TRIAL_RETRY 10000 +#define NOT_TCP_ACK (-1) + static const u8 factors[NQUEUES] = {1, 1, 1, 1}; +static void tcp_process(struct net_device *, struct txq_entry_t *); + static inline bool is_wilc1000(u32 id) { return (id & (~WILC_CHIP_REV_FIELD)) == WILC_1000_BASE_ID; @@ -60,13 +64,26 @@ wilc_wlan_txq_remove_from_head(struct wilc *wilc, u8 q_num) return tqe; } -static void wilc_wlan_txq_add_to_tail(struct net_device *dev, u8 q_num, +static void init_txq_entry(struct txq_entry_t *tqe, struct wilc_vif *vif, + u8 type, enum ip_pkt_priority q_num) +{ + tqe->vif = vif; + tqe->q_num = q_num; + tqe->type = type; + tqe->ack_idx = NOT_TCP_ACK; +} + +static void wilc_wlan_txq_add_to_tail(struct net_device *dev, u8 type, u8 q_num, struct txq_entry_t *tqe) { unsigned long flags; struct wilc_vif *vif = netdev_priv(dev); struct wilc *wilc = vif->wilc; + init_txq_entry(tqe, vif, type, q_num); + if (type == WILC_NET_PKT && vif->ack_filter.enabled) + tcp_process(dev, tqe); + spin_lock_irqsave(&wilc->txq_spinlock, flags); list_add_tail(&tqe->list, &wilc->txq[q_num].txq_head.list); @@ -78,12 +95,14 @@ static void wilc_wlan_txq_add_to_tail(struct net_device *dev, u8 q_num, wake_up_interruptible(&wilc->txq_event); } -static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, u8 q_num, +static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, u8 type, u8 q_num, struct txq_entry_t *tqe) { unsigned long flags; struct wilc *wilc = vif->wilc; + init_txq_entry(tqe, vif, type, q_num); + mutex_lock(&wilc->txq_add_to_head_cs); spin_lock_irqsave(&wilc->txq_spinlock, flags); @@ -97,8 +116,6 @@ static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, u8 q_num, wake_up_interruptible(&wilc->txq_event); } -#define NOT_TCP_ACK (-1) - static inline void add_tcp_session(struct wilc_vif *vif, u32 src_prt, u32 dst_prt, u32 seq) { @@ -281,16 +298,12 @@ static int wilc_wlan_txq_add_cfg_pkt(struct wilc_vif *vif, u8 *buffer, return 0; } - tqe->type = WILC_CFG_PKT; tqe->buffer = buffer; tqe->buffer_size = buffer_size; tqe->tx_complete_func = NULL; tqe->priv = NULL; - tqe->q_num = AC_VO_Q; - tqe->ack_idx = NOT_TCP_ACK; - tqe->vif = vif; - wilc_wlan_txq_add_to_head(vif, AC_VO_Q, tqe); + wilc_wlan_txq_add_to_head(vif, WILC_CFG_PKT, AC_VO_Q, tqe); return 1; } @@ -452,15 +465,12 @@ int wilc_wlan_txq_add_net_pkt(struct net_device *dev, tx_complete_fn(tx_data, 0); return 0; } - tqe->type = WILC_NET_PKT; tqe->buffer = buffer; tqe->buffer_size = buffer_size; tqe->tx_complete_func = tx_complete_fn; tqe->priv = tx_data; - tqe->vif = vif; q_num = ac_classify(wilc, tx_data->skb); - tqe->q_num = q_num; if (ac_change(wilc, &q_num)) { tx_complete_fn(tx_data, 0); kfree(tqe); @@ -468,10 +478,7 @@ int wilc_wlan_txq_add_net_pkt(struct net_device *dev, } if (is_ac_q_limit(wilc, q_num)) { - tqe->ack_idx = NOT_TCP_ACK; - if (vif->ack_filter.enabled) - tcp_process(dev, tqe); - wilc_wlan_txq_add_to_tail(dev, q_num, tqe); + wilc_wlan_txq_add_to_tail(dev, WILC_NET_PKT, q_num, tqe); } else { tx_complete_fn(tx_data, 0); kfree(tqe); @@ -505,15 +512,11 @@ int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer, tx_complete_fn(priv, 0); return 0; } - tqe->type = WILC_MGMT_PKT; tqe->buffer = buffer; tqe->buffer_size = buffer_size; tqe->tx_complete_func = tx_complete_fn; tqe->priv = priv; - tqe->q_num = AC_VO_Q; - tqe->ack_idx = NOT_TCP_ACK; - tqe->vif = vif; - wilc_wlan_txq_add_to_tail(dev, AC_VO_Q, tqe); + wilc_wlan_txq_add_to_tail(dev, WILC_MGMT_PKT, AC_VO_Q, tqe); return 1; } From patchwork Sat Dec 18 23:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 525822 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CB82C4332F for ; Sat, 18 Dec 2021 23:54:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235331AbhLRXy5 (ORCPT ); Sat, 18 Dec 2021 18:54:57 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25560 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234935AbhLRXyU (ORCPT ); Sat, 18 Dec 2021 18:54:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=SCd/tobGA8mYNvYTBXsoUFl/FSU5vvWP7ZqX5PwsUss=; b=YhT7y5CVb83Y2Du5r095HrgYErIWOUWcdEcvLZOOSfmUS84PuK0SwlhItB2Ap9qpRODm IM+PmqexYg1z5zAkPJuKx+uAdR8jxKREYFSIu7vJo2ITgxsfe6r3K5d/tA/fmUfY5lgpsd 59p+a4Yl1fNiPEQwhjBimqLFRUfU3JYKoZ9gkp2Xv/kqiS0GXbOXfmNJa4fIsHEb5RGJye hAHgu2yNcs55DIvklwwwbTeAqjm86NociIcH2p5VfjcMQRrvMfY1YIRlD8rW6E1N6+4iC6 m4khNvNQk/4ARDfeyY2OjOu9rMBtLsXjgT/6Y1Qzm7A0Jh0JA+biujmhGU1l+gOw== Received: by filterdrecv-656998cfdd-ngmx2 with SMTP id filterdrecv-656998cfdd-ngmx2-1-61BE74A8-1F 2021-12-18 23:54:16.941728902 +0000 UTC m=+7604817.237963524 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-4-0 (SG) with ESMTP id tYUYtDuLSPmIBYrCuLuwHQ Sat, 18 Dec 2021 23:54:16.765 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id A1F297010BD; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 11/23] wilc1000: convert tqx_entries from "int" to "atomic_t" Date: Sat, 18 Dec 2021 23:54:17 +0000 (UTC) Message-Id: <20211218235404.3963475-12-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvIrCLYJZzghAKaQ1Q2/AozQL5y8K/DU2wm3OsO49UXpEaoCHuK4aKIibU/pTfUlJUYYwdUWpYfuIIt8IPyhhJkROZBh/06Dpo+s3kkY3kPZZCpelTjmgFj6fBEthUZ2c86xM8s3JB6xG7yyqsG5DNBYjkgCgEvH7LOHmnP27ZMj1a0ai62Rc1eePWvkGhF17xw== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This is in preparation of converting the tx queue to struct sk_buffs entries. atomic_t isn't necessary for the current code, but it is a safe change. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/netdev.c | 3 ++- drivers/net/wireless/microchip/wilc1000/netdev.h | 2 +- drivers/net/wireless/microchip/wilc1000/wlan.c | 12 ++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c b/drivers/net/wireless/microchip/wilc1000/netdev.c index 4dd7c8137c204..3b9f5d3e65998 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.c +++ b/drivers/net/wireless/microchip/wilc1000/netdev.c @@ -149,7 +149,8 @@ static int wilc_txq_task(void *vp) complete(&wl->txq_thread_started); while (1) { wait_event_interruptible(wl->txq_event, - (wl->txq_entries > 0 || wl->close)); + (atomic_read(&wl->txq_entries) > 0 || + wl->close)); if (wl->close) { complete(&wl->txq_thread_started); diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h b/drivers/net/wireless/microchip/wilc1000/netdev.h index ce79bdcc28000..d51095ac54730 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.h +++ b/drivers/net/wireless/microchip/wilc1000/netdev.h @@ -253,7 +253,7 @@ struct wilc { u8 *tx_buffer; struct txq_handle txq[NQUEUES]; - int txq_entries; + atomic_t txq_entries; struct txq_fw_recv_queue_stat fw[NQUEUES]; struct wilc_tx_queue_status tx_q_limit; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index dd669f9ea88a8..8435e1abdd515 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -41,7 +41,7 @@ static void wilc_wlan_txq_remove(struct wilc *wilc, u8 q_num, struct txq_entry_t *tqe) { list_del(&tqe->list); - wilc->txq_entries -= 1; + atomic_dec(&wilc->txq_entries); wilc->txq[q_num].count--; } @@ -57,7 +57,7 @@ wilc_wlan_txq_remove_from_head(struct wilc *wilc, u8 q_num) tqe = list_first_entry(&wilc->txq[q_num].txq_head.list, struct txq_entry_t, list); list_del(&tqe->list); - wilc->txq_entries -= 1; + atomic_dec(&wilc->txq_entries); wilc->txq[q_num].count--; } spin_unlock_irqrestore(&wilc->txq_spinlock, flags); @@ -87,7 +87,7 @@ static void wilc_wlan_txq_add_to_tail(struct net_device *dev, u8 type, u8 q_num, spin_lock_irqsave(&wilc->txq_spinlock, flags); list_add_tail(&tqe->list, &wilc->txq[q_num].txq_head.list); - wilc->txq_entries += 1; + atomic_inc(&wilc->txq_entries); wilc->txq[q_num].count++; spin_unlock_irqrestore(&wilc->txq_spinlock, flags); @@ -108,7 +108,7 @@ static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, u8 type, u8 q_num, spin_lock_irqsave(&wilc->txq_spinlock, flags); list_add(&tqe->list, &wilc->txq[q_num].txq_head.list); - wilc->txq_entries += 1; + atomic_inc(&wilc->txq_entries); wilc->txq[q_num].count++; spin_unlock_irqrestore(&wilc->txq_spinlock, flags); @@ -484,7 +484,7 @@ int wilc_wlan_txq_add_net_pkt(struct net_device *dev, kfree(tqe); } - return wilc->txq_entries; + return atomic_read(&wilc->txq_entries); } int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer, @@ -952,7 +952,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) mutex_unlock(&wilc->txq_add_to_head_cs); out_update_cnt: - *txq_count = wilc->txq_entries; + *txq_count = atomic_read(&wilc->txq_entries); return ret; } From patchwork Sat Dec 18 23:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 526851 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E31EC4332F for ; Sat, 18 Dec 2021 23:55:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234948AbhLRXzR (ORCPT ); Sat, 18 Dec 2021 18:55:17 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25578 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234942AbhLRXyX (ORCPT ); Sat, 18 Dec 2021 18:54:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=IYmT6TTHPC/39vBU9dvhhZgPOg2hMoZjIu47+sZZ8/Y=; b=DrIkitBRj6SIJRBZaSVKO9ueK2xD5t8aW7naXhXX6fqRceeFVFdBfO6qms1f6TUJOZ0B 5q4UakY+CURZgJIzZSviRUm2dno4ILOZGAs0RxPaHPUZBNyevCy0Q6za1l1F9Dku7T+N1e qvpKMiL0Ra9OWv3UZevI5XfqyDKPkdAvFmeQvCehCxKzJw8UEo2JsZ+FMcaUOY4j6JUMOw IUG5YQaN4Yo7R++GSkOvO4WdsJYZflrvoNRr25SFiatTY0qO9uyEZq1lSgANYyhHVdqMZ0 kh9zehXwCJBRcIPH7GYujpQR5rmuOtwpQtqoiRwoBsA8vypIoYX3pzJDB/OWRZeA== Received: by filterdrecv-7bf5c69d5-rfl26 with SMTP id filterdrecv-7bf5c69d5-rfl26-1-61BE74A8-21 2021-12-18 23:54:16.88665959 +0000 UTC m=+9336805.628309366 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-3-1 (SG) with ESMTP id ha9uPykwTiKK9-3KpfG97g Sat, 18 Dec 2021 23:54:16.774 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id A620E701151; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 12/23] wilc1000: refactor wilc_wlan_cfg_commit() a bit Date: Sat, 18 Dec 2021 23:54:17 +0000 (UTC) Message-Id: <20211218235404.3963475-13-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvKs3SfP4/LmsE6Ln6mpnK0MOyjtcUUykcOLofxHKn7Tfu4mZexV0qSUeyJEITbq7Dtupz/czzZWZvHFrBH6gMI9ick4loi/RsyZXv4CerHUzSbt4B3KIfdxsqJZys7AM3q9VN7wnpyNmUf4iGjqAnRi5icejU0DOHDCnEWOZv0f/NBEA5drcIG5LsW32SZ4y7g== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This cleanup makes the switch to sk_buff queues easier. There is no functional change. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 8435e1abdd515..8cd2ede8d2775 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -1271,15 +1271,13 @@ static int wilc_wlan_cfg_commit(struct wilc_vif *vif, int type, struct wilc *wilc = vif->wilc; struct wilc_cfg_frame *cfg = &wilc->cfg_frame; int t_len = wilc->cfg_frame_offset + sizeof(struct wilc_cfg_cmd_hdr); + struct wilc_cfg_cmd_hdr *hdr; - if (type == WILC_CFG_SET) - cfg->hdr.cmd_type = 'W'; - else - cfg->hdr.cmd_type = 'Q'; - - cfg->hdr.seq_no = wilc->cfg_seq_no % 256; - cfg->hdr.total_len = cpu_to_le16(t_len); - cfg->hdr.driver_handler = cpu_to_le32(drv_handler); + hdr = &cfg->hdr; + hdr->cmd_type = (type == WILC_CFG_SET) ? 'W' : 'Q'; + hdr->seq_no = wilc->cfg_seq_no % 256; + hdr->total_len = cpu_to_le16(t_len); + hdr->driver_handler = cpu_to_le32(drv_handler); wilc->cfg_seq_no = cfg->hdr.seq_no; if (!wilc_wlan_txq_add_cfg_pkt(vif, (u8 *)&cfg->hdr, t_len)) From patchwork Sat Dec 18 23:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 526858 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA483C46467 for ; Sat, 18 Dec 2021 23:54:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234929AbhLRXyb (ORCPT ); Sat, 18 Dec 2021 18:54:31 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25502 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234912AbhLRXyT (ORCPT ); Sat, 18 Dec 2021 18:54:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=7Hm3AquiIUdJpoJNmQhIPdf9H6zGdNGjNitvQcp4Vl0=; b=ddhf6b2F3RJn2Yy14Q6Dw8PQ9gtWMXLY8IZbWymw15cu5JVGDgf1I3ZEy9b9CRG653oU VRxbhlEe6GBVHVHcb1NOi/MaEwb0J9CeSU+ipaewOqV3o0RpCCMWeBi0LqtA9lPn1AX8Wi zqRSanNOwvwsC1lfsBAuAgBBfI4+f07Oi3J3KMSn7UOHAuge7TwGoyX4cWpEBwnv082fWi BqcFes1EyYKgR04fgapAF4cYYRyT7P8CHFgYdewB4Qe/x7WUkiZU1lIc20r0FlkLWqqFRU Z29HLdMGEGfWCTaTTXUTYWvnom+U3GTwvQRUuTWdtUtnC4SDsGJHkeYC6/56kFKg== Received: by filterdrecv-64fcb979b9-5m6bg with SMTP id filterdrecv-64fcb979b9-5m6bg-1-61BE74A8-2F 2021-12-18 23:54:16.939374845 +0000 UTC m=+8294248.906437584 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-5-0 (SG) with ESMTP id 4Ej3bdy0SEWVNGLRE4ciEw Sat, 18 Dec 2021 23:54:16.765 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id AA5217011B9; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 13/23] wilc1000: sanitize config packet sequence number management a bit Date: Sat, 18 Dec 2021 23:54:17 +0000 (UTC) Message-Id: <20211218235404.3963475-14-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvDr8Y3qBfvE6zFPF5khqlKFLZiUwzYO3DHUibB8X0HYh+GG7ArmgdxbkXEpYA2o6RQVm88pm2K11mbywCAqW2OlaroGGNuQQcYVbuBObPCulrvv+wuJ/2gbHajiayseYAfJCOfdr3FWzFbJWPEpPpAVZMSHNOOI52RZl5lUKLRY22gF9i8/xRG5JedYvhwIz9w== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Always keep the config packet sequence number in the valid range from 0..255. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 8cd2ede8d2775..6484e4ab8e159 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -1275,10 +1275,9 @@ static int wilc_wlan_cfg_commit(struct wilc_vif *vif, int type, hdr = &cfg->hdr; hdr->cmd_type = (type == WILC_CFG_SET) ? 'W' : 'Q'; - hdr->seq_no = wilc->cfg_seq_no % 256; + hdr->seq_no = wilc->cfg_seq_no; hdr->total_len = cpu_to_le16(t_len); hdr->driver_handler = cpu_to_le32(drv_handler); - wilc->cfg_seq_no = cfg->hdr.seq_no; if (!wilc_wlan_txq_add_cfg_pkt(vif, (u8 *)&cfg->hdr, t_len)) return -1; @@ -1333,7 +1332,7 @@ static int wilc_wlan_cfg_apply_wid(struct wilc_vif *vif, int start, u16 wid, } wilc->cfg_frame_offset = 0; - wilc->cfg_seq_no += 1; + wilc->cfg_seq_no = (wilc->cfg_seq_no + 1) % 256; mutex_unlock(&wilc->cfg_cmd_lock); return ret_size; From patchwork Sat Dec 18 23:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 525820 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73C6BC43217 for ; Sat, 18 Dec 2021 23:55:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235410AbhLRXzD (ORCPT ); Sat, 18 Dec 2021 18:55:03 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25654 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234953AbhLRXyZ (ORCPT ); Sat, 18 Dec 2021 18:54:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=CGtla6DXX2NW6UxMvorEq0hg5En8baXls+s5VuU2yW4=; b=ZT3DPigF+8Yzg//T+tvalTQV4U/iqz+uDPUDgYectHbd8Wz+Did4jaNjpb1YGt6K8Rqc RgZb/DGQK7zMwVNzzNn1WsyuDe2ETacSJ/C3U/BS6wzMUpn+8ZTpISTYYc28E68DCIFgch 0loZmI1hf2frplbHUGPDkRsLy39w8cYEvX644u8W6bX8SPEThdb11Rdx19WNdvcFNhqwBs znplANeHSIYiKHcS5cEobKbjl8ZVGi2DwV7Hf/Wm3GRLqpXDWCWc0hrgJNuyGz+Cg3N4ya 4/bbiDzuadYC0gAjkbA3smcEuQQ+/cunsH09Xs9z5/lS83iE3AlIN59zjTtZB71A== Received: by filterdrecv-75ff7b5ffb-bdt5z with SMTP id filterdrecv-75ff7b5ffb-bdt5z-1-61BE74A8-34 2021-12-18 23:54:16.964242185 +0000 UTC m=+9336801.486918079 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-3-1 (SG) with ESMTP id wkYIxbwqTFmuQuj_BBAN5w Sat, 18 Dec 2021 23:54:16.793 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id AFA9870122E; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 14/23] wilc1000: if there is no tx packet, don't increment packets-sent counter Date: Sat, 18 Dec 2021 23:54:17 +0000 (UTC) Message-Id: <20211218235404.3963475-15-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvIzRn4xIwWHyaaa0MuWcdn1anLz9y3H4r2KThLcMiVEY0EIxgr1EXfxoyFPRY3oI2uiNhcfBpx5zzTshO9hQbJm3euZxhJnyVVOxbqUUFd+iJm7qgEuwZcGcgA/M3hx59k4Aby5GJp1Sq/DRyrNsOQMJNZ4j7Kqsa7F1rOV7uKAn4il58qhYl/8tLZA4p4eJPg== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Granted, this case is mostly theoretical as the queue should never be empty in this place, and hence tqe should never be NULL, but it's still wrong to count a packet that doesn't exist. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 6484e4ab8e159..8e8f0e1de7c4c 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -893,10 +893,10 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) u8 mgmt_ptk = 0; tqe = wilc_wlan_txq_remove_from_head(wilc, vmm_entries_ac[i]); - ac_pkt_num_to_chip[vmm_entries_ac[i]]++; if (!tqe) break; + ac_pkt_num_to_chip[vmm_entries_ac[i]]++; vif = tqe->vif; if (vmm_table[i] == 0) break; From patchwork Sat Dec 18 23:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 526857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B824DC433EF for ; Sat, 18 Dec 2021 23:54:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235115AbhLRXye (ORCPT ); Sat, 18 Dec 2021 18:54:34 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25780 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232124AbhLRXy2 (ORCPT ); Sat, 18 Dec 2021 18:54:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=wXJ8jyflf28hczVeoapfI+zLJtAIzw0kgB1Rd3nDo68=; b=OcMZkzSnIyZf0KSpnqQwypUXzWinuVHeNC7ddpKhOuTIW9fiwGKr7i7CUe+dttX1Y/Me H0Rvyk11XUQTJb0vmQlvif1nGeYHfUdfVcT1ME1Y96nAA5EhCVv9ti09caxzhwdnEgBlz/ q0eywJcWnkZ6y9Vw5wmhM5AbISMwmm3cdu3hMr8Hhantxlvh4llDislyyJCt/1k0Pw8M5v 03RuqSEAO/BvdrvO0v8Pa1ca9DsrOcYUybYfj5Z00+oug2Hz1UWobDBKR6tIzLTOmsAgLc 2INLXU3TKYE6JovigKC/rQCwwO7BPpt1iGh2hxm1gK3wRZTfMHwSRUeshsEyop6Q== Received: by filterdrecv-75ff7b5ffb-t2q6v with SMTP id filterdrecv-75ff7b5ffb-t2q6v-1-61BE74A9-5 2021-12-18 23:54:17.337370383 +0000 UTC m=+9336822.611466926 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-3-1 (SG) with ESMTP id 1rnIf73FSYCcOAi5N-JBDw Sat, 18 Dec 2021 23:54:17.118 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id B58607013A0; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 15/23] wilc1000: Add struct wilc_skb_tx_cb as an alias of struct txq_entry_t Date: Sat, 18 Dec 2021 23:54:17 +0000 (UTC) Message-Id: <20211218235404.3963475-16-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvKY38+15DLPpdGiaQqaVf5xb7LxNXaarsCTetHxyMvozt3vxaQkztXwbTSM1nvDlpUbjxiuIr2AJslMA3TLSH5w4gso7Om8A5kuBiRMsOHsedLTZdgxcWqfNMGkM4ihCJas32uTf2xC2Pytk3dfkiK6YdW3DZupVFOAGLPiXwQsOuUxrrKKLSkwkeRUWn8Q5xQ== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This is in preparation of the next patch, which removes struct wilc_skb_tx_cb in favor of struct sk_buffs. That change requires moving the driver-private state for tx packets from struct txq_entry_t to the "control buffer" (cb field) of struct sk_buff. Making that move now makes the next patch a bit smaller and easier to understand. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/wlan.c | 36 +++++++++++-------- .../net/wireless/microchip/wilc1000/wlan.h | 7 ++++ 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 8e8f0e1de7c4c..5aa7bcf82054f 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -67,10 +67,12 @@ wilc_wlan_txq_remove_from_head(struct wilc *wilc, u8 q_num) static void init_txq_entry(struct txq_entry_t *tqe, struct wilc_vif *vif, u8 type, enum ip_pkt_priority q_num) { + struct wilc_skb_tx_cb *tx_cb = WILC_SKB_TX_CB(tqe); + tqe->vif = vif; - tqe->q_num = q_num; - tqe->type = type; - tqe->ack_idx = NOT_TCP_ACK; + tx_cb->type = type; + tx_cb->q_num = q_num; + tx_cb->ack_idx = NOT_TCP_ACK; } static void wilc_wlan_txq_add_to_tail(struct net_device *dev, u8 type, u8 q_num, @@ -143,6 +145,7 @@ static inline void add_tcp_pending_ack(struct wilc_vif *vif, u32 ack, u32 session_index, struct txq_entry_t *txqe) { + struct wilc_skb_tx_cb *tx_cb = WILC_SKB_TX_CB(txqe); struct tcp_ack_filter *f = &vif->ack_filter; u32 i = f->pending_base + f->pending_acks_idx; @@ -150,7 +153,7 @@ static inline void add_tcp_pending_ack(struct wilc_vif *vif, u32 ack, f->pending_acks[i].ack_num = ack; f->pending_acks[i].txqe = txqe; f->pending_acks[i].session_index = session_index; - txqe->ack_idx = i; + tx_cb->ack_idx = i; f->pending_acks_idx++; } } @@ -210,7 +213,8 @@ static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe) static void wilc_wlan_tx_packet_done(struct txq_entry_t *tqe, int status) { struct wilc_vif *vif = tqe->vif; - int ack_idx = tqe->ack_idx; + struct wilc_skb_tx_cb *tx_cb = WILC_SKB_TX_CB(tqe); + int ack_idx = tx_cb->ack_idx; tqe->status = status; if (tqe->tx_complete_func) @@ -224,10 +228,11 @@ static void wilc_wlan_txq_drop_net_pkt(struct txq_entry_t *tqe) { struct wilc_vif *vif = tqe->vif; struct wilc *wilc = vif->wilc; + struct wilc_skb_tx_cb *tx_cb = WILC_SKB_TX_CB(tqe); vif->ndev->stats.tx_dropped++; - wilc_wlan_txq_remove(wilc, tqe->q_num, tqe); + wilc_wlan_txq_remove(wilc, tx_cb->q_num, tqe); wilc_wlan_tx_packet_done(tqe, 1); } @@ -728,6 +733,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) bool max_size_over = 0, ac_exist = 0; int vmm_sz = 0; struct txq_entry_t *tqe_q[NQUEUES]; + struct wilc_skb_tx_cb *tx_cb; int ret = 0; int counter; int timeout; @@ -772,9 +778,10 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) break; } - if (tqe_q[ac]->type == WILC_CFG_PKT) + tx_cb = WILC_SKB_TX_CB(tqe_q[ac]); + if (tx_cb->type == WILC_CFG_PKT) vmm_sz = ETH_CONFIG_PKT_HDR_OFFSET; - else if (tqe_q[ac]->type == WILC_NET_PKT) + else if (tx_cb->type == WILC_NET_PKT) vmm_sz = ETH_ETHERNET_HDR_OFFSET; else vmm_sz = HOST_HDR_OFFSET; @@ -787,7 +794,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) break; } vmm_table[i] = vmm_sz / 4; - if (tqe_q[ac]->type == WILC_CFG_PKT) + if (tx_cb->type == WILC_CFG_PKT) vmm_table[i] |= BIT(10); cpu_to_le32s(&vmm_table[i]); @@ -898,6 +905,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) ac_pkt_num_to_chip[vmm_entries_ac[i]]++; vif = tqe->vif; + tx_cb = WILC_SKB_TX_CB(tqe); if (vmm_table[i] == 0) break; @@ -905,20 +913,20 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) vmm_sz = FIELD_GET(WILC_VMM_BUFFER_SIZE, vmm_table[i]); vmm_sz *= 4; - if (tqe->type == WILC_MGMT_PKT) + if (tx_cb->type == WILC_MGMT_PKT) mgmt_ptk = 1; - header = (FIELD_PREP(WILC_VMM_HDR_TYPE, tqe->type) | + header = (FIELD_PREP(WILC_VMM_HDR_TYPE, tx_cb->type) | FIELD_PREP(WILC_VMM_HDR_MGMT_FIELD, mgmt_ptk) | FIELD_PREP(WILC_VMM_HDR_PKT_SIZE, tqe->buffer_size) | FIELD_PREP(WILC_VMM_HDR_BUFF_SIZE, vmm_sz)); cpu_to_le32s(&header); memcpy(&txb[offset], &header, 4); - if (tqe->type == WILC_CFG_PKT) { + if (tx_cb->type == WILC_CFG_PKT) { buffer_offset = ETH_CONFIG_PKT_HDR_OFFSET; - } else if (tqe->type == WILC_NET_PKT) { - int prio = tqe->q_num; + } else if (tx_cb->type == WILC_NET_PKT) { + int prio = tx_cb->q_num; bssid = tqe->vif->bssid; buffer_offset = ETH_ETHERNET_HDR_OFFSET; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/wireless/microchip/wilc1000/wlan.h index 9b33262909e2f..295795a8060ac 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.h +++ b/drivers/net/wireless/microchip/wilc1000/wlan.h @@ -333,6 +333,13 @@ struct txq_entry_t { void (*tx_complete_func)(void *priv, int status); }; +#define wilc_skb_tx_cb txq_entry_t + +static inline struct wilc_skb_tx_cb *WILC_SKB_TX_CB(struct txq_entry_t *tqe) +{ + return (struct wilc_skb_tx_cb *)tqe; +} + struct txq_fw_recv_queue_stat { u8 acm; u8 count; From patchwork Sat Dec 18 23:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 525823 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B60EC43217 for ; Sat, 18 Dec 2021 23:54:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235211AbhLRXyu (ORCPT ); Sat, 18 Dec 2021 18:54:50 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25752 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234973AbhLRXy0 (ORCPT ); Sat, 18 Dec 2021 18:54:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=6bm6GaVrFVyGxIa+u0bdAM005qCc6IHaNtcpg3n3Cis=; b=mNCg9gyxbFEm4t+2nZaKg+ReH6UC8hwy6iQNulY/RmrbBOhXDBTxpSbEmUItbj7ME0HA 3wr3OJNjuLqm1gxkydD6Iv6rwXc98PBnLVXbjXUdEOGOQP01a3I64KZt03QHOMp1tge/ec xeKChjmf1eyLhHDfoqE0TDs2ymwL0/YRhqS55ey6fwB39h5ggAQB1zoXoWutG/DzFwYY+w p++3ztfxhrFkR+2kXBsolHF4+KiuO4nvFnyRZio5d35njlb7a2fwHALzw9iAMC93rbJlr+ 8rlsfJky9b9cAHm40gaCEmM+RdNofCvYQRK4ouhf2daOhcyCJ5PfRfAtA8JNI+AA== Received: by filterdrecv-656998cfdd-tjhxw with SMTP id filterdrecv-656998cfdd-tjhxw-1-61BE74A9-3 2021-12-18 23:54:17.157397676 +0000 UTC m=+7604817.697548777 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-6-0 (SG) with ESMTP id 8iAXlL18QCOTQo2pL-qrTA Sat, 18 Dec 2021 23:54:16.971 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id BC2727013D3; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 16/23] wilc1000: switch tx queue to normal sk_buff entries Date: Sat, 18 Dec 2021 23:54:17 +0000 (UTC) Message-Id: <20211218235404.3963475-17-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvGe4xDYjVShlPTBTg4HGK4jZy482UvybMVz1bUfniX9mYpfddjn/2s+uoy4rGBOue5iTJzW+DOfydpHws0MdvzdKg0GqnXKtwk8Uf0Gb4rkcq4f7usSSaHbW3PbN76xnWTW4cT09vhqfOjeSL4rRR9xqGniWwOsXHOeyO5Xjh9ETG7SsgY7croqzI3gSwcNBZQ== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Convert to the transmit path to use normal socket-buffer operations rather than driver-specific structures and functions. This ends up deleting a fair amount of code and otherwise mostly consists of switching struct txq_entry_t to struct sk_buff. Signed-off-by: David Mosberger-Tang --- .../wireless/microchip/wilc1000/cfg80211.c | 35 +-- drivers/net/wireless/microchip/wilc1000/mon.c | 36 +-- .../net/wireless/microchip/wilc1000/netdev.c | 26 +- .../net/wireless/microchip/wilc1000/netdev.h | 7 +- .../net/wireless/microchip/wilc1000/wlan.c | 281 +++++++----------- .../net/wireless/microchip/wilc1000/wlan.h | 50 +--- 6 files changed, 137 insertions(+), 298 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.c b/drivers/net/wireless/microchip/wilc1000/cfg80211.c index be387a8abb6af..d352b7dd03283 100644 --- a/drivers/net/wireless/microchip/wilc1000/cfg80211.c +++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.c @@ -1038,14 +1038,6 @@ void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size) cfg80211_rx_mgmt(&priv->wdev, freq, 0, buff, size, 0); } -static void wilc_wfi_mgmt_tx_complete(void *priv, int status) -{ - struct wilc_p2p_mgmt_data *pv_data = priv; - - kfree(pv_data->buff); - kfree(pv_data); -} - static void wilc_wfi_remain_on_channel_expired(void *data, u64 cookie) { struct wilc_vif *vif = data; @@ -1124,7 +1116,7 @@ static int mgmt_tx(struct wiphy *wiphy, const u8 *buf = params->buf; size_t len = params->len; const struct ieee80211_mgmt *mgmt; - struct wilc_p2p_mgmt_data *mgmt_tx; + struct sk_buff *skb; struct wilc_vif *vif = netdev_priv(wdev->netdev); struct wilc_priv *priv = &vif->priv; struct host_if_drv *wfi_drv = priv->hif_drv; @@ -1141,20 +1133,11 @@ static int mgmt_tx(struct wiphy *wiphy, if (!ieee80211_is_mgmt(mgmt->frame_control)) goto out; - mgmt_tx = kmalloc(sizeof(*mgmt_tx), GFP_KERNEL); - if (!mgmt_tx) { - ret = -ENOMEM; - goto out; - } - - mgmt_tx->buff = kmemdup(buf, len, GFP_KERNEL); - if (!mgmt_tx->buff) { - ret = -ENOMEM; - kfree(mgmt_tx); - goto out; - } + skb = wilc_wlan_alloc_skb(vif, len); + if (!skb) + return -ENOMEM; - mgmt_tx->size = len; + skb_put_data(skb, buf, len); if (ieee80211_is_probe_resp(mgmt->frame_control)) { wilc_set_mac_chnl_num(vif, chan->hw_value); @@ -1176,7 +1159,7 @@ static int mgmt_tx(struct wiphy *wiphy, goto out_set_timeout; vendor_ie = cfg80211_find_vendor_ie(WLAN_OUI_WFA, WLAN_OUI_TYPE_WFA_P2P, - mgmt_tx->buff + ie_offset, + skb->data + ie_offset, len - ie_offset); if (!vendor_ie) goto out_set_timeout; @@ -1189,9 +1172,7 @@ static int mgmt_tx(struct wiphy *wiphy, out_txq_add_pkt: - wilc_wlan_txq_add_mgmt_pkt(wdev->netdev, mgmt_tx, - mgmt_tx->buff, mgmt_tx->size, - wilc_wfi_mgmt_tx_complete); + wilc_wlan_txq_add_mgmt_pkt(wdev->netdev, skb); out: @@ -1732,7 +1713,7 @@ int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type, wl->hif_func = ops; for (i = 0; i < NQUEUES; i++) - INIT_LIST_HEAD(&wl->txq[i].txq_head.list); + skb_queue_head_init(&wl->txq[i]); INIT_LIST_HEAD(&wl->rxq_head.list); INIT_LIST_HEAD(&wl->vif_list); diff --git a/drivers/net/wireless/microchip/wilc1000/mon.c b/drivers/net/wireless/microchip/wilc1000/mon.c index 6bd63934c2d84..0b1c4f266cca5 100644 --- a/drivers/net/wireless/microchip/wilc1000/mon.c +++ b/drivers/net/wireless/microchip/wilc1000/mon.c @@ -95,45 +95,21 @@ void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size) netif_rx(skb); } -struct tx_complete_mon_data { - int size; - void *buff; -}; - -static void mgmt_tx_complete(void *priv, int status) -{ - struct tx_complete_mon_data *pv_data = priv; - /* - * in case of fully hosting mode, the freeing will be done - * in response to the cfg packet - */ - kfree(pv_data->buff); - - kfree(pv_data); -} - static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len) { - struct tx_complete_mon_data *mgmt_tx = NULL; + struct wilc_vif *vif = netdev_priv(dev); + struct sk_buff *skb; if (!dev) return -EFAULT; netif_stop_queue(dev); - mgmt_tx = kmalloc(sizeof(*mgmt_tx), GFP_ATOMIC); - if (!mgmt_tx) - return -ENOMEM; - - mgmt_tx->buff = kmemdup(buf, len, GFP_ATOMIC); - if (!mgmt_tx->buff) { - kfree(mgmt_tx); + skb = wilc_wlan_alloc_skb(vif, len); + if (!skb) return -ENOMEM; - } - - mgmt_tx->size = len; + skb_put_data(skb, buf, len); - wilc_wlan_txq_add_mgmt_pkt(dev, mgmt_tx, mgmt_tx->buff, mgmt_tx->size, - mgmt_tx_complete); + wilc_wlan_txq_add_mgmt_pkt(dev, skb); netif_wake_queue(dev); return 0; diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c b/drivers/net/wireless/microchip/wilc1000/netdev.c index 3b9f5d3e65998..a766687d6ef22 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.c +++ b/drivers/net/wireless/microchip/wilc1000/netdev.c @@ -718,19 +718,10 @@ static void wilc_set_multicast_list(struct net_device *dev) kfree(mc_list); } -static void wilc_tx_complete(void *priv, int status) -{ - struct tx_complete_data *pv_data = priv; - - dev_kfree_skb(pv_data->skb); - kfree(pv_data); -} - netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev) { struct wilc_vif *vif = netdev_priv(ndev); struct wilc *wilc = vif->wilc; - struct tx_complete_data *tx_data = NULL; int queue_count; if (skb->dev != ndev) { @@ -738,22 +729,9 @@ netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev) return NETDEV_TX_OK; } - tx_data = kmalloc(sizeof(*tx_data), GFP_ATOMIC); - if (!tx_data) { - dev_kfree_skb(skb); - netif_wake_queue(ndev); - return NETDEV_TX_OK; - } - - tx_data->buff = skb->data; - tx_data->size = skb->len; - tx_data->skb = skb; - vif->netstats.tx_packets++; - vif->netstats.tx_bytes += tx_data->size; - queue_count = wilc_wlan_txq_add_net_pkt(ndev, tx_data, - tx_data->buff, tx_data->size, - wilc_tx_complete); + vif->netstats.tx_bytes += skb->len; + queue_count = wilc_wlan_txq_add_net_pkt(ndev, skb); if (queue_count > FLOW_CONTROL_UPPER_THRESHOLD) { int srcu_idx; diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h b/drivers/net/wireless/microchip/wilc1000/netdev.h index d51095ac54730..6a135b4d7e3f0 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.h +++ b/drivers/net/wireless/microchip/wilc1000/netdev.h @@ -163,7 +163,7 @@ struct ack_session_info { struct pending_acks { u32 ack_num; u32 session_index; - struct txq_entry_t *txqe; + struct sk_buff *txqe; }; struct tcp_ack_filter { @@ -244,15 +244,14 @@ struct wilc { /* lock to protect issue of wid command to firmware */ struct mutex cfg_cmd_lock; - struct wilc_cfg_frame cfg_frame; - u32 cfg_frame_offset; + struct sk_buff *cfg_skb; u8 cfg_seq_no; u8 *rx_buffer; u32 rx_buffer_offset; u8 *tx_buffer; - struct txq_handle txq[NQUEUES]; + struct sk_buff_head txq[NQUEUES]; atomic_t txq_entries; struct txq_fw_recv_queue_stat fw[NQUEUES]; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 5aa7bcf82054f..f895e4dd2e73f 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -16,7 +16,7 @@ static const u8 factors[NQUEUES] = {1, 1, 1, 1}; -static void tcp_process(struct net_device *, struct txq_entry_t *); +static void tcp_process(struct net_device *, struct sk_buff *); static inline bool is_wilc1000(u32 id) { @@ -37,48 +37,19 @@ static inline void release_bus(struct wilc *wilc, enum bus_release release) mutex_unlock(&wilc->hif_cs); } -static void wilc_wlan_txq_remove(struct wilc *wilc, u8 q_num, - struct txq_entry_t *tqe) -{ - list_del(&tqe->list); - atomic_dec(&wilc->txq_entries); - wilc->txq[q_num].count--; -} - -static struct txq_entry_t * -wilc_wlan_txq_remove_from_head(struct wilc *wilc, u8 q_num) -{ - struct txq_entry_t *tqe = NULL; - unsigned long flags; - - spin_lock_irqsave(&wilc->txq_spinlock, flags); - - if (!list_empty(&wilc->txq[q_num].txq_head.list)) { - tqe = list_first_entry(&wilc->txq[q_num].txq_head.list, - struct txq_entry_t, list); - list_del(&tqe->list); - atomic_dec(&wilc->txq_entries); - wilc->txq[q_num].count--; - } - spin_unlock_irqrestore(&wilc->txq_spinlock, flags); - return tqe; -} - -static void init_txq_entry(struct txq_entry_t *tqe, struct wilc_vif *vif, +static void init_txq_entry(struct sk_buff *tqe, struct wilc_vif *vif, u8 type, enum ip_pkt_priority q_num) { struct wilc_skb_tx_cb *tx_cb = WILC_SKB_TX_CB(tqe); - tqe->vif = vif; tx_cb->type = type; tx_cb->q_num = q_num; tx_cb->ack_idx = NOT_TCP_ACK; } static void wilc_wlan_txq_add_to_tail(struct net_device *dev, u8 type, u8 q_num, - struct txq_entry_t *tqe) + struct sk_buff *tqe) { - unsigned long flags; struct wilc_vif *vif = netdev_priv(dev); struct wilc *wilc = vif->wilc; @@ -86,34 +57,24 @@ static void wilc_wlan_txq_add_to_tail(struct net_device *dev, u8 type, u8 q_num, if (type == WILC_NET_PKT && vif->ack_filter.enabled) tcp_process(dev, tqe); - spin_lock_irqsave(&wilc->txq_spinlock, flags); - - list_add_tail(&tqe->list, &wilc->txq[q_num].txq_head.list); + skb_queue_tail(&wilc->txq[q_num], tqe); atomic_inc(&wilc->txq_entries); - wilc->txq[q_num].count++; - - spin_unlock_irqrestore(&wilc->txq_spinlock, flags); wake_up_interruptible(&wilc->txq_event); } static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, u8 type, u8 q_num, - struct txq_entry_t *tqe) + struct sk_buff *tqe) { - unsigned long flags; struct wilc *wilc = vif->wilc; init_txq_entry(tqe, vif, type, q_num); mutex_lock(&wilc->txq_add_to_head_cs); - spin_lock_irqsave(&wilc->txq_spinlock, flags); - - list_add(&tqe->list, &wilc->txq[q_num].txq_head.list); + skb_queue_head(&wilc->txq[q_num], tqe); atomic_inc(&wilc->txq_entries); - wilc->txq[q_num].count++; - spin_unlock_irqrestore(&wilc->txq_spinlock, flags); mutex_unlock(&wilc->txq_add_to_head_cs); wake_up_interruptible(&wilc->txq_event); } @@ -143,7 +104,7 @@ static inline void update_tcp_session(struct wilc_vif *vif, u32 index, u32 ack) static inline void add_tcp_pending_ack(struct wilc_vif *vif, u32 ack, u32 session_index, - struct txq_entry_t *txqe) + struct sk_buff *txqe) { struct wilc_skb_tx_cb *tx_cb = WILC_SKB_TX_CB(txqe); struct tcp_ack_filter *f = &vif->ack_filter; @@ -158,9 +119,9 @@ static inline void add_tcp_pending_ack(struct wilc_vif *vif, u32 ack, } } -static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe) +static inline void tcp_process(struct net_device *dev, struct sk_buff *tqe) { - void *buffer = tqe->buffer; + void *buffer = tqe->data; const struct ethhdr *eth_hdr_ptr = buffer; int i; unsigned long flags; @@ -210,29 +171,30 @@ static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe) spin_unlock_irqrestore(&wilc->txq_spinlock, flags); } -static void wilc_wlan_tx_packet_done(struct txq_entry_t *tqe, int status) +static void wilc_wlan_tx_packet_done(struct sk_buff *tqe, int status) { - struct wilc_vif *vif = tqe->vif; + struct wilc_vif *vif = netdev_priv(tqe->dev); struct wilc_skb_tx_cb *tx_cb = WILC_SKB_TX_CB(tqe); int ack_idx = tx_cb->ack_idx; - tqe->status = status; - if (tqe->tx_complete_func) - tqe->tx_complete_func(tqe->priv, tqe->status); if (ack_idx != NOT_TCP_ACK && ack_idx < MAX_PENDING_ACKS) vif->ack_filter.pending_acks[ack_idx].txqe = NULL; - kfree(tqe); + if (status) + dev_consume_skb_any(tqe); + else + dev_kfree_skb_any(tqe); } -static void wilc_wlan_txq_drop_net_pkt(struct txq_entry_t *tqe) +static void wilc_wlan_txq_drop_net_pkt(struct sk_buff *tqe) { - struct wilc_vif *vif = tqe->vif; + struct wilc_vif *vif = netdev_priv(tqe->dev); struct wilc *wilc = vif->wilc; struct wilc_skb_tx_cb *tx_cb = WILC_SKB_TX_CB(tqe); vif->ndev->stats.tx_dropped++; - wilc_wlan_txq_remove(wilc, tx_cb->q_num, tqe); + skb_unlink(tqe, &wilc->txq[tx_cb->q_num]); + atomic_dec(&wilc->txq_entries); wilc_wlan_tx_packet_done(tqe, 1); } @@ -261,7 +223,7 @@ static void wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) bigger_ack_num = f->ack_session_info[index].bigger_ack_num; if (f->pending_acks[i].ack_num < bigger_ack_num) { - struct txq_entry_t *tqe; + struct sk_buff *tqe; tqe = f->pending_acks[i].txqe; if (tqe) @@ -284,30 +246,17 @@ void wilc_enable_tcp_ack_filter(struct wilc_vif *vif, bool value) vif->ack_filter.enabled = value; } -static int wilc_wlan_txq_add_cfg_pkt(struct wilc_vif *vif, u8 *buffer, - u32 buffer_size) +static int wilc_wlan_txq_add_cfg_pkt(struct wilc_vif *vif, struct sk_buff *tqe) { - struct txq_entry_t *tqe; struct wilc *wilc = vif->wilc; netdev_dbg(vif->ndev, "Adding config packet ...\n"); if (wilc->quit) { netdev_dbg(vif->ndev, "Return due to clear function\n"); - complete(&wilc->cfg_event); - return 0; - } - - tqe = kmalloc(sizeof(*tqe), GFP_ATOMIC); - if (!tqe) { - complete(&wilc->cfg_event); + dev_kfree_skb_any(tqe); return 0; } - tqe->buffer = buffer; - tqe->buffer_size = buffer_size; - tqe->tx_complete_func = NULL; - tqe->priv = NULL; - wilc_wlan_txq_add_to_head(vif, WILC_CFG_PKT, AC_VO_Q, tqe); return 1; @@ -354,7 +303,7 @@ static bool is_ac_q_limit(struct wilc *wl, u8 q_num) else q_limit = (q->cnt[q_num] * FLOW_CONTROL_UPPER_THRESHOLD / q->sum) + 1; - if (wl->txq[q_num].count <= q_limit) + if (skb_queue_len(&wl->txq[q_num]) <= q_limit) ret = true; spin_unlock_irqrestore(&wl->txq_spinlock, flags); @@ -442,12 +391,8 @@ static inline u8 ac_change(struct wilc *wilc, u8 *ac) return 1; } -int wilc_wlan_txq_add_net_pkt(struct net_device *dev, - struct tx_complete_data *tx_data, u8 *buffer, - u32 buffer_size, - void (*tx_complete_fn)(void *, int)) +int wilc_wlan_txq_add_net_pkt(struct net_device *dev, struct sk_buff *tqe) { - struct txq_entry_t *tqe; struct wilc_vif *vif = netdev_priv(dev); struct wilc *wilc; u8 q_num; @@ -455,109 +400,50 @@ int wilc_wlan_txq_add_net_pkt(struct net_device *dev, wilc = vif->wilc; if (wilc->quit) { - tx_complete_fn(tx_data, 0); + dev_kfree_skb_any(tqe); return 0; } if (!wilc->initialized) { - tx_complete_fn(tx_data, 0); + dev_kfree_skb_any(tqe); return 0; } - tqe = kmalloc(sizeof(*tqe), GFP_ATOMIC); - - if (!tqe) { - tx_complete_fn(tx_data, 0); - return 0; - } - tqe->buffer = buffer; - tqe->buffer_size = buffer_size; - tqe->tx_complete_func = tx_complete_fn; - tqe->priv = tx_data; - - q_num = ac_classify(wilc, tx_data->skb); + q_num = ac_classify(wilc, tqe); if (ac_change(wilc, &q_num)) { - tx_complete_fn(tx_data, 0); - kfree(tqe); + dev_kfree_skb_any(tqe); return 0; } if (is_ac_q_limit(wilc, q_num)) { wilc_wlan_txq_add_to_tail(dev, WILC_NET_PKT, q_num, tqe); } else { - tx_complete_fn(tx_data, 0); - kfree(tqe); + dev_kfree_skb(tqe); } return atomic_read(&wilc->txq_entries); } -int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer, - u32 buffer_size, - void (*tx_complete_fn)(void *, int)) +int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, struct sk_buff *tqe) { - struct txq_entry_t *tqe; struct wilc_vif *vif = netdev_priv(dev); struct wilc *wilc; wilc = vif->wilc; if (wilc->quit) { - tx_complete_fn(priv, 0); + dev_kfree_skb_any(tqe); return 0; } if (!wilc->initialized) { - tx_complete_fn(priv, 0); + dev_kfree_skb_any(tqe); return 0; } - tqe = kmalloc(sizeof(*tqe), GFP_ATOMIC); - - if (!tqe) { - tx_complete_fn(priv, 0); - return 0; - } - tqe->buffer = buffer; - tqe->buffer_size = buffer_size; - tqe->tx_complete_func = tx_complete_fn; - tqe->priv = priv; wilc_wlan_txq_add_to_tail(dev, WILC_MGMT_PKT, AC_VO_Q, tqe); return 1; } -static struct txq_entry_t *wilc_wlan_txq_get_first(struct wilc *wilc, u8 q_num) -{ - struct txq_entry_t *tqe = NULL; - unsigned long flags; - - spin_lock_irqsave(&wilc->txq_spinlock, flags); - - if (!list_empty(&wilc->txq[q_num].txq_head.list)) - tqe = list_first_entry(&wilc->txq[q_num].txq_head.list, - struct txq_entry_t, list); - - spin_unlock_irqrestore(&wilc->txq_spinlock, flags); - - return tqe; -} - -static struct txq_entry_t *wilc_wlan_txq_get_next(struct wilc *wilc, - struct txq_entry_t *tqe, - u8 q_num) -{ - unsigned long flags; - - spin_lock_irqsave(&wilc->txq_spinlock, flags); - - if (!list_is_last(&tqe->list, &wilc->txq[q_num].txq_head.list)) - tqe = list_next_entry(tqe, list); - else - tqe = NULL; - spin_unlock_irqrestore(&wilc->txq_spinlock, flags); - - return tqe; -} - static void wilc_wlan_rxq_add(struct wilc *wilc, struct rxq_entry_t *rqe) { if (wilc->quit) @@ -732,7 +618,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) u32 offset = 0; bool max_size_over = 0, ac_exist = 0; int vmm_sz = 0; - struct txq_entry_t *tqe_q[NQUEUES]; + struct sk_buff *tqe_q[NQUEUES]; struct wilc_skb_tx_cb *tx_cb; int ret = 0; int counter; @@ -758,7 +644,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) srcu_read_unlock(&wilc->srcu, srcu_idx); for (ac = 0; ac < NQUEUES; ac++) - tqe_q[ac] = wilc_wlan_txq_get_first(wilc, ac); + tqe_q[ac] = skb_peek(&wilc->txq[ac]); i = 0; sum = 0; @@ -786,7 +672,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) else vmm_sz = HOST_HDR_OFFSET; - vmm_sz += tqe_q[ac]->buffer_size; + vmm_sz += tqe_q[ac]->len; vmm_sz = ALIGN(vmm_sz, 4); if ((sum + vmm_sz) > WILC_TX_BUFF_SIZE) { @@ -802,9 +688,8 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) i++; sum += vmm_sz; - tqe_q[ac] = wilc_wlan_txq_get_next(wilc, - tqe_q[ac], - ac); + tqe_q[ac] = skb_peek_next(tqe_q[ac], + &wilc->txq[ac]); } } num_pkts_to_add = ac_preserve_ratio; @@ -894,17 +779,18 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) offset = 0; i = 0; do { - struct txq_entry_t *tqe; + struct sk_buff *tqe; u32 header, buffer_offset; char *bssid; u8 mgmt_ptk = 0; - tqe = wilc_wlan_txq_remove_from_head(wilc, vmm_entries_ac[i]); + tqe = skb_dequeue(&wilc->txq[vmm_entries_ac[i]]); if (!tqe) break; + atomic_dec(&wilc->txq_entries); ac_pkt_num_to_chip[vmm_entries_ac[i]]++; - vif = tqe->vif; + vif = netdev_priv(tqe->dev); tx_cb = WILC_SKB_TX_CB(tqe); if (vmm_table[i] == 0) break; @@ -918,7 +804,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) header = (FIELD_PREP(WILC_VMM_HDR_TYPE, tx_cb->type) | FIELD_PREP(WILC_VMM_HDR_MGMT_FIELD, mgmt_ptk) | - FIELD_PREP(WILC_VMM_HDR_PKT_SIZE, tqe->buffer_size) | + FIELD_PREP(WILC_VMM_HDR_PKT_SIZE, tqe->len) | FIELD_PREP(WILC_VMM_HDR_BUFF_SIZE, vmm_sz)); cpu_to_le32s(&header); @@ -928,7 +814,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) } else if (tx_cb->type == WILC_NET_PKT) { int prio = tx_cb->q_num; - bssid = tqe->vif->bssid; + bssid = vif->bssid; buffer_offset = ETH_ETHERNET_HDR_OFFSET; memcpy(&txb[offset + 4], &prio, sizeof(prio)); memcpy(&txb[offset + 8], bssid, 6); @@ -936,8 +822,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) buffer_offset = HOST_HDR_OFFSET; } - memcpy(&txb[offset + buffer_offset], - tqe->buffer, tqe->buffer_size); + memcpy(&txb[offset + buffer_offset], tqe->data, tqe->len); offset += vmm_sz; i++; wilc_wlan_tx_packet_done(tqe, 1); @@ -1251,7 +1136,7 @@ int wilc_wlan_stop(struct wilc *wilc, struct wilc_vif *vif) void wilc_wlan_cleanup(struct net_device *dev) { - struct txq_entry_t *tqe; + struct sk_buff *tqe, *cfg_skb; struct rxq_entry_t *rqe; u8 ac; struct wilc_vif *vif = netdev_priv(dev); @@ -1259,9 +1144,15 @@ void wilc_wlan_cleanup(struct net_device *dev) wilc->quit = 1; for (ac = 0; ac < NQUEUES; ac++) { - while ((tqe = wilc_wlan_txq_remove_from_head(wilc, ac))) + while ((tqe = skb_dequeue(&wilc->txq[ac]))) wilc_wlan_tx_packet_done(tqe, 0); } + atomic_set(&wilc->txq_entries, 0); + cfg_skb = wilc->cfg_skb; + if (cfg_skb) { + wilc->cfg_skb = NULL; + dev_kfree_skb_any(cfg_skb); + } while ((rqe = wilc_wlan_rxq_remove(wilc))) kfree(rqe); @@ -1273,21 +1164,52 @@ void wilc_wlan_cleanup(struct net_device *dev) wilc->hif_func->hif_deinit(NULL); } +struct sk_buff *wilc_wlan_alloc_skb(struct wilc_vif *vif, size_t len) +{ + size_t size, headroom; + struct sk_buff *skb; + + headroom = vif->ndev->needed_headroom; + size = headroom + len + vif->ndev->needed_tailroom; + skb = netdev_alloc_skb(vif->ndev, size); + if (!skb) { + netdev_err(vif->ndev, "Failed to alloc skb"); + return NULL; + } + skb_reserve(skb, headroom); + return skb; +} + +static struct sk_buff *alloc_cfg_skb(struct wilc_vif *vif) +{ + struct sk_buff *skb; + + skb = wilc_wlan_alloc_skb(vif, (sizeof(struct wilc_cfg_cmd_hdr) + + WILC_MAX_CFG_FRAME_SIZE)); + if (!skb) + return NULL; + skb_reserve(skb, sizeof(struct wilc_cfg_cmd_hdr)); + return skb; +} + static int wilc_wlan_cfg_commit(struct wilc_vif *vif, int type, u32 drv_handler) { struct wilc *wilc = vif->wilc; - struct wilc_cfg_frame *cfg = &wilc->cfg_frame; - int t_len = wilc->cfg_frame_offset + sizeof(struct wilc_cfg_cmd_hdr); struct wilc_cfg_cmd_hdr *hdr; + struct sk_buff *cfg_skb = wilc->cfg_skb; - hdr = &cfg->hdr; + hdr = skb_push(cfg_skb, sizeof(*hdr)); hdr->cmd_type = (type == WILC_CFG_SET) ? 'W' : 'Q'; hdr->seq_no = wilc->cfg_seq_no; - hdr->total_len = cpu_to_le16(t_len); + hdr->total_len = cpu_to_le16(cfg_skb->len); hdr->driver_handler = cpu_to_le32(drv_handler); + /* We are about to pass ownership of cfg_skb to the tx queue + * (or it'll be destroyed, in case the queue is full): + */ + wilc->cfg_skb = NULL; - if (!wilc_wlan_txq_add_cfg_pkt(vif, (u8 *)&cfg->hdr, t_len)) + if (!wilc_wlan_txq_add_cfg_pkt(vif, cfg_skb)) return -1; return 0; @@ -1302,24 +1224,32 @@ static int wilc_wlan_cfg_apply_wid(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, u32 buffer_size, int commit, u32 drv_handler, bool set) { - u32 offset; int ret_size; struct wilc *wilc = vif->wilc; mutex_lock(&wilc->cfg_cmd_lock); - if (start) - wilc->cfg_frame_offset = 0; + if (start) { + WARN_ON(wilc->cfg_skb); + wilc->cfg_skb = alloc_cfg_skb(vif); + if (!wilc->cfg_skb) { + netdev_dbg(vif->ndev, "Failed to alloc cfg_skb"); + mutex_unlock(&wilc->cfg_cmd_lock); + return 0; + } + } - offset = wilc->cfg_frame_offset; if (set) - ret_size = wilc_wlan_cfg_set_wid(wilc->cfg_frame.frame, offset, + ret_size = wilc_wlan_cfg_set_wid(wilc->cfg_skb->tail, 0, wid, buffer, buffer_size); else - ret_size = wilc_wlan_cfg_get_wid(wilc->cfg_frame.frame, offset, - wid); - offset += ret_size; - wilc->cfg_frame_offset = offset; + ret_size = wilc_wlan_cfg_get_wid(wilc->cfg_skb->tail, 0, wid); + if (ret_size == 0) + netdev_dbg(vif->ndev, + "Failed to add WID 0x%x to %s cfg packet\n", + wid, set ? "set" : "query"); + + skb_put(wilc->cfg_skb, ret_size); if (!commit) { mutex_unlock(&wilc->cfg_cmd_lock); @@ -1339,7 +1269,6 @@ static int wilc_wlan_cfg_apply_wid(struct wilc_vif *vif, int start, u16 wid, ret_size = 0; } - wilc->cfg_frame_offset = 0; wilc->cfg_seq_no = (wilc->cfg_seq_no + 1) % 256; mutex_unlock(&wilc->cfg_cmd_lock); diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/wireless/microchip/wilc1000/wlan.h index 295795a8060ac..10618327133ce 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.h +++ b/drivers/net/wireless/microchip/wilc1000/wlan.h @@ -320,24 +320,19 @@ enum ip_pkt_priority { AC_BK_Q = 3 }; -struct txq_entry_t { - struct list_head list; - int type; - u8 q_num; - int ack_idx; - u8 *buffer; - int buffer_size; - void *priv; - int status; - struct wilc_vif *vif; - void (*tx_complete_func)(void *priv, int status); +/* When queueing a tx packet, this info is stored in the sk_buff's + * control buffer (cb). + */ +struct wilc_skb_tx_cb { + u8 type; /* one of WILC_*_PKT */ + enum ip_pkt_priority q_num; /* AC queue this packet is on */ + int ack_idx; /* TCP ack index */ }; -#define wilc_skb_tx_cb txq_entry_t - -static inline struct wilc_skb_tx_cb *WILC_SKB_TX_CB(struct txq_entry_t *tqe) +static inline struct wilc_skb_tx_cb *WILC_SKB_TX_CB(struct sk_buff *skb) { - return (struct wilc_skb_tx_cb *)tqe; + BUILD_BUG_ON(sizeof(struct wilc_skb_tx_cb) > sizeof(skb->cb)); + return (struct wilc_skb_tx_cb *)&skb->cb[0]; } struct txq_fw_recv_queue_stat { @@ -345,11 +340,6 @@ struct txq_fw_recv_queue_stat { u8 count; }; -struct txq_handle { - struct txq_entry_t txq_head; - u16 count; -}; - struct rxq_entry_t { struct list_head list; u8 *buffer; @@ -382,12 +372,6 @@ struct wilc_hif_func { #define WILC_MAX_CFG_FRAME_SIZE 1468 -struct tx_complete_data { - int size; - void *buff; - struct sk_buff *skb; -}; - struct wilc_cfg_cmd_hdr { u8 cmd_type; u8 seq_no; @@ -395,11 +379,6 @@ struct wilc_cfg_cmd_hdr { __le32 driver_handler; }; -struct wilc_cfg_frame { - struct wilc_cfg_cmd_hdr hdr; - u8 frame[WILC_MAX_CFG_FRAME_SIZE]; -}; - struct wilc_cfg_rsp { u8 type; u8 seq_no; @@ -411,19 +390,16 @@ int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer, u32 buffer_size); int wilc_wlan_start(struct wilc *wilc); int wilc_wlan_stop(struct wilc *wilc, struct wilc_vif *vif); -int wilc_wlan_txq_add_net_pkt(struct net_device *dev, - struct tx_complete_data *tx_data, u8 *buffer, - u32 buffer_size, - void (*tx_complete_fn)(void *, int)); +int wilc_wlan_txq_add_net_pkt(struct net_device *dev, struct sk_buff *skb); int wilc_wlan_handle_txq(struct wilc *wl, u32 *txq_count); void wilc_handle_isr(struct wilc *wilc); +struct sk_buff *wilc_wlan_alloc_skb(struct wilc_vif *vif, size_t len); void wilc_wlan_cleanup(struct net_device *dev); int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, u32 buffer_size, int commit, u32 drv_handler); int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, u16 wid, int commit, u32 drv_handler); -int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer, - u32 buffer_size, void (*func)(void *, int)); +int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, struct sk_buff *skb); void wilc_enable_tcp_ack_filter(struct wilc_vif *vif, bool value); int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc); netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *dev); From patchwork Sat Dec 18 23:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 525819 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C763BC433FE for ; Sat, 18 Dec 2021 23:55:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235565AbhLRXzX (ORCPT ); Sat, 18 Dec 2021 18:55:23 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25668 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234947AbhLRXyX (ORCPT ); Sat, 18 Dec 2021 18:54:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=R4RyJtuY/uGuGEQsEpntttzYbyVkfCoSuFhUmGGe0PA=; b=W+fYePf+D5IOFEHTHX0AV/isKp/q6bXyBowdk5+HUfRn52DbeN4XI0E+xWboCxCc3PJG 7iqfg8NVw0r/BlNkOiy6D0/YHfBIDbeONChLYDBW7ctj0Y+V4i7Jzw/d4XgKs1nZKbD2W7 e8zBJYt5rbDnZwOXmoMKClpdGQDZ38W0liiM6v9aCH7f7IBS4Z64f6KdH8inPByZXKstUU 1AUwO2POlUisyzT+JNtALhg6+AlEu09mA6RBWoFGExbkzn39sJtEYqNqjMwZAjSf9042t0 dLfkt7uMtH6oWa3SWODWkZ4zwueoK9SHSnmwHpddyDdHCUSK0gJWAobdYmYRtFPg== Received: by filterdrecv-656998cfdd-phncc with SMTP id filterdrecv-656998cfdd-phncc-1-61BE74A9-3 2021-12-18 23:54:17.151024833 +0000 UTC m=+7604818.337271612 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-5-1 (SG) with ESMTP id 5XWLSwaNQpaKO14Zquup1w Sat, 18 Dec 2021 23:54:17.006 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id C1C5E7013D4; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 17/23] wilc1000: remove no longer used "vif" argument from init_txq_entry() Date: Sat, 18 Dec 2021 23:54:17 +0000 (UTC) Message-Id: <20211218235404.3963475-18-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvAIVGQkkNlpmJF3yJdnJor5KInhhkxafKGCb5Jd/4Fxe6Jl/4S74lBnbFPJdPvmB6ZZ5vZ7Ty2vPD8OwtDFsW4ST9LYJK047tHo5Z3RGND6mnzp/z7Kn26NEU2nXtStuubhUxeY8AdyS9SrWpiZhdISayAWe6RnqccyVr2AaQy71FMbJxoLiyCENygNp4o4ZSA== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org With the tx-path switched to sk_buffs, there is no longer any need for the "vif" argument in init_txq_entry(). Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index f895e4dd2e73f..286bbf9392165 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -37,7 +37,7 @@ static inline void release_bus(struct wilc *wilc, enum bus_release release) mutex_unlock(&wilc->hif_cs); } -static void init_txq_entry(struct sk_buff *tqe, struct wilc_vif *vif, +static void init_txq_entry(struct sk_buff *tqe, u8 type, enum ip_pkt_priority q_num) { struct wilc_skb_tx_cb *tx_cb = WILC_SKB_TX_CB(tqe); @@ -53,7 +53,7 @@ static void wilc_wlan_txq_add_to_tail(struct net_device *dev, u8 type, u8 q_num, struct wilc_vif *vif = netdev_priv(dev); struct wilc *wilc = vif->wilc; - init_txq_entry(tqe, vif, type, q_num); + init_txq_entry(tqe, type, q_num); if (type == WILC_NET_PKT && vif->ack_filter.enabled) tcp_process(dev, tqe); @@ -68,7 +68,7 @@ static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, u8 type, u8 q_num, { struct wilc *wilc = vif->wilc; - init_txq_entry(tqe, vif, type, q_num); + init_txq_entry(tqe, type, q_num); mutex_lock(&wilc->txq_add_to_head_cs); From patchwork Sat Dec 18 23:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 526856 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F9F1C4707E for ; Sat, 18 Dec 2021 23:54:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234892AbhLRXyg (ORCPT ); Sat, 18 Dec 2021 18:54:36 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25702 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234969AbhLRXy1 (ORCPT ); Sat, 18 Dec 2021 18:54:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=5Pqwl63bHpqoLecNYX9M7YSYzft3PMq3Tp+Ku265mTY=; b=R31qg4d/FC+Tyg4exwJVMuwogdfu/qX/5lV5bx4JCMnHIwRmt48WcjUmUj2VrH7YXatz GQfZ0wOO6FQ+IS6W+ogSYfcpQHWbpm0Ef7wI9x4U6PLH0apkclP0Sn51G2vPzPl37IsRAx Jt6cjEIB0F6GVITNC2vHYVEEke8x3e0ye7Hb/N1WM2228zUwnxAzqK1Q/+3+y9r7ucxTvB hg8Bk0EAiSeVX4/8rUik1DqudIFFPHb8VAIeOoNiUTDnY4CxD3OhiRXlv9sVzZvsDnUdL3 n4EYIIY3o+8YUqBZ391bPCSRoF5lunwUUvdpnHAVz+MN5J3IcWtzOCD+mXyhkb/A== Received: by filterdrecv-75ff7b5ffb-wdd5z with SMTP id filterdrecv-75ff7b5ffb-wdd5z-1-61BE74A9-9 2021-12-18 23:54:17.132754881 +0000 UTC m=+9336865.234030658 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-1-1 (SG) with ESMTP id 3JAEvuuJSgy3JFED5vCSbw Sat, 18 Dec 2021 23:54:17.020 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id C770770141C; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 18/23] wilc1000: split huge tx handler into subfunctions Date: Sat, 18 Dec 2021 23:54:17 +0000 (UTC) Message-Id: <20211218235404.3963475-19-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvHfkfcXBPrp40SERTTQC6jUvlYfvdwJLiaQX72T07R/eSc78h7Dn/52cnt8CvTM7fOpBtB6jG4FkVTHXMaNV7JD1ysurm77PA0p6x3AaMF+O+7QZoZpVYwIo5WxR0XQiSqyaK526DFxjHeqogg5YhTrqAQtwZSLzvRnXXyLMICzE6fVkfq2zumMv/0XHinySNg== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This makes the code easier to read and less error prone. There are no functional changes in this patch. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/wlan.c | 202 +++++++++++++----- 1 file changed, 153 insertions(+), 49 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 286bbf9392165..b7c8ff95b646a 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -605,43 +605,40 @@ void host_sleep_notify(struct wilc *wilc) } EXPORT_SYMBOL_GPL(host_sleep_notify); -int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) +/** + * Fill VMM table with packets waiting to be sent. The packets are + * added based on access category (priority) but also balanced to + * provide fairness. Since this function peeks at the packet queues, + * the txq_add_to_head_cs mutex must be acquired before calling this + * function. + * + * @wilc - Pointer to the wilc structure. + * @ac_desired_ratio: First-round limit on number of packets to add from the + * respective queue. + * @vmm_table: Pointer to the VMM table to fill. + * @vmm_entries_ac: Pointer to the queue-number table to fill. + * For each packet added to the VMM table, this will be filled in + * with the queue-number (access-category) that the packet is coming + * from. + * + * @return + * The number of VMM entries filled in. The table is 0-terminated + * so the returned number is at most WILC_VMM_TBL_SIZE-1. + */ +static int fill_vmm_table(const struct wilc *wilc, + u8 ac_desired_ratio[NQUEUES], + u32 vmm_table[WILC_VMM_TBL_SIZE], + u8 vmm_entries_ac[WILC_VMM_TBL_SIZE]) { - int i, entries = 0; + int i; u8 k, ac; u32 sum; - u32 reg; - u8 ac_desired_ratio[NQUEUES] = {0, 0, 0, 0}; u8 ac_preserve_ratio[NQUEUES] = {1, 1, 1, 1}; u8 *num_pkts_to_add; - u8 vmm_entries_ac[WILC_VMM_TBL_SIZE]; - u32 offset = 0; bool max_size_over = 0, ac_exist = 0; int vmm_sz = 0; struct sk_buff *tqe_q[NQUEUES]; struct wilc_skb_tx_cb *tx_cb; - int ret = 0; - int counter; - int timeout; - u32 vmm_table[WILC_VMM_TBL_SIZE]; - u8 ac_pkt_num_to_chip[NQUEUES] = {0, 0, 0, 0}; - const struct wilc_hif_func *func; - int srcu_idx; - u8 *txb = wilc->tx_buffer; - struct wilc_vif *vif; - - if (wilc->quit) - goto out_update_cnt; - - if (ac_balance(wilc, ac_desired_ratio)) - return -EINVAL; - - mutex_lock(&wilc->txq_add_to_head_cs); - - srcu_idx = srcu_read_lock(&wilc->srcu); - list_for_each_entry_rcu(vif, &wilc->vif_list, list) - wilc_wlan_txq_filter_dup_tcp_ack(vif->ndev); - srcu_read_unlock(&wilc->srcu, srcu_idx); for (ac = 0; ac < NQUEUES; ac++) tqe_q[ac] = skb_peek(&wilc->txq[ac]); @@ -695,11 +692,28 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) num_pkts_to_add = ac_preserve_ratio; } while (!max_size_over && ac_exist); - if (i == 0) - goto out_unlock; vmm_table[i] = 0x0; + return i; +} + +/** + * Send the VMM table to the chip and get back the number of entries + * that the chip can accept. The bus must have been acquired before + * calling this function. + * + * @wilc: Pointer to the wilc structure. + * @i: The number of entries in the VMM table. + * @vmm_table: The VMM table to send. + * + * @return + * The number of VMM table entries the chip can accept. + */ +static int send_vmm_table(struct wilc *wilc, int i, const u32 *vmm_table) +{ + const struct wilc_hif_func *func; + int ret, counter, entries, timeout; + u32 reg; - acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); counter = 0; func = wilc->hif_func; do { @@ -721,7 +735,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) } while (!wilc->quit); if (ret) - goto out_release_bus; + return ret; timeout = 200; do { @@ -759,22 +773,36 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) break; reg &= ~BIT(0); ret = func->hif_write_reg(wilc, WILC_HOST_TX_CTRL, reg); + } else { + ret = entries; } } while (0); + return ret; +} - if (ret) - goto out_release_bus; - - if (entries == 0) { - /* - * No VMM space available in firmware so retry to transmit - * the packet from tx queue. - */ - ret = WILC_VMM_ENTRY_FULL_RETRY; - goto out_release_bus; - } - - release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); +/** + * Copy a set of packets to the transmit buffer. The + * txq_add_to_head_cs mutex must still be held when calling this + * function. + * + * @wilc - Pointer to the wilc structure. + * @entries: The number of packets to send from the VMM table. + * @vmm_table: The VMM table to send. + * @vmm_entries_ac: Table index i contains the number of the queue to + * take the i-th packet from. + * + * @return + * Negative number on error, 0 on success. + */ +static int copy_packets(struct wilc *wilc, int entries, u32 *vmm_table, + u8 *vmm_entries_ac) +{ + u8 ac_pkt_num_to_chip[NQUEUES] = {0, 0, 0, 0}; + struct wilc_skb_tx_cb *tx_cb; + u8 *txb = wilc->tx_buffer; + struct wilc_vif *vif; + int i, vmm_sz; + u32 offset; offset = 0; i = 0; @@ -829,16 +857,92 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) } while (--entries); for (i = 0; i < NQUEUES; i++) wilc->fw[i].count += ac_pkt_num_to_chip[i]; + return offset; +} - acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); +/** + * Send the packets in the VMM table to the chip. The bus must have + * been acquired. + * + * @wilc - Pointer to the wilc structure. + * @length: The length of the buffer containing the packets to be + * sent to the chip. + * + * @return + * Negative number on error, 0 on success. + */ +static int send_packets(struct wilc *wilc, int len) +{ + const struct wilc_hif_func *func = wilc->hif_func; + int ret; + u8 *txb = wilc->tx_buffer; ret = func->hif_clear_int_ext(wilc, ENABLE_TX_VMM); if (ret) - goto out_release_bus; + return ret; + + ret = func->hif_block_tx_ext(wilc, 0, txb, len); + return ret; +} + +int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) +{ + int i, entries, len; + u8 ac; + u8 ac_desired_ratio[NQUEUES] = {0, 0, 0, 0}; + u8 vmm_entries_ac[WILC_VMM_TBL_SIZE]; + struct sk_buff *tqe_q[NQUEUES]; + int ret = 0; + u32 vmm_table[WILC_VMM_TBL_SIZE]; + int srcu_idx; + struct wilc_vif *vif; + + if (wilc->quit) + goto out_update_cnt; + + if (ac_balance(wilc, ac_desired_ratio)) + return -EINVAL; + + mutex_lock(&wilc->txq_add_to_head_cs); + + srcu_idx = srcu_read_lock(&wilc->srcu); + list_for_each_entry_rcu(vif, &wilc->vif_list, list) + wilc_wlan_txq_filter_dup_tcp_ack(vif->ndev); + srcu_read_unlock(&wilc->srcu, srcu_idx); + + for (ac = 0; ac < NQUEUES; ac++) + tqe_q[ac] = skb_peek(&wilc->txq[ac]); + + i = fill_vmm_table(wilc, ac_desired_ratio, vmm_table, vmm_entries_ac); + if (i == 0) + goto out_unlock; + + acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); + + ret = send_vmm_table(wilc, i, vmm_table); + + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); + + if (ret < 0) + goto out_unlock; + + entries = ret; + if (entries == 0) { + /* No VMM space available in firmware. Inform caller + * to retry later. + */ + ret = WILC_VMM_ENTRY_FULL_RETRY; + goto out_unlock; + } + + len = copy_packets(wilc, entries, vmm_table, vmm_entries_ac); + if (len <= 0) + goto out_unlock; + + acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); - ret = func->hif_block_tx_ext(wilc, 0, txb, offset); + ret = send_packets(wilc, len); -out_release_bus: release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); out_unlock: From patchwork Sat Dec 18 23:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 525824 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DEBEC43219 for ; Sat, 18 Dec 2021 23:54:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234969AbhLRXyh (ORCPT ); Sat, 18 Dec 2021 18:54:37 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25726 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234974AbhLRXy0 (ORCPT ); Sat, 18 Dec 2021 18:54:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=o7oSOnb8F57kKru8yGwzxIQp/4qaa84HAsOuc9Qe3GU=; b=J3QHPiVAo7ftDRJZFh6x1ZM1eGaPXQOxPM9uWB7T+EVAHEkQUh8FOH1lIBHIXOvL0Zr7 iwh9POzw4r5dLsJdWNEh8ibBcl9T5LApkLDhaB0NiJ95XaO7LMtBb8RUTW6X4sLzeyZmYc fxmv44vg4kgJhN3Sf29H7EheBA3z8IJoTGcr84bPVXANaX3qK4X5YiV4xTDo8nPXC0fhZa dTFHSuejOkg0di5kYPpT57FSF74/zmXqmh+GPlPfLOiUbGa3szfpG7rp5q1bg09Y7PDA6H vz2AqCJifQsu/B+vdvyWIp4rq7mOmD6G0O0MkwdQx11MTXEaKl/AVqOuG8aeW4FA== Received: by filterdrecv-64fcb979b9-8r2zw with SMTP id filterdrecv-64fcb979b9-8r2zw-1-61BE74A9-6 2021-12-18 23:54:17.233925598 +0000 UTC m=+8294249.268681274 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-6-1 (SG) with ESMTP id WODQW4uCRqSfD_BdUJPSqg Sat, 18 Dec 2021 23:54:17.067 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id CCF52701426; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 19/23] wilc1000: don't tell the chip to go to sleep while copying tx packets Date: Sat, 18 Dec 2021 23:54:17 +0000 (UTC) Message-Id: <20211218235404.3963475-20-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvBxusGV4Bz+mo2Dhmqm6c7pe6RJmTeflUX3Xl0lMdXMkyBl5XbqwAmvRrRZNjb6/G5PGf7B9pBuxASy/iQJqPLlJ+ieI599/43eP+HlvOB2wlwr0jp8nOP5vgz9ketnwzD72K4R1gAHeh7yF6E2VQmAAFJBef9p86gNWZTVZtfnM9RTtWekGY3WQ1VqisBq+vQ== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Putting the chip to sleep and waking it up again is relatively slow, so there is no point to put the chip to sleep for the short time it takes to copy a couple of packets. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/wlan.c | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index b7c8ff95b646a..8652ec9f6d9c8 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -920,29 +920,27 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); ret = send_vmm_table(wilc, i, vmm_table); + if (ret <= 0) { + if (ret == 0) + /* No VMM space available in firmware. Inform + * caller to retry later. + */ + ret = WILC_VMM_ENTRY_FULL_RETRY; + goto out_release_bus; + } - release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); - - if (ret < 0) - goto out_unlock; + release_bus(wilc, WILC_BUS_RELEASE_ONLY); entries = ret; - if (entries == 0) { - /* No VMM space available in firmware. Inform caller - * to retry later. - */ - ret = WILC_VMM_ENTRY_FULL_RETRY; - goto out_unlock; - } - len = copy_packets(wilc, entries, vmm_table, vmm_entries_ac); if (len <= 0) goto out_unlock; - acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); + acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); ret = send_packets(wilc, len); +out_release_bus: release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); out_unlock: From patchwork Sat Dec 18 23:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 526853 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFCC6C433F5 for ; Sat, 18 Dec 2021 23:55:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235353AbhLRXy6 (ORCPT ); Sat, 18 Dec 2021 18:54:58 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25728 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234966AbhLRXyZ (ORCPT ); Sat, 18 Dec 2021 18:54:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=jRNhAennxhSOZdi9qsIRPJJ4YYwbnqaPLGNJtjqVSho=; b=uvgzfNW/cHH+zlnbyfof8acKjkqPEySKkSdHlxbm5FTSDMUpodiFhwgkT4O7CDKrH6nI pWf2ph3QvPV593hi8G4SaqBwjbai5uW2C45v2YSaBMhJYtxSQxrilZoJitiUxX7+J1B6rG Uidm0J8lXj3WpTtAy8MAmA17C87ZJWzOsGZNFsZ929HCywalkXbopv8iWvckPKFyIr+xuw sBADbwclF3cVuU+wzAbHrklqNq5VFijViUPXJEAFDLU+/RdJtwF/rOqM0NH5+hFeRNtZiF vzq4E6ASWhl98ke6r89Ni5MbhUmYY93R9BaPMAGAo/B+o2GZ/TaVSBcHF0qwqdgw== Received: by filterdrecv-656998cfdd-5st9z with SMTP id filterdrecv-656998cfdd-5st9z-1-61BE74A9-8 2021-12-18 23:54:17.245944614 +0000 UTC m=+7604801.208387376 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-6-0 (SG) with ESMTP id DVHNYCnNSJKWCPObHJ9w1Q Sat, 18 Dec 2021 23:54:17.085 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id D290970144A; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 20/23] wilc1000: eliminate "max_size_over" variable in fill_vmm_table Date: Sat, 18 Dec 2021 23:54:17 +0000 (UTC) Message-Id: <20211218235404.3963475-21-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvP5YoI1SZSYpzAPoR7eME5H12K8x8BE2v0SzM9CHFoNuHjXtQfe0MZ7rnuDn4joPDIcXw5mMeMKPXpUrEczzJfXgsAowWh/bYAkWkK9BX8NHGmww6mhE1818L5YAQ/anEL+q4DQ2jW/g+2WYOlq5ImTQgrvPLotSAzNqii1yYScnxhvbB2l0I6OPZM+DHhueag== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This makes the code tighter and easier to understand. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 8652ec9f6d9c8..88a981b00bda2 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -635,7 +635,7 @@ static int fill_vmm_table(const struct wilc *wilc, u32 sum; u8 ac_preserve_ratio[NQUEUES] = {1, 1, 1, 1}; u8 *num_pkts_to_add; - bool max_size_over = 0, ac_exist = 0; + bool ac_exist = 0; int vmm_sz = 0; struct sk_buff *tqe_q[NQUEUES]; struct wilc_skb_tx_cb *tx_cb; @@ -645,20 +645,17 @@ static int fill_vmm_table(const struct wilc *wilc, i = 0; sum = 0; - max_size_over = 0; num_pkts_to_add = ac_desired_ratio; do { ac_exist = 0; - for (ac = 0; (ac < NQUEUES) && (!max_size_over); ac++) { + for (ac = 0; ac < NQUEUES; ac++) { if (!tqe_q[ac]) continue; ac_exist = 1; - for (k = 0; (k < num_pkts_to_add[ac]) && - (!max_size_over) && tqe_q[ac]; k++) { + for (k = 0; (k < num_pkts_to_add[ac]) && tqe_q[ac]; k++) { if (i >= (WILC_VMM_TBL_SIZE - 1)) { - max_size_over = 1; - break; + goto out; } tx_cb = WILC_SKB_TX_CB(tqe_q[ac]); @@ -673,8 +670,7 @@ static int fill_vmm_table(const struct wilc *wilc, vmm_sz = ALIGN(vmm_sz, 4); if ((sum + vmm_sz) > WILC_TX_BUFF_SIZE) { - max_size_over = 1; - break; + goto out; } vmm_table[i] = vmm_sz / 4; if (tx_cb->type == WILC_CFG_PKT) @@ -690,8 +686,8 @@ static int fill_vmm_table(const struct wilc *wilc, } } num_pkts_to_add = ac_preserve_ratio; - } while (!max_size_over && ac_exist); - + } while (ac_exist); +out: vmm_table[i] = 0x0; return i; } From patchwork Sat Dec 18 23:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 525826 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1EE8C433F5 for ; Sat, 18 Dec 2021 23:54:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235096AbhLRXyd (ORCPT ); Sat, 18 Dec 2021 18:54:33 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25750 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234983AbhLRXy2 (ORCPT ); Sat, 18 Dec 2021 18:54:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=NIm9rxhOLkpRgRFKJtyRTp7JTwyLk6yRswQbMG0UUTo=; b=voIRU6slURfuVeo2wOTfAkEwyphIm6JEwrC5sdgsa8ZKhxsTWlEh9eLP/4DcN43wA/Iq OGICVnDIdiMKzVerGfDg+7XQWQgUOEU8JtlbpbcFtAlK7k6l5SCarmMk9U9Vktw/k0c19q cWKPYbTMwBAY0qicqukGhkD14PPLd0D58eUtBEs6F7Hy4t8aWsXBEpvE8qqMHpS4MovyPo Imd7YVh3C3ZJ+D0K7KwfRQQ045OkODvdhZrVZNUbaQiAHyc7jG0CqxwihbYHzkIIiJ7Ysd B/asARevSESSNEqJxOpvUUf1gSCl0NiFmoTFaobOF0dPuW+a7/EUOC8S/PPiPaIQ== Received: by filterdrecv-75ff7b5ffb-dtr6p with SMTP id filterdrecv-75ff7b5ffb-dtr6p-1-61BE74A9-6 2021-12-18 23:54:17.223635968 +0000 UTC m=+9336808.918388692 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-3-0 (SG) with ESMTP id bI8oJ2quQkaR_GpQKIKhaA Sat, 18 Dec 2021 23:54:17.102 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id D824370144B; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 21/23] wilc1000: declare read-only ac_preserve_ratio as static and const Date: Sat, 18 Dec 2021 23:54:17 +0000 (UTC) Message-Id: <20211218235404.3963475-22-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvFVBzuJ05dy4HNGstcfpDHzb/qHb+wbJQVql955ae/ixbOi74n/KtcksOtXq5NVGKd+ISwwjQO0Y52QoGGKbuQemxqQZdLWy8i5LNwbnRnyoo9fhyzqmi+1De73JFvVmWkgbF0FSK0HbZdVb89ll9YYEP1VT5xZm/FW8yF7DyOt47Y0cAQvlXvtFGgarQt8ilg== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Apart from being slightly more efficient, this makes the code easier to follow. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 88a981b00bda2..debed2f159215 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -633,8 +633,8 @@ static int fill_vmm_table(const struct wilc *wilc, int i; u8 k, ac; u32 sum; - u8 ac_preserve_ratio[NQUEUES] = {1, 1, 1, 1}; - u8 *num_pkts_to_add; + static const u8 ac_preserve_ratio[NQUEUES] = {1, 1, 1, 1}; + const u8 *num_pkts_to_add; bool ac_exist = 0; int vmm_sz = 0; struct sk_buff *tqe_q[NQUEUES]; From patchwork Sat Dec 18 23:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 526852 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0ED4AC4332F for ; Sat, 18 Dec 2021 23:55:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235373AbhLRXy7 (ORCPT ); Sat, 18 Dec 2021 18:54:59 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25734 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234967AbhLRXyZ (ORCPT ); Sat, 18 Dec 2021 18:54:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=L4jrxjI60V18U1KfdB6NjFsObHJc3K9dkEXY7jnJOIY=; b=tCTjJY0CsCNWIqe8qw53n7lkhgCLfogkvYOGmNXDrF3CaQwIKc5sPLXDgRzteQLdtLLJ 2MEcjQS/tCHacgSE+TRdk0UT3+ESOy2REXFGqEfnDV2nkJXaVnnNL1oxYvUj1EKi49A2ZA zSzBNlmPtzHtTP/KtxsmN6BHc3HyvtNiauspfX2EYVjSM6CE26kJbu5vfFq1wD+KkEuny+ CXY81bbSbEuZWPf6oGRpAP8RBufWqp+5YeOZIAEnoLDHfn7ta2zB9+kWkRucVACQziQ2hm gHrHiVAbF6wkyO15w1LDyfhfFia9GfTEKWzcxxx8M1JO3otHQ8SQ+Rc4QJDcX9hg== Received: by filterdrecv-64fcb979b9-6sxlb with SMTP id filterdrecv-64fcb979b9-6sxlb-1-61BE74A9-9 2021-12-18 23:54:17.267529153 +0000 UTC m=+8294205.257723544 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-6-0 (SG) with ESMTP id uH6ySRw9RY6s7dhCBnIeqw Sat, 18 Dec 2021 23:54:17.120 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id DDBC8701456; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 22/23] wilc1000: minor syntax cleanup Date: Sat, 18 Dec 2021 23:54:17 +0000 (UTC) Message-Id: <20211218235404.3963475-23-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvOyBcWEdJk+6TgtIkW4kHOENRwsRKyKvxEg1Xg4ZujUJ/QuiR6NhPsGdDm4hR4B807UtsqD+ucPQmTOnkdVodNtS3fTmKJiN1/QDoMEaxSPGvBnlbNDhgk3aNrdOqm2Tt1yabgGHngmnuMEp5vUW71Em3u8lT3Pgb02yqa3+sPnkJ8acyDYn3CXKBNha/LW/Tw== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Remove extraneous parentheses and braces. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index debed2f159215..4ec23b2b2da05 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -653,10 +653,9 @@ static int fill_vmm_table(const struct wilc *wilc, continue; ac_exist = 1; - for (k = 0; (k < num_pkts_to_add[ac]) && tqe_q[ac]; k++) { - if (i >= (WILC_VMM_TBL_SIZE - 1)) { + for (k = 0; k < num_pkts_to_add[ac] && tqe_q[ac]; k++) { + if (i >= WILC_VMM_TBL_SIZE - 1) goto out; - } tx_cb = WILC_SKB_TX_CB(tqe_q[ac]); if (tx_cb->type == WILC_CFG_PKT) @@ -669,9 +668,8 @@ static int fill_vmm_table(const struct wilc *wilc, vmm_sz += tqe_q[ac]->len; vmm_sz = ALIGN(vmm_sz, 4); - if ((sum + vmm_sz) > WILC_TX_BUFF_SIZE) { + if (sum + vmm_sz > WILC_TX_BUFF_SIZE) goto out; - } vmm_table[i] = vmm_sz / 4; if (tx_cb->type == WILC_CFG_PKT) vmm_table[i] |= BIT(10); @@ -735,10 +733,8 @@ static int send_vmm_table(struct wilc *wilc, int i, const u32 *vmm_table) timeout = 200; do { - ret = func->hif_block_tx(wilc, - WILC_VMM_TBL_RX_SHADOW_BASE, - (u8 *)vmm_table, - ((i + 1) * 4)); + ret = func->hif_block_tx(wilc, WILC_VMM_TBL_RX_SHADOW_BASE, + (u8 *)vmm_table, (i + 1) * 4); if (ret) break; From patchwork Sat Dec 18 23:54:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 525821 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC7FBC433F5 for ; Sat, 18 Dec 2021 23:55:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235400AbhLRXzB (ORCPT ); Sat, 18 Dec 2021 18:55:01 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:25712 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234958AbhLRXyZ (ORCPT ); Sat, 18 Dec 2021 18:54:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=egauge.net; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type; s=sgd; bh=sinBnLCkTHw0t/yG9XyJF667Cq9tEjWOwIYZimlz2fI=; b=oMcJxPsyVLauYPrdCbrnJ+MOBf7W0JPsXJMtsJJ/sw2QAipj5tjZaOJpRtEHX9jfhvwd 1yGbdOMgg0TuEwCJhl74LbshNcmJZT8q53UvscoHnSkf08aC9CfCaKHv2K0oM6NBGlg04C NbCOKRqBZUY6OCJTvJ9oTkkvJGBaLwUqLkWfxWbwHG8447zcSHraPz8g3/MLuN+MggTcA3 7/bZHNuEOlXFR9W9PD5Pf6+O73qDiThuloEdHr/Fhiya1PY3eF5NvjId6CcdeK4JzepojG ArvM4p58tVKfwClqQgaC3WRkfzuZqCUoAq+qjPb/CeET/QuZMvYTMBD9LaIr46kQ== Received: by filterdrecv-656998cfdd-vtnvg with SMTP id filterdrecv-656998cfdd-vtnvg-1-61BE74A9-6 2021-12-18 23:54:17.271696307 +0000 UTC m=+7604818.321476290 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-4-1 (SG) with ESMTP id qiWQH8zgTK2qOWAia0hduw Sat, 18 Dec 2021 23:54:17.110 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id E35AD701463; Sat, 18 Dec 2021 16:54:15 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH 23/23] wilc1000: introduce symbolic names for two tx-related control bits Date: Sat, 18 Dec 2021 23:54:17 +0000 (UTC) Message-Id: <20211218235404.3963475-24-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211218235404.3963475-1-davidm@egauge.net> References: <20211218235404.3963475-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvJSzRgudYonBolmfI0YU2DoSFm5tqSCL4wZQyH3747ovQKXVWM8m16oOQ0L2V7G0GjotG2D4xN5xA/nEHEKuDcLe/Yb0qug1eCuNmVAmFq551cEMaoHyx82K1IPqiOcaTOJZXqcbRbci/CEwmmtiw4Dy9LamY+XeaR011fDc/Bgg3ZqxJk5lZkr2RPFENZ/+Gg== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org I wish these registers were documented so I wouldn't have to guess at their meanings and make up my own names. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 6 +++--- drivers/net/wireless/microchip/wilc1000/wlan.h | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 4ec23b2b2da05..b7a792edea187 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -672,7 +672,7 @@ static int fill_vmm_table(const struct wilc *wilc, goto out; vmm_table[i] = vmm_sz / 4; if (tx_cb->type == WILC_CFG_PKT) - vmm_table[i] |= BIT(10); + vmm_table[i] |= WILC_VMM_CFG_PKT; cpu_to_le32s(&vmm_table[i]); vmm_entries_ac[i] = ac; @@ -715,7 +715,7 @@ static int send_vmm_table(struct wilc *wilc, int i, const u32 *vmm_table) if (ret) break; - if ((reg & 0x1) == 0) { + if ((reg & WILC_HOST_TX_CTRL_BUSY) == 0) { ac_update_fw_ac_pkt_info(wilc, reg); break; } @@ -763,7 +763,7 @@ static int send_vmm_table(struct wilc *wilc, int i, const u32 *vmm_table) ret = func->hif_read_reg(wilc, WILC_HOST_TX_CTRL, ®); if (ret) break; - reg &= ~BIT(0); + reg &= ~WILC_HOST_TX_CTRL_BUSY; ret = func->hif_write_reg(wilc, WILC_HOST_TX_CTRL, reg); } else { ret = entries; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/wireless/microchip/wilc1000/wlan.h index 10618327133ce..f5d32ec93fdb9 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.h +++ b/drivers/net/wireless/microchip/wilc1000/wlan.h @@ -224,6 +224,7 @@ #define BE_AC_ACM_STAT_FIELD BIT(8) #define BK_AC_COUNT_FIELD GENMASK(7, 3) #define BK_AC_ACM_STAT_FIELD BIT(1) +#define WILC_HOST_TX_CTRL_BUSY BIT(0) #define WILC_PKT_HDR_CONFIG_FIELD BIT(31) #define WILC_PKT_HDR_OFFSET_FIELD GENMASK(30, 22) @@ -233,6 +234,7 @@ #define WILC_INTERRUPT_DATA_SIZE GENMASK(14, 0) #define WILC_VMM_BUFFER_SIZE GENMASK(9, 0) +#define WILC_VMM_CFG_PKT BIT(10) #define WILC_VMM_HDR_TYPE BIT(31) #define WILC_VMM_HDR_MGMT_FIELD BIT(30)