From nobody Wed Jul 1 09:56:28 2026 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 30F44C4332F for ; Thu, 23 Dec 2021 01:14:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345850AbhLWBOI (ORCPT ); Wed, 22 Dec 2021 20:14:08 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:17700 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230379AbhLWBOG (ORCPT ); Wed, 22 Dec 2021 20:14:06 -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=SmrKBnVEuSa1Juw5SAAEJzj60ijmoTkRxcpcsF5nTSA=; b=YzSVNjRk+pvvM/BP2KyqNRbFcAtzJzqrV6h52ohmxR9Ww55s/6LALy6sVHvjEUv4TYMD fQ4LVwp3Ly2gngrVfmzWb+ZGvO4MCjEzzPo9HB2XHuQocnkPkqtu88vpwBo6iImkLrFttH OhTrn4ii0s2x1DSGx5pRCs2qRwMvNGeZ/ODXAuRw8sdB8GxHJzUft8kDY5V0IJwp8jz8a0 hiMNwVZplJdRMiq0TMyz9k4i7tAHzrNatBuuO2HlRCQmOkNBlHygcafhBxxIdZ8deNw/Nk towjwgWcVKCKpvwD0X8DIpWpEaR03lizF0ufxN49H9g7NE8iVQ1IpCYQbL1ks2+Q== Received: by filterdrecv-64fcb979b9-tjknx with SMTP id filterdrecv-64fcb979b9-tjknx-1-61C3CD5D-25 2021-12-23 01:14:05.75681832 +0000 UTC m=+8644588.560336792 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-4-0 (SG) with ESMTP id s_DzTIWtT-iUGkJKJ4u1tg Thu, 23 Dec 2021 01:14:05.581 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id D188C70054A; Wed, 22 Dec 2021 18:14:04 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 01/50] wilc1000: don't hold txq_spinlock while initializing AC queue limits Date: Thu, 23 Dec 2021 01:14:05 +0000 (UTC) Message-Id: <20211223011358.4031459-2-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvFFgikHEO6TrfMipf?= =?us-ascii?Q?R5df56socHUWL2usMYlQYxi9mNZe3jUS8vaJZg3?= =?us-ascii?Q?E+EW8ovRMMV2T=2Fwpc1krcS5fB6jrNH8icO6Umjr?= =?us-ascii?Q?7irE9kln3toFVE1GkrchjnSxZFIqVqhsal3TWn2?= =?us-ascii?Q?kNIHE+iD1ZTqdX=2FkTIGJFdYr84LpBlOfOEmw09D?= =?us-ascii?Q?r+tyg4wH1YD+iPj7W6riA=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 a067274c20144..f4fc2cc392bd0 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; }; =20 struct wilc { diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index fb5633a05fd51..c4da14147dd04 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -12,6 +12,8 @@ =20 #define WAKE_UP_TRIAL_RETRY 10000 =20 +static const u8 factors[NQUEUES] =3D {1, 1, 1, 1}; + static inline bool is_wilc1000(u32 id) { return (id & (~WILC_CHIP_REV_FIELD)) =3D=3D WILC_1000_BASE_ID; @@ -283,10 +285,23 @@ static int wilc_wlan_txq_add_cfg_pkt(struct wilc_vif = *vif, u8 *buffer, return 1; } =20 +static void init_q_limits(struct wilc *wl) +{ + struct wilc_tx_queue_status *q =3D &wl->tx_q_limit; + int i; + + for (i =3D 0; i < AC_BUFFER_SIZE; i++) + q->buffer[i] =3D i % NQUEUES; + + for (i =3D 0; i < NQUEUES; i++) { + q->cnt[i] =3D AC_BUFFER_SIZE * factors[i] / NQUEUES; + q->sum +=3D q->cnt[i]; + } + q->end_index =3D AC_BUFFER_SIZE - 1; +} + static bool is_ac_q_limit(struct wilc *wl, u8 q_num) { - u8 factors[NQUEUES] =3D {1, 1, 1, 1}; - u16 i; unsigned long flags; struct wilc_tx_queue_status *q =3D &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 =3D false; =20 spin_lock_irqsave(&wl->txq_spinlock, flags); - if (!q->initialized) { - for (i =3D 0; i < AC_BUFFER_SIZE; i++) - q->buffer[i] =3D i % NQUEUES; - - for (i =3D 0; i < NQUEUES; i++) { - q->cnt[i] =3D AC_BUFFER_SIZE * factors[i] / NQUEUES; - q->sum +=3D q->cnt[i]; - } - q->end_index =3D AC_BUFFER_SIZE - 1; - q->initialized =3D 1; - } =20 end_index =3D q->end_index; q->cnt[q->buffer[end_index]] -=3D factors[q->buffer[end_index]]; @@ -1484,6 +1488,8 @@ int wilc_wlan_init(struct net_device *dev) goto fail; } =20 + init_q_limits(wilc); + if (!wilc->tx_buffer) wilc->tx_buffer =3D kmalloc(WILC_TX_BUFF_SIZE, GFP_KERNEL); =20 --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 90AFBC4332F for ; Thu, 23 Dec 2021 01:16:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345869AbhLWBOL (ORCPT ); Wed, 22 Dec 2021 20:14:11 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:17764 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237775AbhLWBOH (ORCPT ); Wed, 22 Dec 2021 20:14:07 -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=emRedEXnN1E6Sca8nTmnylU6pLvfF71PWPx92q9deco=; b=Op0A18i9PVkUdlsJon3r7sJVA+uM9i5UwiX/lsv8rSrubQTNq6lINUOnGDqkl85vgR0D L5B4FLVb69DTzotAVTuPSBaSXA2ToMkCotY2KXRuYVdf50hDCCWwmHcZVOlxE9/70VY6BF oLCsPNU6rc8m3DNeiOjuFMpZPorEkIgStW+5gyUa2YNsflQ9+iEQNTmtyX5u2dHjUwWyc2 lrRXafceBZ4x2Gfd0PifmBFMFxCHfdHAaFU6b7xOcTX0NmzcgMbma82/NmavOpxJP1QH/r E1XEbkgK39i7oQkOoUn35A7V4AiAqXq2A8A/Kw4hWTDsOlO/4l+OmvjS2jJK1VCQ== Received: by filterdrecv-64fcb979b9-7lnp4 with SMTP id filterdrecv-64fcb979b9-7lnp4-1-61C3CD5D-36 2021-12-23 01:14:05.795334457 +0000 UTC m=+8644592.725894849 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-6-0 (SG) with ESMTP id P5TgjB1ZSFKLRRrKRnDvVg Thu, 23 Dec 2021 01:14:05.577 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id D47DE700604; Wed, 22 Dec 2021 18:14:04 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 02/50] wilc1000: switch txq_event from completion to waitqueue Date: Thu, 23 Dec 2021 01:14:05 +0000 (UTC) Message-Id: <20211223011358.4031459-3-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvKKbokcqBZrOnU5kE?= =?us-ascii?Q?pG8h+syelvS85jzqTtTcv7YHcinBYmG949gzYNe?= =?us-ascii?Q?S+CPI21kQiP7YmP1MedO60V8pEhFGOCredqr8ve?= =?us-ascii?Q?mjiK4j+7YY03Dvf2Jx8OAd89cqyQrakPPjC5Vci?= =?us-ascii?Q?TZOYp8xYGdNyFRoeD3fp5sEC9i76Rb=2Ftx22U8yB?= =?us-ascii?Q?4IB+dkjo7JRX9A6iLuBsw=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/n= et/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); =20 - 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 643bddaae32ad..d5969f2e369c4 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 =3D vp; + long timeout; =20 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)); =20 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 =3D=3D WILC_VMM_ENTRY_FULL_RETRY) { + timeout =3D msecs_to_jiffies(1); + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(timeout); + } } while (ret =3D=3D WILC_VMM_ENTRY_FULL_RETRY && !wl->close); } return 0; @@ -419,12 +426,11 @@ static void wlan_deinitialize_threads(struct net_devi= ce *dev) =20 wl->close =3D 1; =20 - complete(&wl->txq_event); - if (wl->txq_thread) { kthread_stop(wl->txq_thread); wl->txq_thread =3D NULL; } + wake_up_interruptible(&wl->txq_event); } =20 static void wilc_wlan_deinitialize(struct net_device *dev) @@ -446,7 +452,6 @@ static void wilc_wlan_deinitialize(struct net_device *d= ev) wl->hif_func->disable_interrupt(wl); mutex_unlock(&wl->hif_cs); } - complete(&wl->txq_event); =20 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 f4fc2cc392bd0..c07f58a86bc76 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.h +++ b/drivers/net/wireless/microchip/wilc1000/netdev.h @@ -237,7 +237,7 @@ struct wilc { =20 struct completion cfg_event; struct completion sync_event; - struct completion txq_event; + wait_queue_head_t txq_event; struct completion txq_thread_started; =20 struct task_struct *txq_thread; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index c4da14147dd04..26fa7078acffd 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, =20 spin_unlock_irqrestore(&wilc->txq_spinlock, flags); =20 - complete(&wilc->txq_event); + wake_up_interruptible(&wilc->txq_event); } =20 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 *vi= f, u8 q_num, =20 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); } =20 #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 =3D vif->wilc; struct tcp_ack_filter *f =3D &vif->ack_filter; u32 i =3D 0; - u32 dropped =3D 0; unsigned long flags; =20 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 ne= t_device *dev) f->pending_base =3D 0; =20 spin_unlock_irqrestore(&wilc->txq_spinlock, flags); - - while (dropped > 0) { - wait_for_completion_timeout(&wilc->txq_event, - msecs_to_jiffies(1)); - dropped--; - } } =20 void wilc_enable_tcp_ack_filter(struct wilc_vif *vif, bool value) --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 C7ABEC433EF for ; Thu, 23 Dec 2021 01:14:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345880AbhLWBON (ORCPT ); Wed, 22 Dec 2021 20:14:13 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:17816 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238630AbhLWBOI (ORCPT ); Wed, 22 Dec 2021 20:14:08 -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=TCoMVHSYVhkJgtIGjOgzk6pH7Tut5PTIvOcUiLqFDQU=; b=f5ysdqv03gdXWYFLzx74xdkovU0c7CKKXPvqkekpBCrwEMB9/+9R6qW7EHY+OqCnaFk6 cOu8o/9ghIl4ftlm7BGiET/IntCN8AbdIcFPYfYsyNesRji2py+vKnwVQtjadoGRW/JTFW dS1y4cfWVCd+vynlPiRnL3iXhotce/qtpTyWTsZ8VC+64Uyn/w9AcTrvP3lsnQir+71t7l CoYtq5UnA6Nx37k9MQbZSj1k9c3PyrxrwNlF6CjgeTGMLwTSqZJlvtS7lkwsTGsrfU6ui0 Z1Rds78oIkt2VGGZ9uCDHYXI+jnMKDqsLNOx/1G63CyukueLg6OcMeeK7qLvZodw== Received: by filterdrecv-7bf5c69d5-88tll with SMTP id filterdrecv-7bf5c69d5-88tll-1-61C3CD5D-46 2021-12-23 01:14:05.78637051 +0000 UTC m=+9687224.636323211 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-3-1 (SG) with ESMTP id hdnbALfbTKOlXMkxIs8p2g Thu, 23 Dec 2021 01:14:05.582 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id D75527009E9; Wed, 22 Dec 2021 18:14:04 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 03/50] wilc1000: move receive-queue stats from txq to wilc structure Date: Thu, 23 Dec 2021 01:14:05 +0000 (UTC) Message-Id: <20211223011358.4031459-4-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvHpcdJyjK68kH7Sar?= =?us-ascii?Q?FuF+9wd2pQ9CycCQS3psyU5a2BgiM9NfanPTTGn?= =?us-ascii?Q?r3zYONbprcPrw1z=2FH8X3gZmbkZcyk3fPes7O9Li?= =?us-ascii?Q?WKH0y9rOwNUTZNc8MXsrtrU19M38Jg9Eiy5E=2Fnh?= =?us-ascii?Q?Im7MX4IUTmWBkZZqrZ9sxssf8u=2FXcaF1neIWv00?= =?us-ascii?Q?eN+Bc=2F4RF5pOEGWIWgzxA=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 c07f58a86bc76..d88fee8f9a6b0 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.h +++ b/drivers/net/wireless/microchip/wilc1000/netdev.h @@ -256,6 +256,7 @@ struct wilc { =20 struct txq_handle txq[NQUEUES]; int txq_entries; + struct txq_fw_recv_queue_stat fw[NQUEUES]; =20 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/w= ireless/microchip/wilc1000/wlan.c index 26fa7078acffd..d1f68df1dbeef 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 *rat= io) return -EINVAL; =20 for (i =3D 0; i < NQUEUES; i++) - if (wl->txq[i].fw.count > max_count) - max_count =3D wl->txq[i].fw.count; + if (wl->fw[i].count > max_count) + max_count =3D wl->fw[i].count; =20 for (i =3D 0; i < NQUEUES; i++) - ratio[i] =3D max_count - wl->txq[i].fw.count; + ratio[i] =3D max_count - wl->fw[i].count; =20 return 0; } =20 static inline void ac_update_fw_ac_pkt_info(struct wilc *wl, u32 reg) { - wl->txq[AC_BK_Q].fw.count =3D FIELD_GET(BK_AC_COUNT_FIELD, reg); - wl->txq[AC_BE_Q].fw.count =3D FIELD_GET(BE_AC_COUNT_FIELD, reg); - wl->txq[AC_VI_Q].fw.count =3D FIELD_GET(VI_AC_COUNT_FIELD, reg); - wl->txq[AC_VO_Q].fw.count =3D FIELD_GET(VO_AC_COUNT_FIELD, reg); - - wl->txq[AC_BK_Q].fw.acm =3D FIELD_GET(BK_AC_ACM_STAT_FIELD, reg); - wl->txq[AC_BE_Q].fw.acm =3D FIELD_GET(BE_AC_ACM_STAT_FIELD, reg); - wl->txq[AC_VI_Q].fw.acm =3D FIELD_GET(VI_AC_ACM_STAT_FIELD, reg); - wl->txq[AC_VO_Q].fw.acm =3D FIELD_GET(VO_AC_ACM_STAT_FIELD, reg); + wl->fw[AC_BK_Q].count =3D FIELD_GET(BK_AC_COUNT_FIELD, reg); + wl->fw[AC_BE_Q].count =3D FIELD_GET(BE_AC_COUNT_FIELD, reg); + wl->fw[AC_VI_Q].count =3D FIELD_GET(VI_AC_COUNT_FIELD, reg); + wl->fw[AC_VO_Q].count =3D FIELD_GET(VO_AC_COUNT_FIELD, reg); + + wl->fw[AC_BK_Q].acm =3D FIELD_GET(BK_AC_ACM_STAT_FIELD, reg); + wl->fw[AC_BE_Q].acm =3D FIELD_GET(BE_AC_ACM_STAT_FIELD, reg); + wl->fw[AC_VI_Q].acm =3D FIELD_GET(VI_AC_ACM_STAT_FIELD, reg); + wl->fw[AC_VO_Q].acm =3D FIELD_GET(VO_AC_ACM_STAT_FIELD, reg); } =20 static inline u8 ac_change(struct wilc *wilc, u8 *ac) { do { - if (wilc->txq[*ac].fw.acm =3D=3D 0) + if (wilc->fw[*ac].acm =3D=3D 0) return 0; (*ac)++; } while (*ac < NQUEUES); @@ -920,7 +920,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_co= unt) kfree(tqe); } while (--entries); for (i =3D 0; i < NQUEUES; i++) - wilc->txq[i].fw.count +=3D ac_pkt_num_to_chip[i]; + wilc->fw[i].count +=3D ac_pkt_num_to_chip[i]; =20 acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); =20 diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/w= ireless/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; }; =20 struct rxq_entry_t { --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 DC524C433EF for ; Thu, 23 Dec 2021 01:14:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345859AbhLWBOJ (ORCPT ); Wed, 22 Dec 2021 20:14:09 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:17748 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235443AbhLWBOH (ORCPT ); Wed, 22 Dec 2021 20:14:07 -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=EAPQRl9XYrJUUbnmBFI0oiwVcQ9+ZAVKjeClJzCesz8=; b=bmo2xaUcf4Gu0xVrnJmREEsXgLBlENc3edPCdKxjQYBPf2zpHAkoRKU3VOuqJLBeHBuG v/sN03Z6xFCWwuifdMVAxlyJLeq5NojC6rZ3iaBJ9cpTnCmeZOfUWmNOmLVHeI2pNBvvmv oWLcQ7Sa1fGYHq3zw90H5JGLemGnAvnzgwkzzRNy2TbqoB7WvpWl7leldGUpCw1bkZ/vqJ trI+oPEJw4MKap6sEvu0cwjq6OMv23Qb3nWf8Lb+2VYU4lKw2/PYkSvRmd0Qeg1rICNXP1 Qt9dM8mzXGsJg3twScDtNK/pOGzdZW3SFbfB4UzweU8nqnjVvH6pDaCKl2UR1PQg== Received: by filterdrecv-64fcb979b9-7lnp4 with SMTP id filterdrecv-64fcb979b9-7lnp4-1-61C3CD5D-31 2021-12-23 01:14:05.752259373 +0000 UTC m=+8644592.682819742 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-6-1 (SG) with ESMTP id O7tYqgpCS7SEqvxXfg_VLg Thu, 23 Dec 2021 01:14:05.558 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id DAC1E700BB0; Wed, 22 Dec 2021 18:14:04 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 04/50] wilc1000: factor common code in wilc_wlan_cfg_set() and wilc_wlan_cfg_get() Date: Thu, 23 Dec 2021 01:14:05 +0000 (UTC) Message-Id: <20211223011358.4031459-5-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvKRPg1r8DnHgLz9uT?= =?us-ascii?Q?sd8CBTF3hyA386sin=2FBGCA3+pABmTC=2FMMOPAidl?= =?us-ascii?Q?lHc49Lyg8vU82CAz1L5iTJI+eUXDHHMAjRiGOam?= =?us-ascii?Q?gA0EFEnfGmgsShArYNmJ1I6BIwg9phbZbYna+n6?= =?us-ascii?Q?YJfnqfVs9as9=2F5AmAeBbJ+o=2F8Mjxz90ZhT7OvV=2F?= =?us-ascii?Q?R2KRQNIn+WeXyFmBLy1WA=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 | 79 ++++++++++--------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index d1f68df1dbeef..97624f758cbe4 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -1276,8 +1276,28 @@ static int wilc_wlan_cfg_commit(struct wilc_vif *vif= , int type, return 0; } =20 -int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, - u32 buffer_size, int commit, u32 drv_handler) +/** + * wilc_wlan_cfg_apply_wid() - Add a config set or get (query). + * @vif: The virtual interface to which the set/get applies. + * @start: Should be 1 if a new config packet should be initialized, + * 0 otherwise. + * @wid: The WID to use. + * @buffer: For a set, the bytes to include in the request, + * for a get, the buffer in which to return the result. + * @buffer_size: The size of the buffer in bytes. + * @commit: Should be 1 if the config packet should be sent after + * adding this request/query. + * @drv_handler: An opaque cookie that will be sent in the config header. + * @set: Should be true if a set, false for get. + * + * Add a WID set/query to the current config packet and optionally + * submit the resulting packet to the chip and wait for its reply. + * + * Return: Zero on failure, positive number on success. + */ +static int wilc_wlan_cfg_apply_wid(struct wilc_vif *vif, int start, u16 wi= d, + u8 *buffer, u32 buffer_size, int commit, + u32 drv_handler, bool set) { u32 offset; int ret_size; @@ -1289,8 +1309,12 @@ int wilc_wlan_cfg_set(struct wilc_vif *vif, int star= t, u16 wid, u8 *buffer, wilc->cfg_frame_offset =3D 0; =20 offset =3D wilc->cfg_frame_offset; - ret_size =3D wilc_wlan_cfg_set_wid(wilc->cfg_frame.frame, offset, - wid, buffer, buffer_size); + if (set) + ret_size =3D wilc_wlan_cfg_set_wid(wilc->cfg_frame.frame, offset, + wid, buffer, buffer_size); + else + ret_size =3D wilc_wlan_cfg_get_wid(wilc->cfg_frame.frame, offset, + wid); offset +=3D ret_size; wilc->cfg_frame_offset =3D offset; =20 @@ -1299,9 +1323,11 @@ int wilc_wlan_cfg_set(struct wilc_vif *vif, int star= t, u16 wid, u8 *buffer, return ret_size; } =20 - 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); =20 - 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 =3D 0; =20 if (!wait_for_completion_timeout(&wilc->cfg_event, @@ -1317,41 +1343,18 @@ int wilc_wlan_cfg_set(struct wilc_vif *vif, int sta= rt, u16 wid, u8 *buffer, return ret_size; } =20 +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 =3D vif->wilc; - - mutex_lock(&wilc->cfg_cmd_lock); - - if (start) - wilc->cfg_frame_offset =3D 0; - - offset =3D wilc->cfg_frame_offset; - ret_size =3D wilc_wlan_cfg_get_wid(wilc->cfg_frame.frame, offset, wid); - offset +=3D ret_size; - wilc->cfg_frame_offset =3D 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 =3D 0; - - if (!wait_for_completion_timeout(&wilc->cfg_event, - WILC_CFG_PKTS_TIMEOUT)) { - netdev_dbg(vif->ndev, "%s: Timed Out\n", __func__); - ret_size =3D 0; - } - wilc->cfg_frame_offset =3D 0; - wilc->cfg_seq_no +=3D 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); } =20 int wilc_send_config_pkt(struct wilc_vif *vif, u8 mode, struct wid *wids, --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 0E4D0C433F5 for ; Thu, 23 Dec 2021 01:16:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346756AbhLWBQO (ORCPT ); Wed, 22 Dec 2021 20:16:14 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27490 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346272AbhLWBOy (ORCPT ); Wed, 22 Dec 2021 20:14:54 -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=Hgcvux2x80iJNHTT8Ywl3SP3JaAxVpVY4jdADVtyp24=; b=Zxb6E2yywaTqNbgdk7xF0Hb7M6bZBGfSj3ue71HXm4EUzTfmYCieKc5YrGHzJivzvITU 2jjwWex4r8C0OEf36dCqam1wf463/NKRRF9WVkndExYOdxJqUngipCu0twbUaT3ISfBFf7 q1+FWbqsZOvxOo1IhHi5uehOOd2NY8lx6/jz6LDTB49CrLLlO3omRSuO+wX48ggI28hcf3 X4DQKtvgpP9Q+hJSvn5nuRSy5seVlrXDm8n/C6Rv3V0RK1sBARuARnz8WjnSHbjY8VWMwQ 1fbdWTSv3g9oDNr/YFMFuS11NrbVdTR8CU868BHcJCva9Jlkj50HxtaYkYIzAaPA== Received: by filterdrecv-7bf5c69d5-n84ln with SMTP id filterdrecv-7bf5c69d5-n84ln-1-61C3CD5E-B 2021-12-23 01:14:06.168607769 +0000 UTC m=+9687225.761254579 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-1-1 (SG) with ESMTP id SbsXXKDTRbKHV6cqEM3tPw Thu, 23 Dec 2021 01:14:06.029 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id E32C1700BFC; Wed, 22 Dec 2021 18:14:04 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 05/50] wilc1000: add wilc_wlan_tx_packet_done() function Date: Thu, 23 Dec 2021 01:14:07 +0000 (UTC) Message-Id: <20211223011358.4031459-6-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvCKFafSZUZYOu1P05?= =?us-ascii?Q?CEj+Zsb9CK5JKRSqsrljNdImB023LgVhJEGXKH0?= =?us-ascii?Q?RMK5+rzygP7Kr=2FZNSpO4YzuYBgPGjO47BNoSu6x?= =?us-ascii?Q?ucblNqztTA6oVa1MnqWOIDTWz=2FN7Zk223PDRRyM?= =?us-ascii?Q?q+X7M2XcTZLbyaC1vKvXwXTwp1mCRPsN=2FEiSdtr?= =?us-ascii?Q?Iq8S3KfVsh7kFqFfW4G=2Fw=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/w= ireless/microchip/wilc1000/wlan.c index 97624f758cbe4..7b7ee6ee9f849 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); } =20 +static void wilc_wlan_tx_packet_done(struct txq_entry_t *tqe, int status) +{ + tqe->status =3D status; + if (tqe->tx_complete_func) + tqe->tx_complete_func(tqe->priv, tqe->status); + if (tqe->ack_idx !=3D NOT_TCP_ACK && tqe->ack_idx < MAX_PENDING_ACKS) + tqe->vif->ack_filter.pending_acks[tqe->ack_idx].txqe =3D NULL; + kfree(tqe); +} + static void wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) { struct wilc_vif *vif =3D netdev_priv(dev); @@ -220,11 +230,7 @@ static void wilc_wlan_txq_filter_dup_tcp_ack(struct ne= t_device *dev) tqe =3D f->pending_acks[i].txqe; if (tqe) { wilc_wlan_txq_remove(wilc, tqe->q_num, tqe); - tqe->status =3D 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_c= ount) tqe->buffer, tqe->buffer_size); offset +=3D vmm_sz; i++; - tqe->status =3D 1; - if (tqe->tx_complete_func) - tqe->tx_complete_func(tqe->priv, tqe->status); - if (tqe->ack_idx !=3D NOT_TCP_ACK && - tqe->ack_idx < MAX_PENDING_ACKS) - vif->ack_filter.pending_acks[tqe->ack_idx].txqe =3D NULL; - kfree(tqe); + wilc_wlan_tx_packet_done(tqe, 1); } while (--entries); for (i =3D 0; i < NQUEUES; i++) wilc->fw[i].count +=3D ac_pkt_num_to_chip[i]; @@ -1236,11 +1236,8 @@ void wilc_wlan_cleanup(struct net_device *dev) =20 wilc->quit =3D 1; for (ac =3D 0; ac < NQUEUES; ac++) { - while ((tqe =3D wilc_wlan_txq_remove_from_head(wilc, ac))) { - if (tqe->tx_complete_func) - tqe->tx_complete_func(tqe->priv, 0); - kfree(tqe); - } + while ((tqe =3D wilc_wlan_txq_remove_from_head(wilc, ac))) + wilc_wlan_tx_packet_done(tqe, 0); } =20 while ((rqe =3D wilc_wlan_rxq_remove(wilc))) --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 87818C433F5 for ; Thu, 23 Dec 2021 01:15:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346448AbhLWBPY (ORCPT ); Wed, 22 Dec 2021 20:15:24 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18094 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240443AbhLWBOJ (ORCPT ); Wed, 22 Dec 2021 20:14:09 -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=HPVfzeTUe/WGAcSpYNV1LTwnd+/+fQEScpSKKNE3ps4=; b=QDUr0aYc9OioLKyNx+0BG1Uqf26kyvOez1Ui6KpBWlpsy1ZtE1rxgHvZzDq6bhInYrcO IyxDL0ArZVJLR7mG9GEZgzxSgOyE+f4wpsUoBeRop5Qvn6cEIk+pSa0WVWhYnCk4CEw0J1 2ctCg0B9XjauGb5l3FLGMAcTCl5++f1EJhsUt3iIbBHuwCvY3oqnS8uTL9UHy6ybZiE9Ui qn8EBCOe9/B1V+FkvHW3auk89Jr0qFXNsG5qGTd4kfWwF/e/h5Y1ymN5dZayPYGiu8GcUn rFlTh/zGs/ZJyeodY7g94VYvhevljpRXEgXwcIi0zF74qMFo97qkoMDUADgsXYhQ== Received: by filterdrecv-656998cfdd-rqq5v with SMTP id filterdrecv-656998cfdd-rqq5v-1-61C3CD5E-19 2021-12-23 01:14:06.403185438 +0000 UTC m=+7955207.157107831 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-4-1 (SG) with ESMTP id eeiDkwZeSRyUJpU1jcnWxA Thu, 23 Dec 2021 01:14:06.203 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id E7022700C16; Wed, 22 Dec 2021 18:14:04 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 06/50] wilc1000: move tx packet drop code into its own function Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-7-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvDVRIOLZX=2Fuaqgwge?= =?us-ascii?Q?pdd=2FOprcOg8eS0wCEoSluFg9GT2EE9PHLrMK+sW?= =?us-ascii?Q?kumqROGfcg1jVIacE+3XCYucS1+AoWeOAnjMVE0?= =?us-ascii?Q?tHZ1n3gzbYZYl+OBzsy7A7F1UbJrp71qFrZzndR?= =?us-ascii?Q?tXsH3=2FjSm2mQCQwn2pZ00A8dH8Clco3SBDk0kw6?= =?us-ascii?Q?ehI7PwNM=2FI9Wxo8zPXLzg=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/w= ireless/microchip/wilc1000/wlan.c index 7b7ee6ee9f849..e4342631aae93 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); } =20 +static void wilc_wlan_txq_drop_net_pkt(struct txq_entry_t *tqe) +{ + struct wilc *wilc =3D 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 =3D netdev_priv(dev); @@ -228,10 +236,8 @@ static void wilc_wlan_txq_filter_dup_tcp_ack(struct ne= t_device *dev) struct txq_entry_t *tqe; =20 tqe =3D 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 =3D 0; --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 61245C433FE for ; Thu, 23 Dec 2021 01:15:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346480AbhLWBP0 (ORCPT ); Wed, 22 Dec 2021 20:15:26 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:17986 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239861AbhLWBOK (ORCPT ); Wed, 22 Dec 2021 20:14:10 -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=+7AWGxcrq5YzxQh8YZpRRrdRupC/5aJM8GvitkVOgJc=; b=sgnljYTeOYohG3acZKV0iK0B/fvJScPcF/noXswvlzrshoSVIfHYus7hQF1N20wQ8OLi M+xlQUrF0Hh5pmmtHQwkpNj38pXSy6IBo+JrSKphjO/5Uc7u2mhZpyXXmzFlsPpARYwWyt 7cTNgnB1F91PHzjP2tHIDCBzL48Udq6LdKVQaqhlqO7t6no7RWB1I6KJAKYq+jrvnimXNU dqCKzgfnLUey0mZlNF9kVC5MLsh1wF+E5OqBkJLxb8+nki/EwDx1ltomVqHSuOqp+LWSNw 8XA7j4v+7jq8J9DPw5wN2Epwejb70xOhXt3gpWAJl98MB5YF7dSQCAelZuzsgxcQ== Received: by filterdrecv-75ff7b5ffb-7ssmw with SMTP id filterdrecv-75ff7b5ffb-7ssmw-1-61C3CD5E-11 2021-12-23 01:14:06.196346041 +0000 UTC m=+9687225.265879185 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-3-0 (SG) with ESMTP id 6x-HI6p1SLWMDmAwRcjxkg Thu, 23 Dec 2021 01:14:06.029 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id EA6AC700D4D; Wed, 22 Dec 2021 18:14:04 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 07/50] wilc1000: increment tx_dropped stat counter on tx packet drop Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-8-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvDKrArIMv0ekRFhsm?= =?us-ascii?Q?fMLkKZAX5foC3EIyVvusbxrwy0G4rOImm0QqeNx?= =?us-ascii?Q?D5K9LJ+WXaZDsNQsAFlQRJjojhhxrTz0f27W4q9?= =?us-ascii?Q?0aK4hYDXrlwQ6DYgPE8kjb6SbpAaNgukvMiX9DP?= =?us-ascii?Q?oDZz7gk00Lei0V7h+18gSnvgfIiTJ9erP+CwmrA?= =?us-ascii?Q?bmyru3Kh1bvNnZKoUvDJg=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/w= ireless/microchip/wilc1000/wlan.c index e4342631aae93..4e59d4c707ea5 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) =20 static void wilc_wlan_txq_drop_net_pkt(struct txq_entry_t *tqe) { - struct wilc *wilc =3D tqe->vif->wilc; + struct wilc_vif *vif =3D tqe->vif; + struct wilc *wilc =3D vif->wilc; + + vif->ndev->stats.tx_dropped++; =20 wilc_wlan_txq_remove(wilc, tqe->q_num, tqe); wilc_wlan_tx_packet_done(tqe, 1); --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 2504AC433F5 for ; Thu, 23 Dec 2021 01:17:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346058AbhLWBRU (ORCPT ); Wed, 22 Dec 2021 20:17:20 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18042 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239943AbhLWBOK (ORCPT ); Wed, 22 Dec 2021 20:14:10 -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=JGekckS+BkDawyQ24EmnCw50b1Ts4lgPiiG7L5RqiKE=; b=o7+eFSchQFMwUyNZH0kT4TN8VmPYEK4qWDay93h9P3QLO46155x/LnLGc6mZY0ZziPVM RacJ0GZtxEa08gUYZVK6suCAyjOZRIW7wjbHKTaw2rlO9qXPnY1zPh9oZSSCCS7AT5Iu8L 7lOw8eryl6CgWJhQg+rsX6zO64f+0trjzSbh8mkEvZn4X+IUpdElOXrQwgEp7VSROsBwpd 93YyI0zKfDBlp8b8ez8WFdlf5B6bqImO8QXJwMbG497VPwpnxvAOE/1RS8NyTLnXPOl7AA mZkrTZfpmJhcaBpUGxDsZSwQDLSMwmJfgP3mfG9vBmpNoKxTpeMbHp6x1K85ygcw== Received: by filterdrecv-7bf5c69d5-rfl26 with SMTP id filterdrecv-7bf5c69d5-rfl26-1-61C3CD5E-C 2021-12-23 01:14:06.309139133 +0000 UTC m=+9687195.050788963 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-1-0 (SG) with ESMTP id Rnh6AwIMRxeb54SvekpCHA Thu, 23 Dec 2021 01:14:06.168 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id EDD5C700D6B; Wed, 22 Dec 2021 18:14:04 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 08/50] wilc1000: fix management packet type inconsistency Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-9-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvH8QYPm77HLoqzd6i?= =?us-ascii?Q?pELrLw2hwsFT5BXPNL6oemUucAN0NCztY18dpLk?= =?us-ascii?Q?nIyWtZNrLRCDESJBCsE8mIZKewcdLRAEQOl0+T4?= =?us-ascii?Q?aV=2F1vU9+DWoZHzJEyH2UFq8Zb9bGy3myoS0hA3G?= =?us-ascii?Q?v01PtrHaQ3CvniE4RcNJpuUN6YoS5YMQ19lLlJy?= =?us-ascii?Q?j+pmfHyC+rWrN+wQ+O8Sg=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/w= ireless/microchip/wilc1000/wlan.c index 4e59d4c707ea5..1156498e66b81 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 =3D buffer_size; tqe->tx_complete_func =3D tx_complete_fn; tqe->priv =3D priv; - tqe->q_num =3D AC_BE_Q; + tqe->q_num =3D AC_VO_Q; tqe->ack_idx =3D NOT_TCP_ACK; tqe->vif =3D vif; wilc_wlan_txq_add_to_tail(dev, AC_VO_Q, tqe); --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 2C82FC433EF for ; Thu, 23 Dec 2021 01:17:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346564AbhLWBRY (ORCPT ); Wed, 22 Dec 2021 20:17:24 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:17970 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238680AbhLWBOI (ORCPT ); Wed, 22 Dec 2021 20:14:08 -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=XUnrrGniQ2mn68UkAYnDzma+xGBy6FTx8ryJIfAGnQo=; b=VcBFnY2muLpFkQ1893uov1TVafXAcHDZDkHJB690ydWybbP6RK+v19Y3c2i9f1kPHGF0 ZFC2xEXM0oET8DD5ca3q2yYeV1DFWmB9tObGhcR373tikpnfceftTH7lZkDgzwHZfNutQw NV8KXIrKPW/eNFXW2H70JgUIzgIVIftpjKXw3v5sO2yXTnzzQTtvoM348N4CDCY5TU1RBO IgshvXMhDkUxJ3DZvGUoL3QDFBS2f/nMxQt6nXxG9eQ32YD0xSN58iBOi+wrA2bFr4inBE dTe5e5MP/LEF79kC8pEC+erqAHlL73U8C0FYkRsCpsb0645Z3W92aii3wz2UbOeg== Received: by filterdrecv-64fcb979b9-7lnp4 with SMTP id filterdrecv-64fcb979b9-7lnp4-1-61C3CD5E-10 2021-12-23 01:14:06.269481321 +0000 UTC m=+8644593.200041699 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-6-0 (SG) with ESMTP id LNQyyxPoSt-QvKfE-Cejvg Thu, 23 Dec 2021 01:14:06.045 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id F1607700F78; Wed, 22 Dec 2021 18:14:04 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 09/50] wilc1000: prepare wilc_wlan_tx_packet_done() for sk_buff changes Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-10-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvCb1xlyXRSrVqQqxd?= =?us-ascii?Q?c6y8Gj6yOsjIp2cOckDjzQ6eQStIL96U5Dw3ROd?= =?us-ascii?Q?QNJIrQjv46xS5QYahfsOrfwiSRwctE9aF271tnB?= =?us-ascii?Q?7ggtb3EX7=2FvKH4UuSK2oQ++9f27+UWvJf2Gl7cy?= =?us-ascii?Q?j5X703R7EnbaWi540H8NGWTfa55KihzX9+3mWL3?= =?us-ascii?Q?OzEjTrKpTN7jKL+rPK5xg=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/w= ireless/microchip/wilc1000/wlan.c index 1156498e66b81..77dd91c23faad 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) =20 static void wilc_wlan_tx_packet_done(struct txq_entry_t *tqe, int status) { + struct wilc_vif *vif =3D tqe->vif; + int ack_idx =3D tqe->ack_idx; + tqe->status =3D status; if (tqe->tx_complete_func) tqe->tx_complete_func(tqe->priv, tqe->status); - if (tqe->ack_idx !=3D NOT_TCP_ACK && tqe->ack_idx < MAX_PENDING_ACKS) - tqe->vif->ack_filter.pending_acks[tqe->ack_idx].txqe =3D NULL; + if (ack_idx !=3D NOT_TCP_ACK && ack_idx < MAX_PENDING_ACKS) + vif->ack_filter.pending_acks[ack_idx].txqe =3D NULL; kfree(tqe); } =20 --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 A2C16C433FE for ; Thu, 23 Dec 2021 01:14:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345738AbhLWBOS (ORCPT ); Wed, 22 Dec 2021 20:14:18 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18100 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241655AbhLWBOK (ORCPT ); Wed, 22 Dec 2021 20:14:10 -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=RrC6yl4xH6yjl3QxLWQ7ovhkZ1xBTAY6/gvQ4887ii8=; b=lCw62VJ1nIh5yKKDj+tjObc0DQ0ZSv6WcUyofX/1byILozJ8h7to26jWmhcnCtzxHlLJ bH45ZcIk7s2IET4bqlz760PYwUBMjXcHhE4JpkLp7chnwPWKZ2byUaavmZHS6jTaK2+4qN qhghAXn9QDkv6LHyawWdfObgmKPeLVPQuuirXJbYzSspe+zicQQsG6to7vpGZiUGhSvfzl oZARFFcgQHYw7vLh9ieNTCHImbirj9PZUnFcIjhBw06WRwoyzBm5rU/xHPr0Nahdb3Onbm LBEwXtgDA6rkyBUOL8aP3Qx1S4MtrrqX1hppa4Lq6G6wYvoHBfZVDnKhkWu9MGyw== Received: by filterdrecv-75ff7b5ffb-ndqvq with SMTP id filterdrecv-75ff7b5ffb-ndqvq-1-61C3CD5E-13 2021-12-23 01:14:06.305257498 +0000 UTC m=+9687224.905653124 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-2-0 (SG) with ESMTP id ZcYzltZZSCi_lFJvTySvaw Thu, 23 Dec 2021 01:14:06.174 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 00E3E70101D; Wed, 22 Dec 2021 18:14:04 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 10/50] wilc1000: factor initialization of tx queue-specific packet fields Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-11-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvCJLlBTC4xumxACeW?= =?us-ascii?Q?N+4uQ8hRebKr63nOnFFNqzj5hYSEwCbOzbV+zUL?= =?us-ascii?Q?cwe6Kk0CVpAqADDFfmHNMM=2FvUvf=2FWXRI7Fr0kJY?= =?us-ascii?Q?X9v5S4LOnLgtceaCErDIbpovJ=2FZGvdk8IovLiOi?= =?us-ascii?Q?vJ3L=2FvhfsIGhOBb7ykwMo7hoBk3krHO17MyrBPz?= =?us-ascii?Q?LARKpt75YFV1rsF9+59mA=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/w= ireless/microchip/wilc1000/wlan.c index 77dd91c23faad..781c40f2c930c 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -12,8 +12,12 @@ =20 #define WAKE_UP_TRIAL_RETRY 10000 =20 +#define NOT_TCP_ACK (-1) + static const u8 factors[NQUEUES] =3D {1, 1, 1, 1}; =20 +static void tcp_process(struct net_device *, struct txq_entry_t *); + static inline bool is_wilc1000(u32 id) { return (id & (~WILC_CHIP_REV_FIELD)) =3D=3D WILC_1000_BASE_ID; @@ -60,13 +64,26 @@ wilc_wlan_txq_remove_from_head(struct wilc *wilc, u8 q_= num) return tqe; } =20 -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 =3D vif; + tqe->q_num =3D q_num; + tqe->type =3D type; + tqe->ack_idx =3D 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 =3D netdev_priv(dev); struct wilc *wilc =3D vif->wilc; =20 + init_txq_entry(tqe, vif, type, q_num); + if (type =3D=3D WILC_NET_PKT && vif->ack_filter.enabled) + tcp_process(dev, tqe); + spin_lock_irqsave(&wilc->txq_spinlock, flags); =20 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); } =20 -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 =3D vif->wilc; =20 + init_txq_entry(tqe, vif, type, q_num); + mutex_lock(&wilc->txq_add_to_head_cs); =20 spin_lock_irqsave(&wilc->txq_spinlock, flags); @@ -97,8 +116,6 @@ static void wilc_wlan_txq_add_to_head(struct wilc_vif *v= if, u8 q_num, wake_up_interruptible(&wilc->txq_event); } =20 -#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; } =20 - tqe->type =3D WILC_CFG_PKT; tqe->buffer =3D buffer; tqe->buffer_size =3D buffer_size; tqe->tx_complete_func =3D NULL; tqe->priv =3D NULL; - tqe->q_num =3D AC_VO_Q; - tqe->ack_idx =3D NOT_TCP_ACK; - tqe->vif =3D vif; =20 - 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); =20 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 =3D WILC_NET_PKT; tqe->buffer =3D buffer; tqe->buffer_size =3D buffer_size; tqe->tx_complete_func =3D tx_complete_fn; tqe->priv =3D tx_data; - tqe->vif =3D vif; =20 q_num =3D ac_classify(wilc, tx_data->skb); - tqe->q_num =3D 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, } =20 if (is_ac_q_limit(wilc, q_num)) { - tqe->ack_idx =3D 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 =3D WILC_MGMT_PKT; tqe->buffer =3D buffer; tqe->buffer_size =3D buffer_size; tqe->tx_complete_func =3D tx_complete_fn; tqe->priv =3D priv; - tqe->q_num =3D AC_VO_Q; - tqe->ack_idx =3D NOT_TCP_ACK; - tqe->vif =3D 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; } =20 --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 B7581C433EF for ; Thu, 23 Dec 2021 01:14:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241904AbhLWBOP (ORCPT ); Wed, 22 Dec 2021 20:14:15 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18044 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240022AbhLWBOK (ORCPT ); Wed, 22 Dec 2021 20:14:10 -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=pzoQ8/2NNAK4ATykxYPnsdStYUF1CXuhMggSoBJHvS0=; b=kggOZLvyCFjQAqRfjyC9khGmtSKnSeXjxfIsv+w51tombRHzqOpGaFpK9w2ov+HqwPoR 9BPqJvOQSOQjv6YEi/EhxXzCxYDpt/qJ08xCeIiisJtCZgJ+D+I3ANQGtn4lH83h39khPg SGSDy6n4CfttLWBPA05HuQG9KoQWistIbE9Gx5W5I+r3w0Ra0TC8tZr8WQ2Ug5riEi4RjY aH+xXV08CVVdhALm9hiHTHNpYo+bDqrdqloVrwKKk+0fkhslOiKRgeHaSsbtNAu0o91u7g ImUfgZQq3gmreCmdkE8oDCqHpspEl27cqk4Atw0MNZxzfCoJKoD9sIPNY6zZDbzw== Received: by filterdrecv-75ff7b5ffb-6sw96 with SMTP id filterdrecv-75ff7b5ffb-6sw96-1-61C3CD5E-7 2021-12-23 01:14:06.163181464 +0000 UTC m=+9687258.234840275 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-1-0 (SG) with ESMTP id mXqZGDqcQA29k1_iIsj-2g Thu, 23 Dec 2021 01:14:06.024 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 088427010AC; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 11/50] wilc1000: convert tqx_entries from "int" to "atomic_t" Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-12-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvMpnkY6SXEETBOQOb?= =?us-ascii?Q?cjnMOudSn0Sbh67pCS5DMiOw3ECgFuH=2FG=2FUpuN+?= =?us-ascii?Q?chI5OwysiIgY+5fa81Ji5w2rnvCHgzJAUNY9Y3Q?= =?us-ascii?Q?Ez2yNPnPTQ9X=2F5YyDqQMkKdszgWRzjtrE0UQYji?= =?us-ascii?Q?a36KI47CocXq00K+5GTtqQB45=2F5w6SnyVGqyG6a?= =?us-ascii?Q?YCj9gTxj6goAQcifw95YA=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 d5969f2e369c4..486091a4cb993 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)); =20 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 d88fee8f9a6b0..60f4871a7d579 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.h +++ b/drivers/net/wireless/microchip/wilc1000/netdev.h @@ -255,7 +255,7 @@ struct wilc { u8 *tx_buffer; =20 struct txq_handle txq[NQUEUES]; - int txq_entries; + atomic_t txq_entries; struct txq_fw_recv_queue_stat fw[NQUEUES]; =20 struct wilc_tx_queue_status tx_q_limit; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index 781c40f2c930c..26b7d219ecbbb 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 -=3D 1; + atomic_dec(&wilc->txq_entries); wilc->txq[q_num].count--; } =20 @@ -57,7 +57,7 @@ wilc_wlan_txq_remove_from_head(struct wilc *wilc, u8 q_nu= m) tqe =3D list_first_entry(&wilc->txq[q_num].txq_head.list, struct txq_entry_t, list); list_del(&tqe->list); - wilc->txq_entries -=3D 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); =20 list_add_tail(&tqe->list, &wilc->txq[q_num].txq_head.list); - wilc->txq_entries +=3D 1; + atomic_inc(&wilc->txq_entries); wilc->txq[q_num].count++; =20 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); =20 list_add(&tqe->list, &wilc->txq[q_num].txq_head.list); - wilc->txq_entries +=3D 1; + atomic_inc(&wilc->txq_entries); wilc->txq[q_num].count++; =20 spin_unlock_irqrestore(&wilc->txq_spinlock, flags); @@ -484,7 +484,7 @@ int wilc_wlan_txq_add_net_pkt(struct net_device *dev, kfree(tqe); } =20 - return wilc->txq_entries; + return atomic_read(&wilc->txq_entries); } =20 int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buf= fer, @@ -952,7 +952,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_co= unt) mutex_unlock(&wilc->txq_add_to_head_cs); =20 out_update_cnt: - *txq_count =3D wilc->txq_entries; + *txq_count =3D atomic_read(&wilc->txq_entries); return ret; } =20 --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 73561C433F5 for ; Thu, 23 Dec 2021 01:14:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346048AbhLWBO1 (ORCPT ); Wed, 22 Dec 2021 20:14:27 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18122 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345646AbhLWBON (ORCPT ); Wed, 22 Dec 2021 20:14:13 -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=m7/NHd70aW+5nMyYcygmge2MErZGaxPW2OeWbTdP2ZI=; b=UGhCfPVJLrG5fdt631HayU/HkgnPSBr/OW//HfPWFRPo8wlRWuHNDXBIj/E+KQ0c0yNb WyNfQkNuiU34RLLV5lZHygBSQQGJV9u2Z002n9RAUgixoiGtWvqPEMM5lsRAtBsDxO1l/J Dqm9hnN3r+xDBpb/21xy8t+Onzp6GGtgp75gkFy8HYakq+a1nsUJwETOhp032G2P1hZSj/ 7jO+Opn4hIVMUwuRvP8bYWO3qAYAbZiiCEHQ/1qk5s2OUvdoKFGWv5zeCWTdoY/tuUR+eB YF0Prxhr9hscKB9hb2Xpv/iO/7Yuv1WGm2vlExaUBR/KUc4o5CpoTfil89am6q7g== Received: by filterdrecv-75ff7b5ffb-q2hvm with SMTP id filterdrecv-75ff7b5ffb-q2hvm-1-61C3CD5E-1A 2021-12-23 01:14:06.383809858 +0000 UTC m=+9687230.227918554 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-canary-0 (SG) with ESMTP id odf-ZXRpRF20CW2pPp5AVQ Thu, 23 Dec 2021 01:14:06.223 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 0EB277010D8; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 12/50] wilc1000: refactor wilc_wlan_cfg_commit() a bit Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-13-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvCI5wdCf6k9nSTiV8?= =?us-ascii?Q?Y5orYAp30zrmhpmPpWiYcIZ7KjBx7mrhBRbhHE8?= =?us-ascii?Q?NiP1IDsjpJ8qs9=2F442dFh+0K0Pmp3hXJRtT3gnb?= =?us-ascii?Q?bppSwifd3UDrPx3AgrQ31wzM0gVZQMGYmDGn+hJ?= =?us-ascii?Q?eZc7UJX5QH2JvS1wUdKzd710PcZGywbJiPyJs8D?= =?us-ascii?Q?e+6UM45ott9qpwro++1Ow=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/w= ireless/microchip/wilc1000/wlan.c index 26b7d219ecbbb..2e3dc04120832 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 *vi= f, int type, struct wilc *wilc =3D vif->wilc; struct wilc_cfg_frame *cfg =3D &wilc->cfg_frame; int t_len =3D wilc->cfg_frame_offset + sizeof(struct wilc_cfg_cmd_hdr); + struct wilc_cfg_cmd_hdr *hdr; =20 - if (type =3D=3D WILC_CFG_SET) - cfg->hdr.cmd_type =3D 'W'; - else - cfg->hdr.cmd_type =3D 'Q'; - - cfg->hdr.seq_no =3D wilc->cfg_seq_no % 256; - cfg->hdr.total_len =3D cpu_to_le16(t_len); - cfg->hdr.driver_handler =3D cpu_to_le32(drv_handler); + hdr =3D &cfg->hdr; + hdr->cmd_type =3D (type =3D=3D WILC_CFG_SET) ? 'W' : 'Q'; + hdr->seq_no =3D wilc->cfg_seq_no % 256; + hdr->total_len =3D cpu_to_le16(t_len); + hdr->driver_handler =3D cpu_to_le32(drv_handler); wilc->cfg_seq_no =3D cfg->hdr.seq_no; =20 if (!wilc_wlan_txq_add_cfg_pkt(vif, (u8 *)&cfg->hdr, t_len)) --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 8F5D8C433FE for ; Thu, 23 Dec 2021 01:15:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346212AbhLWBPQ (ORCPT ); Wed, 22 Dec 2021 20:15:16 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:17942 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238481AbhLWBOJ (ORCPT ); Wed, 22 Dec 2021 20:14:09 -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=xW1715MXgBwHsK1A3U4v+kbFvvAbBFG76BgdlmNpRzE=; b=oswUulyiyzoQbmbFBk645iztnQ8z5NVCEdmI/iUIoX9EK+3J5KpoUS+m3JK4ff1oVUC8 Dm7qP5PdcEzFW/UPDYgmXu3GDND3mdMdIS/2bPcAJ+EEEhO2fyVoEtMWZ+pJEW8psdN8Zx WF+jVb0dETjAin2X8LNp6M4rItuaZLw5Ue8K+xiaF1tDKyDsHpyM5YXJV2gnGQP1VP3QYR JP/mAITLcYzO3+1aUPpyJzFNvod0a10OnLSGLOEdI6+5cUXPyr+TemOclQZd9CL2nZo7bm YcSXk0RLoyt4wYRiHpWqP6Uj8Amfdb4lT89qB+58cVQRDw2VynyJyjB5x3zTZ03g== Received: by filterdrecv-7bf5c69d5-88tll with SMTP id filterdrecv-7bf5c69d5-88tll-1-61C3CD5E-E 2021-12-23 01:14:06.177821663 +0000 UTC m=+9687225.027774416 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-1-0 (SG) with ESMTP id MsGsOEceTr-VDilM5VIsgw Thu, 23 Dec 2021 01:14:06.049 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 14FDC701151; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 13/50] wilc1000: sanitize config packet sequence number management a bit Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-14-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvGypGrhqGxl=2FEY3id?= =?us-ascii?Q?+trAVDjgRqjwx0dK6tKpD39ADl8w+Ha58BsfUJS?= =?us-ascii?Q?RdeVHdNMmSbtm+kB4TnuFscnap7cx5NsjYFljba?= =?us-ascii?Q?l7kbLCexcSuwXUeKTUFCGsgzb=2F5cOOFh9tSN7Db?= =?us-ascii?Q?GoFaUoI+MI4mflLw4dqLKFYTvtT9xh8A2khEaPk?= =?us-ascii?Q?YR2HhZck8jqEZdEZctM6g=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/w= ireless/microchip/wilc1000/wlan.c index 2e3dc04120832..979615914d420 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, =20 hdr =3D &cfg->hdr; hdr->cmd_type =3D (type =3D=3D WILC_CFG_SET) ? 'W' : 'Q'; - hdr->seq_no =3D wilc->cfg_seq_no % 256; + hdr->seq_no =3D wilc->cfg_seq_no; hdr->total_len =3D cpu_to_le16(t_len); hdr->driver_handler =3D cpu_to_le32(drv_handler); - wilc->cfg_seq_no =3D cfg->hdr.seq_no; =20 if (!wilc_wlan_txq_add_cfg_pkt(vif, (u8 *)&cfg->hdr, t_len)) return -1; @@ -1347,7 +1346,7 @@ static int wilc_wlan_cfg_apply_wid(struct wilc_vif *v= if, int start, u16 wid, } =20 wilc->cfg_frame_offset =3D 0; - wilc->cfg_seq_no +=3D 1; + wilc->cfg_seq_no =3D (wilc->cfg_seq_no + 1) % 256; mutex_unlock(&wilc->cfg_cmd_lock); =20 return ret_size; --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 48DB9C433EF for ; Thu, 23 Dec 2021 01:15:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346353AbhLWBPS (ORCPT ); Wed, 22 Dec 2021 20:15:18 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18000 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239737AbhLWBOJ (ORCPT ); Wed, 22 Dec 2021 20:14:09 -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=umwnLomDnL8JV4cAJEilJ/xdGNnjtl/WMw/dTXYXnHw=; b=XaMT+NPDkMBwRbNRZ5nRuZewLyDWkWRsKt0OjjotqbZA5gZ/4Mr952ZLdrWQlkAWkT22 3ep1d56SkgTGHRdHk942/yDUNP/FvzId1G2ygcDXyq84vd+gePBibmJKVeXV9YwBfYZcNV gQdSChdqCVd6rOG2KEHP2lmIa5Yo/JgyrJ1uu/++8vIvVEUTrfDP9whKL6AtZH32LX0nmv vtMNkh6n2lAqaGZF9QAvunsif6eXLFVbvA8sRUe8REk4j875uz5OfiZwjHq7ysBusRsKZA sL3lh45yxbtwUA6U1QNx6Xcu1Z7M/egVgOABzz3q51G5VQoNxN0ee+e6SKZ+zXSw== Received: by filterdrecv-75ff7b5ffb-w7hgd with SMTP id filterdrecv-75ff7b5ffb-w7hgd-1-61C3CD5E-9 2021-12-23 01:14:06.198059899 +0000 UTC m=+9687226.166389619 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-3-0 (SG) with ESMTP id j-W6BjeiQ9uWp7sLPSK6Ng Thu, 23 Dec 2021 01:14:06.044 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 1B3B97011B9; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 14/50] wilc1000: if there is no tx packet, don't increment packets-sent counter Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-15-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvOR25dwhR8xVxUiJR?= =?us-ascii?Q?PvfwopFiHKgJmz5nG7pPD2E+83y=2Fm+RHtKjsCtp?= =?us-ascii?Q?gPwMsMrHiC8Af1aM9ryNHWuHG4x4Wz1mgeFCsIL?= =?us-ascii?Q?gOPPNU4cgGUUGBnN8QfOAjpiI0Jsq6dH5MVfZES?= =?us-ascii?Q?WHdRuRvzkTK7LR=2F0karz0uhzMgwKEycX0ybW7KV?= =?us-ascii?Q?CYqxtT2PEud5pH730Y0ww=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/w= ireless/microchip/wilc1000/wlan.c index 979615914d420..7106e6be719c1 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 =3D 0; =20 tqe =3D wilc_wlan_txq_remove_from_head(wilc, vmm_entries_ac[i]); - ac_pkt_num_to_chip[vmm_entries_ac[i]]++; if (!tqe) break; =20 + ac_pkt_num_to_chip[vmm_entries_ac[i]]++; vif =3D tqe->vif; if (vmm_table[i] =3D=3D 0) break; --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 02C94C433EF for ; Thu, 23 Dec 2021 01:14:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346106AbhLWBOb (ORCPT ); Wed, 22 Dec 2021 20:14:31 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18264 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345711AbhLWBON (ORCPT ); Wed, 22 Dec 2021 20:14:13 -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=6H7NNmKl33EBYWw0z5heLUHxIv7BPWBWa24waKEMcSk=; b=ZgFYtDQ61ycVQAPEPH21tNcHpdXveRej1XAmOcA6aSfK1k7Ak+y1+R/9kfG8VlIPBOfB yMRvKzFrYskPJjk+Rs0KvYgHlBDLEfoYPshYjiLO3WYYyMdtMVm6cn2fps76nqhjozn7f/ PTx6/BiJWgyUYqUuGL6B4RF748OCKvssMK2xflrSxFGVuwbQa4+pR6ejqUVWKzA80D80AR uQGHzQNABfgSWhnAlPZ9dzQ2BZjuh+8duYsjdVGCSVCM3uXEJOatHXPbnB+Q6pcfKmh9EQ lmJBLwHFqu1u0PQhgqf41YGwjjrYzQcWh0nd6Q4yKTO8elDKm5sNGLLM9FobMljg== Received: by filterdrecv-656998cfdd-phncc with SMTP id filterdrecv-656998cfdd-phncc-1-61C3CD5E-34 2021-12-23 01:14:06.590646115 +0000 UTC m=+7955207.776892892 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-6-1 (SG) with ESMTP id g8xYSwNRSQ2WqdDpKBNqeA Thu, 23 Dec 2021 01:14:06.434 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 21BB97011EE; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 15/50] wilc1000: add struct wilc_skb_tx_cb as an alias of struct txq_entry_t Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-16-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvJVai0WXMG1+HQN6o?= =?us-ascii?Q?v2CuUX1YfqzWiuT0Ki8nekpKI3Qgbj3UWNGvbRS?= =?us-ascii?Q?OCBP2hth34cttp0FYFVAL1+SeTew=2F1GfP3ry5Yz?= =?us-ascii?Q?XiEu+y=2F9UaJs1ez=2F9vtvK4JaJ1slaXIlsgHZJe7?= =?us-ascii?Q?qdXVOTDvMHNHasAcC+icU7nq1Zm2kBpZfca=2FPza?= =?us-ascii?Q?nEKIqRVQEW=2FD=2FZ2FQYTMw=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/w= ireless/microchip/wilc1000/wlan.c index 7106e6be719c1..c352e939f1901 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 =3D WILC_SKB_TX_CB(tqe); + tqe->vif =3D vif; - tqe->q_num =3D q_num; - tqe->type =3D type; - tqe->ack_idx =3D NOT_TCP_ACK; + tx_cb->type =3D type; + tx_cb->q_num =3D q_num; + tx_cb->ack_idx =3D NOT_TCP_ACK; } =20 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 =3D WILC_SKB_TX_CB(txqe); struct tcp_ack_filter *f =3D &vif->ack_filter; u32 i =3D f->pending_base + f->pending_acks_idx; =20 @@ -150,7 +153,7 @@ static inline void add_tcp_pending_ack(struct wilc_vif = *vif, u32 ack, f->pending_acks[i].ack_num =3D ack; f->pending_acks[i].txqe =3D txqe; f->pending_acks[i].session_index =3D session_index; - txqe->ack_idx =3D i; + tx_cb->ack_idx =3D 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 =3D tqe->vif; - int ack_idx =3D tqe->ack_idx; + struct wilc_skb_tx_cb *tx_cb =3D WILC_SKB_TX_CB(tqe); + int ack_idx =3D tx_cb->ack_idx; =20 tqe->status =3D status; if (tqe->tx_complete_func) @@ -224,10 +228,11 @@ static void wilc_wlan_txq_drop_net_pkt(struct txq_ent= ry_t *tqe) { struct wilc_vif *vif =3D tqe->vif; struct wilc *wilc =3D vif->wilc; + struct wilc_skb_tx_cb *tx_cb =3D WILC_SKB_TX_CB(tqe); =20 vif->ndev->stats.tx_dropped++; =20 - 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); } =20 @@ -728,6 +733,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_co= unt) bool max_size_over =3D 0, ac_exist =3D 0; int vmm_sz =3D 0; struct txq_entry_t *tqe_q[NQUEUES]; + struct wilc_skb_tx_cb *tx_cb; int ret =3D 0; int counter; int timeout; @@ -772,9 +778,10 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_c= ount) break; } =20 - if (tqe_q[ac]->type =3D=3D WILC_CFG_PKT) + tx_cb =3D WILC_SKB_TX_CB(tqe_q[ac]); + if (tx_cb->type =3D=3D WILC_CFG_PKT) vmm_sz =3D ETH_CONFIG_PKT_HDR_OFFSET; - else if (tqe_q[ac]->type =3D=3D WILC_NET_PKT) + else if (tx_cb->type =3D=3D WILC_NET_PKT) vmm_sz =3D ETH_ETHERNET_HDR_OFFSET; else vmm_sz =3D HOST_HDR_OFFSET; @@ -787,7 +794,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_co= unt) break; } vmm_table[i] =3D vmm_sz / 4; - if (tqe_q[ac]->type =3D=3D WILC_CFG_PKT) + if (tx_cb->type =3D=3D WILC_CFG_PKT) vmm_table[i] |=3D BIT(10); =20 cpu_to_le32s(&vmm_table[i]); @@ -898,6 +905,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_co= unt) =20 ac_pkt_num_to_chip[vmm_entries_ac[i]]++; vif =3D tqe->vif; + tx_cb =3D WILC_SKB_TX_CB(tqe); if (vmm_table[i] =3D=3D 0) break; =20 @@ -905,20 +913,20 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_= count) vmm_sz =3D FIELD_GET(WILC_VMM_BUFFER_SIZE, vmm_table[i]); vmm_sz *=3D 4; =20 - if (tqe->type =3D=3D WILC_MGMT_PKT) + if (tx_cb->type =3D=3D WILC_MGMT_PKT) mgmt_ptk =3D 1; =20 - header =3D (FIELD_PREP(WILC_VMM_HDR_TYPE, tqe->type) | + header =3D (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)); =20 cpu_to_le32s(&header); memcpy(&txb[offset], &header, 4); - if (tqe->type =3D=3D WILC_CFG_PKT) { + if (tx_cb->type =3D=3D WILC_CFG_PKT) { buffer_offset =3D ETH_CONFIG_PKT_HDR_OFFSET; - } else if (tqe->type =3D=3D WILC_NET_PKT) { - int prio =3D tqe->q_num; + } else if (tx_cb->type =3D=3D WILC_NET_PKT) { + int prio =3D tx_cb->q_num; =20 bssid =3D tqe->vif->bssid; buffer_offset =3D ETH_ETHERNET_HDR_OFFSET; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/w= ireless/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); }; =20 +#define wilc_skb_tx_cb txq_entry_t + +static inline struct wilc_skb_tx_cb *WILC_SKB_TX_CB(struct txq_entry_t *tq= e) +{ + return (struct wilc_skb_tx_cb *)tqe; +} + struct txq_fw_recv_queue_stat { u8 acm; u8 count; --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 77353C433F5 for ; Thu, 23 Dec 2021 01:17:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346516AbhLWBQ7 (ORCPT ); Wed, 22 Dec 2021 20:16:59 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18444 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345822AbhLWBOX (ORCPT ); Wed, 22 Dec 2021 20:14: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=AiUrZyrzmuqF+ox7MULI0/JDJqTelx0cedjXURnUDcg=; b=l415gb1kHdRDfTB1EGQh5k0lRNzP376ZfDFuW0xQZ0iUTED8fr/EmYUBT8+DmkliUHc5 ZDXvNxVsEfUYfZurVXj4E2cbojkwR38WU9/zCdDQ8LKwK4jwxIULyUcV7zF8+w3gsJSziV FexjtFDoZo4hJgkuLJ5twlTQAWVjX8iML712eVFced77/8tUWUMpFQYvLYlxH/bhHAIcCo j6x1fqk2aYHj9dvkltCIOCjWWT/VR1ptNXRqV41+SqAJ7EBZ7mVa+cCklAWHuUW+DKRAJu 6REtV/FwC6Pqedhf4egCGEVm2rrSt2esvJIEByzxTYNx6APTM6hJU4FZgOwDPkTQ== Received: by filterdrecv-75ff7b5ffb-czr4j with SMTP id filterdrecv-75ff7b5ffb-czr4j-1-61C3CD5E-B 2021-12-23 01:14:06.650207901 +0000 UTC m=+9687229.673760741 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-1-0 (SG) with ESMTP id 22PZ_gD8QyK5Me4KiVuGKA Thu, 23 Dec 2021 01:14:06.437 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 295117011FF; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 16/50] wilc1000: switch tx queue to normal sk_buff entries Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-17-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvBaesWnzz8DgI6OeP?= =?us-ascii?Q?3k=2Fb9yhMUCRwjat2o7MKZjMnxFxIBda51KS6HT1?= =?us-ascii?Q?H7X8BkNArp3AvLUMmnRzfwdCXOIycAQVSHX5NiB?= =?us-ascii?Q?x9MvmVxVnPGybr8mYx0R77K1nUwGvq2vYS6ytfF?= =?us-ascii?Q?OMfj3EhNWdqpOkZGNabm8P5rbrv+G+enw8YuTfK?= =?us-ascii?Q?GDmchLG01I9hLU1zbvuyg=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Convert 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/n= et/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); } =20 -static void wilc_wfi_mgmt_tx_complete(void *priv, int status) -{ - struct wilc_p2p_mgmt_data *pv_data =3D priv; - - kfree(pv_data->buff); - kfree(pv_data); -} - static void wilc_wfi_remain_on_channel_expired(void *data, u64 cookie) { struct wilc_vif *vif =3D data; @@ -1124,7 +1116,7 @@ static int mgmt_tx(struct wiphy *wiphy, const u8 *buf =3D params->buf; size_t len =3D params->len; const struct ieee80211_mgmt *mgmt; - struct wilc_p2p_mgmt_data *mgmt_tx; + struct sk_buff *skb; struct wilc_vif *vif =3D netdev_priv(wdev->netdev); struct wilc_priv *priv =3D &vif->priv; struct host_if_drv *wfi_drv =3D priv->hif_drv; @@ -1141,20 +1133,11 @@ static int mgmt_tx(struct wiphy *wiphy, if (!ieee80211_is_mgmt(mgmt->frame_control)) goto out; =20 - mgmt_tx =3D kmalloc(sizeof(*mgmt_tx), GFP_KERNEL); - if (!mgmt_tx) { - ret =3D -ENOMEM; - goto out; - } - - mgmt_tx->buff =3D kmemdup(buf, len, GFP_KERNEL); - if (!mgmt_tx->buff) { - ret =3D -ENOMEM; - kfree(mgmt_tx); - goto out; - } + skb =3D wilc_wlan_alloc_skb(vif, len); + if (!skb) + return -ENOMEM; =20 - mgmt_tx->size =3D len; + skb_put_data(skb, buf, len); =20 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; =20 vendor_ie =3D 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, =20 out_txq_add_pkt: =20 - 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); =20 out: =20 @@ -1732,7 +1713,7 @@ int wilc_cfg80211_init(struct wilc **wilc, struct dev= ice *dev, int io_type, wl->hif_func =3D ops; =20 for (i =3D 0; i < NQUEUES; i++) - INIT_LIST_HEAD(&wl->txq[i].txq_head.list); + skb_queue_head_init(&wl->txq[i]); =20 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/wi= reless/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); } =20 -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 =3D 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 =3D NULL; + struct wilc_vif *vif =3D netdev_priv(dev); + struct sk_buff *skb; =20 if (!dev) return -EFAULT; =20 netif_stop_queue(dev); - mgmt_tx =3D kmalloc(sizeof(*mgmt_tx), GFP_ATOMIC); - if (!mgmt_tx) - return -ENOMEM; - - mgmt_tx->buff =3D kmemdup(buf, len, GFP_ATOMIC); - if (!mgmt_tx->buff) { - kfree(mgmt_tx); + skb =3D wilc_wlan_alloc_skb(vif, len); + if (!skb) return -ENOMEM; - } - - mgmt_tx->size =3D len; + skb_put_data(skb, buf, len); =20 - 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); =20 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 486091a4cb993..999933532c2de 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); } =20 -static void wilc_tx_complete(void *priv, int status) -{ - struct tx_complete_data *pv_data =3D 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 =3D netdev_priv(ndev); struct wilc *wilc =3D vif->wilc; - struct tx_complete_data *tx_data =3D NULL; int queue_count; =20 if (skb->dev !=3D ndev) { @@ -738,22 +729,9 @@ netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct = net_device *ndev) return NETDEV_TX_OK; } =20 - tx_data =3D kmalloc(sizeof(*tx_data), GFP_ATOMIC); - if (!tx_data) { - dev_kfree_skb(skb); - netif_wake_queue(ndev); - return NETDEV_TX_OK; - } - - tx_data->buff =3D skb->data; - tx_data->size =3D skb->len; - tx_data->skb =3D skb; - vif->netstats.tx_packets++; - vif->netstats.tx_bytes +=3D tx_data->size; - queue_count =3D wilc_wlan_txq_add_net_pkt(ndev, tx_data, - tx_data->buff, tx_data->size, - wilc_tx_complete); + vif->netstats.tx_bytes +=3D skb->len; + queue_count =3D wilc_wlan_txq_add_net_pkt(ndev, skb); =20 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 60f4871a7d579..650b40961cf98 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; }; =20 struct tcp_ack_filter { @@ -246,15 +246,14 @@ struct wilc { =20 /* 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; =20 u8 *rx_buffer; u32 rx_buffer_offset; u8 *tx_buffer; =20 - struct txq_handle txq[NQUEUES]; + struct sk_buff_head txq[NQUEUES]; atomic_t txq_entries; struct txq_fw_recv_queue_stat fw[NQUEUES]; =20 diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index c352e939f1901..a970ddf43edf0 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -16,7 +16,7 @@ =20 static const u8 factors[NQUEUES] =3D {1, 1, 1, 1}; =20 -static void tcp_process(struct net_device *, struct txq_entry_t *); +static void tcp_process(struct net_device *, struct sk_buff *); =20 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); } =20 -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 =3D NULL; - unsigned long flags; - - spin_lock_irqsave(&wilc->txq_spinlock, flags); - - if (!list_empty(&wilc->txq[q_num].txq_head.list)) { - tqe =3D 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 =3D WILC_SKB_TX_CB(tqe); =20 - tqe->vif =3D vif; tx_cb->type =3D type; tx_cb->q_num =3D q_num; tx_cb->ack_idx =3D NOT_TCP_ACK; } =20 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 =3D netdev_priv(dev); struct wilc *wilc =3D vif->wilc; =20 @@ -86,34 +57,24 @@ static void wilc_wlan_txq_add_to_tail(struct net_device= *dev, u8 type, u8 q_num, if (type =3D=3D WILC_NET_PKT && vif->ack_filter.enabled) tcp_process(dev, tqe); =20 - 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); =20 wake_up_interruptible(&wilc->txq_event); } =20 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 =3D vif->wilc; =20 init_txq_entry(tqe, vif, type, q_num); =20 mutex_lock(&wilc->txq_add_to_head_cs); =20 - 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++; =20 - 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) =20 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 =3D WILC_SKB_TX_CB(txqe); struct tcp_ack_filter *f =3D &vif->ack_filter; @@ -158,9 +119,9 @@ static inline void add_tcp_pending_ack(struct wilc_vif = *vif, u32 ack, } } =20 -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 =3D tqe->buffer; + void *buffer =3D tqe->data; const struct ethhdr *eth_hdr_ptr =3D 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); } =20 -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 =3D tqe->vif; + struct wilc_vif *vif =3D netdev_priv(tqe->dev); struct wilc_skb_tx_cb *tx_cb =3D WILC_SKB_TX_CB(tqe); int ack_idx =3D tx_cb->ack_idx; =20 - tqe->status =3D status; - if (tqe->tx_complete_func) - tqe->tx_complete_func(tqe->priv, tqe->status); if (ack_idx !=3D NOT_TCP_ACK && ack_idx < MAX_PENDING_ACKS) vif->ack_filter.pending_acks[ack_idx].txqe =3D NULL; - kfree(tqe); + if (status) + dev_consume_skb_any(tqe); + else + dev_kfree_skb_any(tqe); } =20 -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 =3D tqe->vif; + struct wilc_vif *vif =3D netdev_priv(tqe->dev); struct wilc *wilc =3D vif->wilc; struct wilc_skb_tx_cb *tx_cb =3D WILC_SKB_TX_CB(tqe); =20 vif->ndev->stats.tx_dropped++; =20 - 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); } =20 @@ -261,7 +223,7 @@ static void wilc_wlan_txq_filter_dup_tcp_ack(struct net= _device *dev) bigger_ack_num =3D f->ack_session_info[index].bigger_ack_num; =20 if (f->pending_acks[i].ack_num < bigger_ack_num) { - struct txq_entry_t *tqe; + struct sk_buff *tqe; =20 tqe =3D 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 =3D value; } =20 -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 =3D vif->wilc; =20 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 =3D kmalloc(sizeof(*tqe), GFP_ATOMIC); - if (!tqe) { - complete(&wilc->cfg_event); + dev_kfree_skb_any(tqe); return 0; } =20 - tqe->buffer =3D buffer; - tqe->buffer_size =3D buffer_size; - tqe->tx_complete_func =3D NULL; - tqe->priv =3D NULL; - wilc_wlan_txq_add_to_head(vif, WILC_CFG_PKT, AC_VO_Q, tqe); =20 return 1; @@ -354,7 +303,7 @@ static bool is_ac_q_limit(struct wilc *wl, u8 q_num) else q_limit =3D (q->cnt[q_num] * FLOW_CONTROL_UPPER_THRESHOLD / q->sum) + 1; =20 - if (wl->txq[q_num].count <=3D q_limit) + if (skb_queue_len(&wl->txq[q_num]) <=3D q_limit) ret =3D true; =20 spin_unlock_irqrestore(&wl->txq_spinlock, flags); @@ -442,12 +391,8 @@ static inline u8 ac_change(struct wilc *wilc, u8 *ac) return 1; } =20 -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 =3D 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 =3D vif->wilc; =20 if (wilc->quit) { - tx_complete_fn(tx_data, 0); + dev_kfree_skb_any(tqe); return 0; } =20 if (!wilc->initialized) { - tx_complete_fn(tx_data, 0); + dev_kfree_skb_any(tqe); return 0; } =20 - tqe =3D kmalloc(sizeof(*tqe), GFP_ATOMIC); - - if (!tqe) { - tx_complete_fn(tx_data, 0); - return 0; - } - tqe->buffer =3D buffer; - tqe->buffer_size =3D buffer_size; - tqe->tx_complete_func =3D tx_complete_fn; - tqe->priv =3D tx_data; - - q_num =3D ac_classify(wilc, tx_data->skb); + q_num =3D 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; } =20 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); } =20 return atomic_read(&wilc->txq_entries); } =20 -int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buf= fer, - 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 =3D netdev_priv(dev); struct wilc *wilc; =20 wilc =3D vif->wilc; =20 if (wilc->quit) { - tx_complete_fn(priv, 0); + dev_kfree_skb_any(tqe); return 0; } =20 if (!wilc->initialized) { - tx_complete_fn(priv, 0); + dev_kfree_skb_any(tqe); return 0; } - tqe =3D kmalloc(sizeof(*tqe), GFP_ATOMIC); - - if (!tqe) { - tx_complete_fn(priv, 0); - return 0; - } - tqe->buffer =3D buffer; - tqe->buffer_size =3D buffer_size; - tqe->tx_complete_func =3D tx_complete_fn; - tqe->priv =3D priv; wilc_wlan_txq_add_to_tail(dev, WILC_MGMT_PKT, AC_VO_Q, tqe); return 1; } =20 -static struct txq_entry_t *wilc_wlan_txq_get_first(struct wilc *wilc, u8 q= _num) -{ - struct txq_entry_t *tqe =3D NULL; - unsigned long flags; - - spin_lock_irqsave(&wilc->txq_spinlock, flags); - - if (!list_empty(&wilc->txq[q_num].txq_head.list)) - tqe =3D 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 =3D list_next_entry(tqe, list); - else - tqe =3D 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_co= unt) u32 offset =3D 0; bool max_size_over =3D 0, ac_exist =3D 0; int vmm_sz =3D 0; - struct txq_entry_t *tqe_q[NQUEUES]; + struct sk_buff *tqe_q[NQUEUES]; struct wilc_skb_tx_cb *tx_cb; int ret =3D 0; int counter; @@ -758,7 +644,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_co= unt) srcu_read_unlock(&wilc->srcu, srcu_idx); =20 for (ac =3D 0; ac < NQUEUES; ac++) - tqe_q[ac] =3D wilc_wlan_txq_get_first(wilc, ac); + tqe_q[ac] =3D skb_peek(&wilc->txq[ac]); =20 i =3D 0; sum =3D 0; @@ -786,7 +672,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_co= unt) else vmm_sz =3D HOST_HDR_OFFSET; =20 - vmm_sz +=3D tqe_q[ac]->buffer_size; + vmm_sz +=3D tqe_q[ac]->len; vmm_sz =3D ALIGN(vmm_sz, 4); =20 if ((sum + vmm_sz) > WILC_TX_BUFF_SIZE) { @@ -802,9 +688,8 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_co= unt) =20 i++; sum +=3D vmm_sz; - tqe_q[ac] =3D wilc_wlan_txq_get_next(wilc, - tqe_q[ac], - ac); + tqe_q[ac] =3D skb_peek_next(tqe_q[ac], + &wilc->txq[ac]); } } num_pkts_to_add =3D ac_preserve_ratio; @@ -894,17 +779,18 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_= count) offset =3D 0; i =3D 0; do { - struct txq_entry_t *tqe; + struct sk_buff *tqe; u32 header, buffer_offset; char *bssid; u8 mgmt_ptk =3D 0; =20 - tqe =3D wilc_wlan_txq_remove_from_head(wilc, vmm_entries_ac[i]); + tqe =3D skb_dequeue(&wilc->txq[vmm_entries_ac[i]]); if (!tqe) break; =20 + atomic_dec(&wilc->txq_entries); ac_pkt_num_to_chip[vmm_entries_ac[i]]++; - vif =3D tqe->vif; + vif =3D netdev_priv(tqe->dev); tx_cb =3D WILC_SKB_TX_CB(tqe); if (vmm_table[i] =3D=3D 0) break; @@ -918,7 +804,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_co= unt) =20 header =3D (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)); =20 cpu_to_le32s(&header); @@ -928,7 +814,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_co= unt) } else if (tx_cb->type =3D=3D WILC_NET_PKT) { int prio =3D tx_cb->q_num; =20 - bssid =3D tqe->vif->bssid; + bssid =3D vif->bssid; buffer_offset =3D 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_co= unt) buffer_offset =3D HOST_HDR_OFFSET; } =20 - memcpy(&txb[offset + buffer_offset], - tqe->buffer, tqe->buffer_size); + memcpy(&txb[offset + buffer_offset], tqe->data, tqe->len); offset +=3D 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) =20 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 =3D netdev_priv(dev); @@ -1259,9 +1144,15 @@ void wilc_wlan_cleanup(struct net_device *dev) =20 wilc->quit =3D 1; for (ac =3D 0; ac < NQUEUES; ac++) { - while ((tqe =3D wilc_wlan_txq_remove_from_head(wilc, ac))) + while ((tqe =3D skb_dequeue(&wilc->txq[ac]))) wilc_wlan_tx_packet_done(tqe, 0); } + atomic_set(&wilc->txq_entries, 0); + cfg_skb =3D wilc->cfg_skb; + if (cfg_skb) { + wilc->cfg_skb =3D NULL; + dev_kfree_skb_any(cfg_skb); + } =20 while ((rqe =3D wilc_wlan_rxq_remove(wilc))) kfree(rqe); @@ -1273,21 +1164,52 @@ void wilc_wlan_cleanup(struct net_device *dev) wilc->hif_func->hif_deinit(wilc); } =20 +struct sk_buff *wilc_wlan_alloc_skb(struct wilc_vif *vif, size_t len) +{ + size_t size, headroom; + struct sk_buff *skb; + + headroom =3D vif->ndev->needed_headroom; + size =3D headroom + len + vif->ndev->needed_tailroom; + skb =3D 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 =3D 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 =3D vif->wilc; - struct wilc_cfg_frame *cfg =3D &wilc->cfg_frame; - int t_len =3D wilc->cfg_frame_offset + sizeof(struct wilc_cfg_cmd_hdr); struct wilc_cfg_cmd_hdr *hdr; + struct sk_buff *cfg_skb =3D wilc->cfg_skb; =20 - hdr =3D &cfg->hdr; + hdr =3D skb_push(cfg_skb, sizeof(*hdr)); hdr->cmd_type =3D (type =3D=3D WILC_CFG_SET) ? 'W' : 'Q'; hdr->seq_no =3D wilc->cfg_seq_no; - hdr->total_len =3D cpu_to_le16(t_len); + hdr->total_len =3D cpu_to_le16(cfg_skb->len); hdr->driver_handler =3D 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 =3D NULL; =20 - 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; =20 return 0; @@ -1316,24 +1238,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 =3D vif->wilc; =20 mutex_lock(&wilc->cfg_cmd_lock); =20 - if (start) - wilc->cfg_frame_offset =3D 0; + if (start) { + WARN_ON(wilc->cfg_skb); + wilc->cfg_skb =3D 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; + } + } =20 - offset =3D wilc->cfg_frame_offset; if (set) - ret_size =3D wilc_wlan_cfg_set_wid(wilc->cfg_frame.frame, offset, + ret_size =3D wilc_wlan_cfg_set_wid(skb_tail_pointer(wilc->cfg_skb), 0, wid, buffer, buffer_size); else - ret_size =3D wilc_wlan_cfg_get_wid(wilc->cfg_frame.frame, offset, - wid); - offset +=3D ret_size; - wilc->cfg_frame_offset =3D offset; + ret_size =3D wilc_wlan_cfg_get_wid(skb_tail_pointer(wilc->cfg_skb), 0, w= id); + if (ret_size =3D=3D 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); =20 if (!commit) { mutex_unlock(&wilc->cfg_cmd_lock); @@ -1353,7 +1283,6 @@ static int wilc_wlan_cfg_apply_wid(struct wilc_vif *v= if, int start, u16 wid, ret_size =3D 0; } =20 - wilc->cfg_frame_offset =3D 0; wilc->cfg_seq_no =3D (wilc->cfg_seq_no + 1) % 256; mutex_unlock(&wilc->cfg_cmd_lock); =20 diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/w= ireless/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 =3D 3 }; =20 -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 */ }; =20 -#define wilc_skb_tx_cb txq_entry_t - -static inline struct wilc_skb_tx_cb *WILC_SKB_TX_CB(struct txq_entry_t *tq= e) +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]; } =20 struct txq_fw_recv_queue_stat { @@ -345,11 +340,6 @@ struct txq_fw_recv_queue_stat { u8 count; }; =20 -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 { =20 #define WILC_MAX_CFG_FRAME_SIZE 1468 =20 -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; }; =20 -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, co= nst 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 *buf= fer, - 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); --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 96550C433FE for ; Thu, 23 Dec 2021 01:14:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345962AbhLWBOV (ORCPT ); Wed, 22 Dec 2021 20:14:21 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18250 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345653AbhLWBOM (ORCPT ); Wed, 22 Dec 2021 20:14:12 -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=eTCBwwd712xb7qk5FJKt9s2SPN4iZ3evhxEvhrmqVG0=; b=qFAobek2GlJ0Bkyz99qu4u/sbAGwfA94iQP2eQnx6F0l3ZQqMGl3V9ATyVBFo5tka1ys VDLmw83n7hy/5Lcij+pLHuzMeMVrRa9bEMmsIgMz80r/r5NOAyfO9T7AXoruljLkCQEioR sJ7zyntVMAYNMTtus9Vil6m9tF7Ke9sEHpFmRm66WRyGArWbXZP+9OCn1P9kMTifTBhSX/ 06ScxdAJPbPv5adpoAxV6AzGPSj/eTH1Rsuij9VLmJsdgZB7sBUp7UdoC9Yqf8X8k0z1aK ePO/7TH5YcNLE/q/Zl+/h8mhvNEYUu8dH0CUJgiLYALRYVFWlh/BtYsO1CHcVOuw== Received: by filterdrecv-64fcb979b9-tjknx with SMTP id filterdrecv-64fcb979b9-tjknx-1-61C3CD5E-1D 2021-12-23 01:14:06.570345309 +0000 UTC m=+8644589.373863885 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-4-0 (SG) with ESMTP id Ix1XkgGqSFi8py498O2p_g Thu, 23 Dec 2021 01:14:06.429 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 2F9327012D2; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 17/50] wilc1000: remove no longer used "vif" argument from init_txq_entry() Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-18-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvF57zItUWDc68Njwz?= =?us-ascii?Q?om2zBXkmJEYQhgSnJ3Qik1UqW8tfJqfcvcHJvYK?= =?us-ascii?Q?bKbeuYAkOQbStMz=2Fkx2DZvHrec6MDTTz5xXPfG8?= =?us-ascii?Q?JMYkxg94lV=2F7wru+GdmuHXIy5labSLRIWr2UB9J?= =?us-ascii?Q?aGSoSJwFAnKhMCwFNqmU3hRGjF1JPmfKH6nB6AD?= =?us-ascii?Q?H3Na7tbQb4hW68OgZEn5A=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/w= ireless/microchip/wilc1000/wlan.c index a970ddf43edf0..8bff1d8050b11 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 bu= s_release release) mutex_unlock(&wilc->hif_cs); } =20 -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 =3D 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 =3D netdev_priv(dev); struct wilc *wilc =3D vif->wilc; =20 - init_txq_entry(tqe, vif, type, q_num); + init_txq_entry(tqe, type, q_num); if (type =3D=3D WILC_NET_PKT && vif->ack_filter.enabled) tcp_process(dev, tqe); =20 @@ -68,7 +68,7 @@ static void wilc_wlan_txq_add_to_head(struct wilc_vif *vi= f, u8 type, u8 q_num, { struct wilc *wilc =3D vif->wilc; =20 - init_txq_entry(tqe, vif, type, q_num); + init_txq_entry(tqe, type, q_num); =20 mutex_lock(&wilc->txq_add_to_head_cs); =20 --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 3B443C433EF for ; Thu, 23 Dec 2021 01:14:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346064AbhLWBO2 (ORCPT ); Wed, 22 Dec 2021 20:14:28 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18296 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345736AbhLWBOO (ORCPT ); Wed, 22 Dec 2021 20:14:14 -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=vZhKpwkeABx3tV5464sBNHKmLdYJetnkUWgiwVq0e+M=; b=gSMXBJmGkyQjVJdOl21pxvi7KtiMRQGaum/3+DtPG8VdaTSmBRxB4u3bBD7ONHGsUDdK D0MqI+fKkvqCGZ0KHlGCdQQonTTGWBE7YsoGen4n0GYppz/JWQHCeREwd1RIbu0qlErWjN ypjuBG9V/G9aryFUlOHjy2WMfEHzg/J9O8ujPsHg0BmjUdte6fOsFRnatK6Zw3FB6TGiHx 2RQ3xIje6YFOxwdPVeOIwXttEYRjhOp/k8oBfADCM8/blRARaa21IXPZD1Do5cYZr1yDQu a619dWd5snsWW7nh4HRrmytA0L5Z7xKw0Pa/5zrPUeSF7C73Iqlmr2+QWm4NiCFg== Received: by filterdrecv-64fcb979b9-stcmh with SMTP id filterdrecv-64fcb979b9-stcmh-1-61C3CD5E-19 2021-12-23 01:14:06.641297648 +0000 UTC m=+8644585.985703208 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-5-0 (SG) with ESMTP id kYQx10e9SJ-POfpDVVT99Q Thu, 23 Dec 2021 01:14:06.439 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 36E4A701321; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 18/50] wilc1000: split huge tx handler into subfunctions Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-19-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvN=2FgGHiwjRLSHlTP9?= =?us-ascii?Q?0xv=2FCkD5McJdotNU1IWUaiA5rlUOQzfOXej2buH?= =?us-ascii?Q?57ZdJ8RFuS2M85fKVNxTd4qP8KXY0N=2FT0=2FP78DO?= =?us-ascii?Q?qmzFZNjnH2fG9IE1nN3UZp0MFvPK3JiFrLyRDqH?= =?us-ascii?Q?b9VqjPwFDmiogKa5NJjAl11092aCtDzof6uqKHv?= =?us-ascii?Q?y6uqz9SSratHx6DExmuxQ=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 | 206 +++++++++++++----- 1 file changed, 157 insertions(+), 49 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index 8bff1d8050b11..54dfb2b9f3524 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -605,43 +605,43 @@ void host_sleep_notify(struct wilc *wilc) } EXPORT_SYMBOL_GPL(host_sleep_notify); =20 -int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) +/** + * fill_vmm_table() - Fill VMM table with packets to be sent + * @wilc: Pointer to the wilc structure. + * @ac_desired_ratio: First-round limit on number of packets to add from t= he + * 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. + * + * Fill VMM table with packets waiting to be sent. The packets are + * added based on access category (priority) but also balanced to + * provide fairness. + * + * Context: Since this function peeks at the packet queues, the + * txq_add_to_head_cs mutex must be acquired before calling this + * function. + * + * 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 =3D 0; + int i; u8 k, ac; u32 sum; - u32 reg; - u8 ac_desired_ratio[NQUEUES] =3D {0, 0, 0, 0}; u8 ac_preserve_ratio[NQUEUES] =3D {1, 1, 1, 1}; u8 *num_pkts_to_add; - u8 vmm_entries_ac[WILC_VMM_TBL_SIZE]; - u32 offset =3D 0; bool max_size_over =3D 0, ac_exist =3D 0; int vmm_sz =3D 0; struct sk_buff *tqe_q[NQUEUES]; struct wilc_skb_tx_cb *tx_cb; - int ret =3D 0; - int counter; - int timeout; - u32 vmm_table[WILC_VMM_TBL_SIZE]; - u8 ac_pkt_num_to_chip[NQUEUES] =3D {0, 0, 0, 0}; - const struct wilc_hif_func *func; - int srcu_idx; - u8 *txb =3D 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 =3D 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); =20 for (ac =3D 0; ac < NQUEUES; ac++) tqe_q[ac] =3D skb_peek(&wilc->txq[ac]); @@ -695,11 +695,31 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_= count) num_pkts_to_add =3D ac_preserve_ratio; } while (!max_size_over && ac_exist); =20 - if (i =3D=3D 0) - goto out_unlock; vmm_table[i] =3D 0x0; + return i; +} + +/** + * send_vmm_table() - Send the VMM table to the chip + * @wilc: Pointer to the wilc structure. + * @i: The number of entries in the VMM table. + * @vmm_table: The VMM table to send. + * + * Send the VMM table to the chip and get back the number of entries + * that the chip can accept. + * + * Context: The bus must have been acquired before calling this + * function. + * + * 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; =20 - acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); counter =3D 0; func =3D wilc->hif_func; do { @@ -721,7 +741,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_co= unt) } while (!wilc->quit); =20 if (ret) - goto out_release_bus; + return ret; =20 timeout =3D 200; do { @@ -759,22 +779,38 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_= count) break; reg &=3D ~BIT(0); ret =3D func->hif_write_reg(wilc, WILC_HOST_TX_CTRL, reg); + } else { + ret =3D entries; } } while (0); + return ret; +} =20 - if (ret) - goto out_release_bus; - - if (entries =3D=3D 0) { - /* - * No VMM space available in firmware so retry to transmit - * the packet from tx queue. - */ - ret =3D WILC_VMM_ENTRY_FULL_RETRY; - goto out_release_bus; - } - - release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); +/** + * copy_packets() - Copy packets to the transmit buffer + * @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. + * + * Copy a set of packets to the transmit buffer. + * + * Context: The txq_add_to_head_cs mutex must still be held when + * calling this function. + * + * 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] =3D {0, 0, 0, 0}; + struct wilc_skb_tx_cb *tx_cb; + u8 *txb =3D wilc->tx_buffer; + struct wilc_vif *vif; + int i, vmm_sz; + u32 offset; =20 offset =3D 0; i =3D 0; @@ -829,16 +865,88 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_= count) } while (--entries); for (i =3D 0; i < NQUEUES; i++) wilc->fw[i].count +=3D ac_pkt_num_to_chip[i]; + return offset; +} =20 - acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); +/** + * send_packets() - Send packets to the chip + * @wilc: Pointer to the wilc structure. + * @len: The length of the buffer containing the packets to be sent to + * the chip. + * + * Send the packets in the VMM table to the chip. + * + * Context: The bus must have been acquired. + * + * Return: + * Negative number on error, 0 on success. + */ +static int send_packets(struct wilc *wilc, int len) +{ + const struct wilc_hif_func *func =3D wilc->hif_func; + int ret; + u8 *txb =3D wilc->tx_buffer; =20 ret =3D func->hif_clear_int_ext(wilc, ENABLE_TX_VMM); if (ret) - goto out_release_bus; + return ret; + + return func->hif_block_tx_ext(wilc, 0, txb, len); +} + +int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) +{ + int i, entries, len; + u8 ac_desired_ratio[NQUEUES] =3D {0, 0, 0, 0}; + u8 vmm_entries_ac[WILC_VMM_TBL_SIZE]; + int ret =3D 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 =3D 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); + + i =3D fill_vmm_table(wilc, ac_desired_ratio, vmm_table, vmm_entries_ac); + if (i =3D=3D 0) + goto out_unlock; + + acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); + + ret =3D send_vmm_table(wilc, i, vmm_table); + + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); + + if (ret < 0) + goto out_unlock; + + entries =3D ret; + if (entries =3D=3D 0) { + /* No VMM space available in firmware. Inform caller + * to retry later. + */ + ret =3D WILC_VMM_ENTRY_FULL_RETRY; + goto out_unlock; + } + + len =3D copy_packets(wilc, entries, vmm_table, vmm_entries_ac); + if (len <=3D 0) + goto out_unlock; + + acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); =20 - ret =3D func->hif_block_tx_ext(wilc, 0, txb, offset); + ret =3D send_packets(wilc, len); =20 -out_release_bus: release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); =20 out_unlock: --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 B1637C433FE for ; Thu, 23 Dec 2021 01:15:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346622AbhLWBPl (ORCPT ); Wed, 22 Dec 2021 20:15:41 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18408 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345804AbhLWBOT (ORCPT ); Wed, 22 Dec 2021 20:14: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=9GhperGdLp5mSs2oGPGWX3vVh6QZlgVmNWU2J8h4eJY=; b=LDUXjoktAgidrqd0DknbCqj+Cq40xD+T0dA+omHvM5a/4tAsOr8lu85ZnBVyl117D4T1 FF/7RavN0zfbhSOk65PFCRePblFoKBm7YovjdXl36Irqi5OE0cZerC77CMMg778yvMHGOA 4LQvwb8c/Sa5XuP3gfzg0bWBOzGIC4GeFNSiViaBFUloEd1urrYLDtOBRa8VKL3ZJjDrPe HBXWnwHuUWJxbf9WKQZS2ZbRYEtdF9hZLmGCSMNC9oNE7TvGuLp41zLzEMZkmjB3UaN17Q vAIQJ6EZkyay17ZVb9Lr0l2llKMvaffc9QCNvyD8Ah15pv21Nq8rtulondgJF2Nw== Received: by filterdrecv-656998cfdd-vtnvg with SMTP id filterdrecv-656998cfdd-vtnvg-1-61C3CD5E-1E 2021-12-23 01:14:06.716473164 +0000 UTC m=+7955207.766253174 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-4-0 (SG) with ESMTP id FZOMOdXcTZSqSpHTHFO7eA Thu, 23 Dec 2021 01:14:06.545 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 3DED070133A; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 19/50] wilc1000: don't tell the chip to go to sleep while copying tx packets Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-20-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvP9gs2xqRpyIBtGYR?= =?us-ascii?Q?lDavY3uO9Y96GusEhphEvR8U2Or9IV1GN9AtCEU?= =?us-ascii?Q?roMXcil4bWWz0vBANOAMeohSevp9gTXHIlh=2FsAZ?= =?us-ascii?Q?HYRVNVZ3n3hCHJMS90SmO+hpy2xJZq83MKSAfKR?= =?us-ascii?Q?IqAqJvS4eEsTYn7qepezzG8CAjdYWSy29ZEVttH?= =?us-ascii?Q?JN6DhPfjEayTq+mO87S9A=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/w= ireless/microchip/wilc1000/wlan.c index 54dfb2b9f3524..a6064a85140b4 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -924,29 +924,27 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_= count) acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); =20 ret =3D send_vmm_table(wilc, i, vmm_table); + if (ret <=3D 0) { + if (ret =3D=3D 0) + /* No VMM space available in firmware. Inform + * caller to retry later. + */ + ret =3D WILC_VMM_ENTRY_FULL_RETRY; + goto out_release_bus; + } =20 - release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); - - if (ret < 0) - goto out_unlock; + release_bus(wilc, WILC_BUS_RELEASE_ONLY); =20 entries =3D ret; - if (entries =3D=3D 0) { - /* No VMM space available in firmware. Inform caller - * to retry later. - */ - ret =3D WILC_VMM_ENTRY_FULL_RETRY; - goto out_unlock; - } - len =3D copy_packets(wilc, entries, vmm_table, vmm_entries_ac); if (len <=3D 0) goto out_unlock; =20 - acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); + acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); =20 ret =3D send_packets(wilc, len); =20 +out_release_bus: release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); =20 out_unlock: --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 46BAAC433FE for ; Thu, 23 Dec 2021 01:14:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345987AbhLWBOX (ORCPT ); Wed, 22 Dec 2021 20:14:23 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18254 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345686AbhLWBOM (ORCPT ); Wed, 22 Dec 2021 20:14:12 -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=8dwPvDwhfyU5dMZPpdOsVTnb3/1u+mRXqp7YaVTNdGU=; b=R3yiLGLs1uZQGXBA5TY6+EOguEXdgO+NFMS9YERcdysDiQ74J09QGW0gtwwaBTwIb3lP 14/s3VZ0MrU9V1Esh6nxwkFlnkeAu3oeTqnb0+GCprOZ2Df8Hl+HIRdfh93KlGnbickV4r 1rZLqvK+Ryd+uNTMUH0qyT4sXyAUeny5SIYKZWoBM3zVFvoDr62sOI5L3QZ6OSDyNDTNii +jSXr56RBOU3/8NPVBHcv6KWTgdql3C6HQ5pKMM1C2a9ZhBW0ayYJ4xgu3ka1nT/lNMthz wryFmVZf8EqOks5TDp/IJXqehiHzMHQEUeON2RlHmpY5/db5fYfDIguaWdaah8tw== Received: by filterdrecv-656998cfdd-mht2v with SMTP id filterdrecv-656998cfdd-mht2v-1-61C3CD5E-18 2021-12-23 01:14:06.608787935 +0000 UTC m=+7955208.093419968 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-5-1 (SG) with ESMTP id vPbHODG4Sse8dQwPEkefYg Thu, 23 Dec 2021 01:14:06.453 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 443A8701397; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 20/50] wilc1000: eliminate "max_size_over" variable in fill_vmm_table Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-21-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvBovVGGUqsKDfRdCL?= =?us-ascii?Q?g1PJA3t8foKn9E0eDBioSfxjXTPS=2FqEtvMwuU7e?= =?us-ascii?Q?ykaxv403jcXR8Nu5mfoqIItxiNmkjMWXiv0cB4g?= =?us-ascii?Q?Hy6NAKDpjbx12H5snr+QqKlSDu9RMHVYMiOTHzz?= =?us-ascii?Q?lOvs2evMJZh66jnXmNW86Gk9zygPRo6NhJ=2FSaBN?= =?us-ascii?Q?dN99o2AC2tKuMeAcZdotw=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/w= ireless/microchip/wilc1000/wlan.c index a6064a85140b4..dc6608390591c 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -638,7 +638,7 @@ static int fill_vmm_table(const struct wilc *wilc, u32 sum; u8 ac_preserve_ratio[NQUEUES] =3D {1, 1, 1, 1}; u8 *num_pkts_to_add; - bool max_size_over =3D 0, ac_exist =3D 0; + bool ac_exist =3D 0; int vmm_sz =3D 0; struct sk_buff *tqe_q[NQUEUES]; struct wilc_skb_tx_cb *tx_cb; @@ -648,20 +648,17 @@ static int fill_vmm_table(const struct wilc *wilc, =20 i =3D 0; sum =3D 0; - max_size_over =3D 0; num_pkts_to_add =3D ac_desired_ratio; do { ac_exist =3D 0; - for (ac =3D 0; (ac < NQUEUES) && (!max_size_over); ac++) { + for (ac =3D 0; ac < NQUEUES; ac++) { if (!tqe_q[ac]) continue; =20 ac_exist =3D 1; - for (k =3D 0; (k < num_pkts_to_add[ac]) && - (!max_size_over) && tqe_q[ac]; k++) { + for (k =3D 0; (k < num_pkts_to_add[ac]) && tqe_q[ac]; k++) { if (i >=3D (WILC_VMM_TBL_SIZE - 1)) { - max_size_over =3D 1; - break; + goto out; } =20 tx_cb =3D WILC_SKB_TX_CB(tqe_q[ac]); @@ -676,8 +673,7 @@ static int fill_vmm_table(const struct wilc *wilc, vmm_sz =3D ALIGN(vmm_sz, 4); =20 if ((sum + vmm_sz) > WILC_TX_BUFF_SIZE) { - max_size_over =3D 1; - break; + goto out; } vmm_table[i] =3D vmm_sz / 4; if (tx_cb->type =3D=3D WILC_CFG_PKT) @@ -693,8 +689,8 @@ static int fill_vmm_table(const struct wilc *wilc, } } num_pkts_to_add =3D ac_preserve_ratio; - } while (!max_size_over && ac_exist); - + } while (ac_exist); +out: vmm_table[i] =3D 0x0; return i; } --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 7BE1FC433EF for ; Thu, 23 Dec 2021 01:17:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347031AbhLWBRP (ORCPT ); Wed, 22 Dec 2021 20:17:15 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18274 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345775AbhLWBOT (ORCPT ); Wed, 22 Dec 2021 20:14: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=6QXkOacECeXoh5s5NBM40R3qV30Md7UBrpN7t6KOPGo=; b=jEsfdGGUqZlOHJ+qiIdYcdiGc8y5cjxsk0E8S4tSYvGbZuBtCtw94/79qfawzR2qfIY0 wpWdYTloK4wUIeW/etD4crH6ouhIR31tqxcM4v+fPpuwNlWiM7+rgXw8NoyFdFBqHPGHhQ xJWxMK7H+5EME/K7ltURYiCX5Eeblq/Ce+21KPeVlycQrQjGiqU6dY7kxiXI1woA1jcEVv nQTaXg0StAaZkcYRq299C8ioYioItUJowXKvNNsNFLLIpTU/Po6UU5Cy4gEqmaaMpMmCAl a53p0GErHe8lV7d8n1E0iIfD7icUZodNdoDyoq96HNJpn9heDL/xlnkVsxXVCLAg== Received: by filterdrecv-75ff7b5ffb-96rhp with SMTP id filterdrecv-75ff7b5ffb-96rhp-1-61C3CD5E-1D 2021-12-23 01:14:06.586363998 +0000 UTC m=+9687226.466870642 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-1-1 (SG) with ESMTP id LDXSjrTJS9u9LcGCsLIr-w Thu, 23 Dec 2021 01:14:06.471 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 4AE897013D2; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 21/50] wilc1000: declare read-only ac_preserve_ratio as static and const Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-22-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvLZxHI1WTv+apMggT?= =?us-ascii?Q?xpW6dVO07dWMAWJoY1Bu46DX+LwUkE7cVHmQvQr?= =?us-ascii?Q?gtXMbB8mrMynCaXw8lkkNDKys91eMLB9gl=2FSPG7?= =?us-ascii?Q?JHQYkeOAYEuC895TxDiKXYMD1IfY4eXq+o5n5jB?= =?us-ascii?Q?96ToPek62EKvQPFSFau1kmZ3PSa4m9lm+AQ6avw?= =?us-ascii?Q?PWtm0kpCKtgoZJ5OBCWtQ=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/w= ireless/microchip/wilc1000/wlan.c index dc6608390591c..bdc31a4fd0f6a 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -636,8 +636,8 @@ static int fill_vmm_table(const struct wilc *wilc, int i; u8 k, ac; u32 sum; - u8 ac_preserve_ratio[NQUEUES] =3D {1, 1, 1, 1}; - u8 *num_pkts_to_add; + static const u8 ac_preserve_ratio[NQUEUES] =3D {1, 1, 1, 1}; + const u8 *num_pkts_to_add; bool ac_exist =3D 0; int vmm_sz =3D 0; struct sk_buff *tqe_q[NQUEUES]; --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 B56C2C433EF for ; Thu, 23 Dec 2021 01:15:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346521AbhLWBP2 (ORCPT ); Wed, 22 Dec 2021 20:15:28 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18246 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345661AbhLWBOM (ORCPT ); Wed, 22 Dec 2021 20:14:12 -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=+rDeixZ7MJSx6InnY+u1z6fli4Hj5k1B4JVFs6766eU=; b=fehs5hthNSvBBSTyskZKbAzPyTqgZjqfQ/jS+p9Ph4LoWr/V/zHU5EePqlvAGEQBmxHj NU4/6nmxnMVjlDgS1u6IRFAnhWi+tkZfQlvsRWH9VPbyroPrdzNs2cSEwyuQKoDsRP1lGZ 3Cx2JYQkRNC66xLxS4RCoNUtZV6O7MiwR8PgZq3LB7D+AKYaPUEvrUBIpkO0ELJtwkCQmY DedxsmJ8y+lyKSxsN3RYiBjR06zZJW1fuF6rtVbYX4zgSIKsuvln2AXdyBuTYvhZIt0hEB CRYANGPpn/JkKubcMqZo5M5B/0zsky6xkHqZeTErrhSYDlQoLAYHM+C8wHhdNvEw== Received: by filterdrecv-656998cfdd-ptr8m with SMTP id filterdrecv-656998cfdd-ptr8m-1-61C3CD5E-32 2021-12-23 01:14:06.611838373 +0000 UTC m=+7955208.471421114 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-5-0 (SG) with ESMTP id 0znaJCznRG-yQLmOzbTajw Thu, 23 Dec 2021 01:14:06.470 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 5122870144A; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 22/50] wilc1000: minor syntax cleanup Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-23-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvJKfYCcYkBmI5xpqF?= =?us-ascii?Q?oSD34tNpJNDAhFw+fPQk430jNmTlt1liYNUH15c?= =?us-ascii?Q?CnQ=2Ffa6zQty9oXEWTbqAz5=2F=2FJ0EIGQ6WNVNmfWA?= =?us-ascii?Q?b09KZG8w4boRb+EUzAUuYjhA+v4ucJmwKXay+Yc?= =?us-ascii?Q?JhmuZkF99=2FqBbl1PRDZj9majoyyAwbIs8c54vS=2F?= =?us-ascii?Q?Xznwx7xb229XG4EOSaZ6Q=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/w= ireless/microchip/wilc1000/wlan.c index bdc31a4fd0f6a..27b1d317dc0c4 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -656,10 +656,9 @@ static int fill_vmm_table(const struct wilc *wilc, continue; =20 ac_exist =3D 1; - for (k =3D 0; (k < num_pkts_to_add[ac]) && tqe_q[ac]; k++) { - if (i >=3D (WILC_VMM_TBL_SIZE - 1)) { + for (k =3D 0; k < num_pkts_to_add[ac] && tqe_q[ac]; k++) { + if (i >=3D WILC_VMM_TBL_SIZE - 1) goto out; - } =20 tx_cb =3D WILC_SKB_TX_CB(tqe_q[ac]); if (tx_cb->type =3D=3D WILC_CFG_PKT) @@ -672,9 +671,8 @@ static int fill_vmm_table(const struct wilc *wilc, vmm_sz +=3D tqe_q[ac]->len; vmm_sz =3D ALIGN(vmm_sz, 4); =20 - if ((sum + vmm_sz) > WILC_TX_BUFF_SIZE) { + if (sum + vmm_sz > WILC_TX_BUFF_SIZE) goto out; - } vmm_table[i] =3D vmm_sz / 4; if (tx_cb->type =3D=3D WILC_CFG_PKT) vmm_table[i] |=3D BIT(10); @@ -741,10 +739,8 @@ static int send_vmm_table(struct wilc *wilc, int i, co= nst u32 *vmm_table) =20 timeout =3D 200; do { - ret =3D func->hif_block_tx(wilc, - WILC_VMM_TBL_RX_SHADOW_BASE, - (u8 *)vmm_table, - ((i + 1) * 4)); + ret =3D func->hif_block_tx(wilc, WILC_VMM_TBL_RX_SHADOW_BASE, + (u8 *)vmm_table, (i + 1) * 4); if (ret) break; =20 --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 89295C433F5 for ; Thu, 23 Dec 2021 01:15:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345735AbhLWBPi (ORCPT ); Wed, 22 Dec 2021 20:15:38 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18258 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345762AbhLWBOS (ORCPT ); Wed, 22 Dec 2021 20:14: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=P3vjFpDJHEWW7SWSpRLhpleR6qDxnZjgnmLnPz6G8BU=; b=snT890lOOe4TeW91I9cPz+4/ladedXzhvy20QFJaibRKlF6/txys+ynk2ZZrS/wIUfEJ oR2Z/TvDaVsvnrbuTeo/UCtZHDbWagzLAKSzX3V9G1gfhO7+Od6/BeUhjFO15UOxxVPrde oVWhUj5x3NqAn+oy3zK8yWeHgKqAlKgYlxgFNOGj9HAEr3be+oi20Pk7gr5tvhqaLQmQ8b z12UO4XVxiGoXNlf21CQGz2SVAhvQRkLf7vPEsg1Hll401WCLoEUlya/aAW/T7rrhKlNy+ 9bjKkH/uyBQJQX0nf0fXRMBR53pT2F5qmF+yCWdRrqwKcrufDd/OQCURTMH9ASdA== Received: by filterdrecv-7bf5c69d5-5zdgz with SMTP id filterdrecv-7bf5c69d5-5zdgz-1-61C3CD5E-30 2021-12-23 01:14:06.61160249 +0000 UTC m=+9687225.820325608 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-2-0 (SG) with ESMTP id 0V7qflYNS7iEC4FxhBJa7g Thu, 23 Dec 2021 01:14:06.475 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 5813070144B; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 23/50] wilc1000: introduce symbolic names for two tx-related control bits Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-24-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvJD+x2smqDgMhvITP?= =?us-ascii?Q?dFZ8LpvZ4l0gufVGuiwD1p5mR9rphOFgG4bG=2F4z?= =?us-ascii?Q?=2F+tkUCDTCYhl0x1an9kXtm6YdZV+BObrdiRZ7AL?= =?us-ascii?Q?GB9WgQhPPaebE8LxtUAW1rUmWQBzBBorbkoYrMl?= =?us-ascii?Q?zrh01n2ixD4irlYxG2N=2FcKhanhCeDXjY3xzUZta?= =?us-ascii?Q?Rlty27veFNLEyjMzbzJcQ=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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/w= ireless/microchip/wilc1000/wlan.c index 27b1d317dc0c4..f82857cebe35e 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -675,7 +675,7 @@ static int fill_vmm_table(const struct wilc *wilc, goto out; vmm_table[i] =3D vmm_sz / 4; if (tx_cb->type =3D=3D WILC_CFG_PKT) - vmm_table[i] |=3D BIT(10); + vmm_table[i] |=3D WILC_VMM_CFG_PKT; =20 cpu_to_le32s(&vmm_table[i]); vmm_entries_ac[i] =3D ac; @@ -721,7 +721,7 @@ static int send_vmm_table(struct wilc *wilc, int i, con= st u32 *vmm_table) if (ret) break; =20 - if ((reg & 0x1) =3D=3D 0) { + if ((reg & WILC_HOST_TX_CTRL_BUSY) =3D=3D 0) { ac_update_fw_ac_pkt_info(wilc, reg); break; } @@ -769,7 +769,7 @@ static int send_vmm_table(struct wilc *wilc, int i, con= st u32 *vmm_table) ret =3D func->hif_read_reg(wilc, WILC_HOST_TX_CTRL, ®); if (ret) break; - reg &=3D ~BIT(0); + reg &=3D ~WILC_HOST_TX_CTRL_BUSY; ret =3D func->hif_write_reg(wilc, WILC_HOST_TX_CTRL, reg); } else { ret =3D entries; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/w= ireless/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) =20 #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) =20 #define WILC_VMM_BUFFER_SIZE GENMASK(9, 0) +#define WILC_VMM_CFG_PKT BIT(10) =20 #define WILC_VMM_HDR_TYPE BIT(31) #define WILC_VMM_HDR_MGMT_FIELD BIT(30) --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 38DFBC433EF for ; Thu, 23 Dec 2021 01:15:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346060AbhLWBPc (ORCPT ); Wed, 22 Dec 2021 20:15:32 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18362 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345765AbhLWBOR (ORCPT ); Wed, 22 Dec 2021 20:14: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=N46QLJgAXe0NvBlcbTaWBwYjHo/Ap7DZmE5k7VZ+W3Q=; b=V64BEDRL3vBXJzMTbzc6Zw5w8bWHXW3QPOVeOZ1rCzoRRF5U/xrJZjkvJjjXUQ7GDUwZ e6kbIZjO2AEwZ8IjpQvQpfmRV5rm1PjiVRPfdK1CfW+0+lUzDd6+BopDXAirnUjQSDqAFG WKyqC7NfeyCabd0oKi1XRghEK2xDCQSlcYASMbOQ5mi26CwrNWIbF7bNEU5V8wVbYjWmuQ UoeXghe8Lg0Ilm7l7rm/Phy7C6iZLXpUGlKNNZskttfZU7y9p77HDE3ycVuHfidwB47hI3 c2Of3FNGpUFcMSTvKB9VkpaIBW6NS/RPkV1m5+xCleUER4JiobS/wif3jg6cpLmA== Received: by filterdrecv-64fcb979b9-st7n5 with SMTP id filterdrecv-64fcb979b9-st7n5-1-61C3CD5E-31 2021-12-23 01:14:06.632823617 +0000 UTC m=+8644640.616410629 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-6-1 (SG) with ESMTP id __87Da3hTAGNaPsJHueHmQ Thu, 23 Dec 2021 01:14:06.464 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 5E49F701456; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 24/50] wilc1000: protect tx_q_limit with a mutex instead of a spinlock Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-25-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvGBcp4s2Az1AHv79A?= =?us-ascii?Q?BU3BFGyn+E9LPexzA58AtugPyGPRXwwtc3DKSoO?= =?us-ascii?Q?sBtpfgdGlcAixxwv=2FfgakudCQuG61w7zhL9rZ1s?= =?us-ascii?Q?+gqX7WUeL1cv24d7q7zDLz1UBI+gEqnsVb03SmH?= =?us-ascii?Q?xpTA9Ti3=2F4PECDSjnWTQWmuG9J2kGNop6IecrAx?= =?us-ascii?Q?cgNPtd5oJbTQbqG+E=2FQqA=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Access to tx_q_limit needs to be serialized among the possibly multiple writers to the tx queue. A mutex will do fine for that. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/cfg80211.c | 2 ++ drivers/net/wireless/microchip/wilc1000/netdev.h | 2 ++ drivers/net/wireless/microchip/wilc1000/wlan.c | 5 ++--- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.c b/drivers/n= et/wireless/microchip/wilc1000/cfg80211.c index d352b7dd03283..0fcc064254f1e 100644 --- a/drivers/net/wireless/microchip/wilc1000/cfg80211.c +++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.c @@ -1672,6 +1672,7 @@ static void wlan_init_locks(struct wilc *wl) =20 spin_lock_init(&wl->txq_spinlock); mutex_init(&wl->txq_add_to_head_cs); + mutex_init(&wl->tx_q_limit_lock); =20 init_waitqueue_head(&wl->txq_event); init_completion(&wl->cfg_event); @@ -1688,6 +1689,7 @@ void wlan_deinit_locks(struct wilc *wilc) mutex_destroy(&wilc->txq_add_to_head_cs); mutex_destroy(&wilc->vif_mutex); mutex_destroy(&wilc->deinit_lock); + mutex_destroy(&wilc->tx_q_limit_lock); cleanup_srcu_struct(&wilc->srcu); } =20 diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h b/drivers/net= /wireless/microchip/wilc1000/netdev.h index 650b40961cf98..e247f92a409e0 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.h +++ b/drivers/net/wireless/microchip/wilc1000/netdev.h @@ -257,6 +257,8 @@ struct wilc { atomic_t txq_entries; struct txq_fw_recv_queue_stat fw[NQUEUES]; =20 + /* protect tx_q_limit state */ + struct mutex tx_q_limit_lock; struct wilc_tx_queue_status tx_q_limit; struct rxq_entry_t rxq_head; =20 diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index f82857cebe35e..9b6605e9df296 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -279,13 +279,12 @@ static void init_q_limits(struct wilc *wl) =20 static bool is_ac_q_limit(struct wilc *wl, u8 q_num) { - unsigned long flags; struct wilc_tx_queue_status *q =3D &wl->tx_q_limit; u8 end_index; u8 q_limit; bool ret =3D false; =20 - spin_lock_irqsave(&wl->txq_spinlock, flags); + mutex_lock(&wl->tx_q_limit_lock); =20 end_index =3D q->end_index; q->cnt[q->buffer[end_index]] -=3D factors[q->buffer[end_index]]; @@ -306,7 +305,7 @@ static bool is_ac_q_limit(struct wilc *wl, u8 q_num) if (skb_queue_len(&wl->txq[q_num]) <=3D q_limit) ret =3D true; =20 - spin_unlock_irqrestore(&wl->txq_spinlock, flags); + mutex_unlock(&wl->tx_q_limit_lock); =20 return ret; } --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 ED38BC433EF for ; Thu, 23 Dec 2021 01:14:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346011AbhLWBOY (ORCPT ); Wed, 22 Dec 2021 20:14:24 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18276 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345716AbhLWBON (ORCPT ); Wed, 22 Dec 2021 20:14:13 -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=agTBrbbxmaBcZhOGntoYkSTH1oRQbQIq4v8g5Df83lg=; b=I2OSv7f6dUAIVuLK4ihQ3KNlGLeVSixiSC1ql98qZVBthRWB7JnPTtICS+BBenpgi0Ur pBWh4OmTFgslu/CmiIJmGzYNtP2jX4ccbaIyHkS8PhFu1eBeqq/YC0XAkZjV3XjUx+iHKW Om2N7QV4YcvT0XDqmWeAo5NGXQchWWQmAYuRNNCGQsy4ZLC5Stbp8Gio5S3kixoygLnl2W 3gB5jFdQvmm0FShsB+bB10wSXFeiWVfo8q0XrXXBeE0D1mPBjXFt+f0f5yyQAsCF81/D4Q Xeyzx/sSQO4VztoksmNoSe9LpJsnTDWCNRjJkUwk99E+2WdRpprCLHXKhv/lxNdQ== Received: by filterdrecv-656998cfdd-phncc with SMTP id filterdrecv-656998cfdd-phncc-1-61C3CD5E-38 2021-12-23 01:14:06.64426236 +0000 UTC m=+7955207.830509139 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-4-1 (SG) with ESMTP id 71zB2wfxQ3agYG4UQ8ZiVg Thu, 23 Dec 2021 01:14:06.494 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 649E9701463; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 25/50] wilc1000: replace txq_spinlock with ack_filter_lock mutex Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-26-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvLFGvaKITknzkke94?= =?us-ascii?Q?9=2F7j63eSgfYeyP9v+L3+fNZ9QLqBEqZkdjJa3QD?= =?us-ascii?Q?7To2KHUS8OZft9cQsvjJ4hJp2PT8yyWRRGyjdOR?= =?us-ascii?Q?8egrTs+KALh6SzPjQou9g3gi=2FETlJc1=2FKC6KOy7?= =?us-ascii?Q?2W09Y1IgUeq0zkd0epS+=2FHY4Q4ENwPq2oF3xdff?= =?us-ascii?Q?MzVU3yv=2FzICqX76y27sVg=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The only purpose left for txq_spinlock is to protect the ack_filter. The ack_filter is only updated by the tx queue writers and the tx queue consumer, so interrupts don't have to be disabled and sleeping is OK. In other words, we can use a mutex instead of a spinlock. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/cfg80211.c | 1 - drivers/net/wireless/microchip/wilc1000/netdev.c | 2 ++ drivers/net/wireless/microchip/wilc1000/netdev.h | 5 ++--- drivers/net/wireless/microchip/wilc1000/wlan.c | 12 ++++-------- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.c b/drivers/n= et/wireless/microchip/wilc1000/cfg80211.c index 0fcc064254f1e..6f19dee813f2a 100644 --- a/drivers/net/wireless/microchip/wilc1000/cfg80211.c +++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.c @@ -1670,7 +1670,6 @@ static void wlan_init_locks(struct wilc *wl) mutex_init(&wl->vif_mutex); mutex_init(&wl->deinit_lock); =20 - spin_lock_init(&wl->txq_spinlock); mutex_init(&wl->txq_add_to_head_cs); mutex_init(&wl->tx_q_limit_lock); =20 diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c b/drivers/net= /wireless/microchip/wilc1000/netdev.c index 999933532c2de..71cb15f042cdd 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.c +++ b/drivers/net/wireless/microchip/wilc1000/netdev.c @@ -863,6 +863,7 @@ void wilc_netdev_cleanup(struct wilc *wilc) =20 srcu_idx =3D srcu_read_lock(&wilc->srcu); list_for_each_entry_rcu(vif, &wilc->vif_list, list) { + mutex_destroy(&vif->ack_filter_lock); if (vif->ndev) unregister_netdev(vif->ndev); } @@ -929,6 +930,7 @@ struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, = const char *name, vif->wilc =3D wl; vif->ndev =3D ndev; ndev->ml_priv =3D vif; + mutex_init(&vif->ack_filter_lock); =20 ndev->netdev_ops =3D &wilc_netdev_ops; =20 diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h b/drivers/net= /wireless/microchip/wilc1000/netdev.h index e247f92a409e0..82f38a0e20214 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.h +++ b/drivers/net/wireless/microchip/wilc1000/netdev.h @@ -190,6 +190,8 @@ struct wilc_vif { struct timer_list during_ip_timer; struct timer_list periodic_rssi; struct rf_info periodic_stat; + /* protect ack_filter */ + struct mutex ack_filter_lock; struct tcp_ack_filter ack_filter; bool connecting; struct wilc_priv priv; @@ -226,9 +228,6 @@ struct wilc { /* protect head of transmit queue */ struct mutex txq_add_to_head_cs; =20 - /* protect txq_entry_t transmit queue */ - spinlock_t txq_spinlock; - /* protect rxq_entry_t receiver queue */ struct mutex rxq_cs; =20 diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index 9b6605e9df296..81180b2f9f4e1 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -124,15 +124,13 @@ static inline void tcp_process(struct net_device *dev= , struct sk_buff *tqe) void *buffer =3D tqe->data; const struct ethhdr *eth_hdr_ptr =3D buffer; int i; - unsigned long flags; struct wilc_vif *vif =3D netdev_priv(dev); - struct wilc *wilc =3D vif->wilc; struct tcp_ack_filter *f =3D &vif->ack_filter; const struct iphdr *ip_hdr_ptr; const struct tcphdr *tcp_hdr_ptr; u32 ihl, total_length, data_offset; =20 - spin_lock_irqsave(&wilc->txq_spinlock, flags); + mutex_lock(&vif->ack_filter_lock); =20 if (eth_hdr_ptr->h_proto !=3D htons(ETH_P_IP)) goto out; @@ -168,7 +166,7 @@ static inline void tcp_process(struct net_device *dev, = struct sk_buff *tqe) } =20 out: - spin_unlock_irqrestore(&wilc->txq_spinlock, flags); + mutex_unlock(&vif->ack_filter_lock); } =20 static void wilc_wlan_tx_packet_done(struct sk_buff *tqe, int status) @@ -201,12 +199,10 @@ static void wilc_wlan_txq_drop_net_pkt(struct sk_buff= *tqe) static void wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) { struct wilc_vif *vif =3D netdev_priv(dev); - struct wilc *wilc =3D vif->wilc; struct tcp_ack_filter *f =3D &vif->ack_filter; u32 i =3D 0; - unsigned long flags; =20 - spin_lock_irqsave(&wilc->txq_spinlock, flags); + mutex_lock(&vif->ack_filter_lock); for (i =3D f->pending_base; i < (f->pending_base + f->pending_acks_idx); i++) { u32 index; @@ -238,7 +234,7 @@ static void wilc_wlan_txq_filter_dup_tcp_ack(struct net= _device *dev) else f->pending_base =3D 0; =20 - spin_unlock_irqrestore(&wilc->txq_spinlock, flags); + mutex_unlock(&vif->ack_filter_lock); } =20 void wilc_enable_tcp_ack_filter(struct wilc_vif *vif, bool value) --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 2B19AC433FE for ; Thu, 23 Dec 2021 01:15:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346219AbhLWBPu (ORCPT ); Wed, 22 Dec 2021 20:15:50 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27166 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346210AbhLWBOi (ORCPT ); Wed, 22 Dec 2021 20:14:38 -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=6N7dj4qJUKtMM/lJa8tbpsQXTpV3hh508uNFMCeLTmw=; b=vr+cyHY2pvPEH42hDN8WIQdKRBy7fQiQTie0z7EgQ7iJcIbs1LSTZYR7mEUfwFqWDZDh 5eh39xKSQJsPmXg0qm9SZecMP4+N2M3Dsp4XOZI2ureZ36yZWB1L4zPYkQBy/FIabKx85L WhAbvaYhcxqjFoUA6Ig/vFhMhvANjYyAoNnQjaqctzadT252UF1LaXebuRIj3dtOt3jU4y sTPETVrmyUPUDm2UDsUewXIa4bqSiZoVm/LnZcQiqsfCiIGH4mydq+a9v6GhInK6h8K6dA oGM7H7iq6m9YlvrN9ndnefOeUCQExmMlHsHa0kGZvOn4g0oWBiFMo3zSggd5ZCTg== Received: by filterdrecv-64fcb979b9-4vrtk with SMTP id filterdrecv-64fcb979b9-4vrtk-1-61C3CD5E-33 2021-12-23 01:14:06.639603191 +0000 UTC m=+8644640.706394453 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-4-1 (SG) with ESMTP id XtinkhGEQb2hIYycvpVgXQ Thu, 23 Dec 2021 01:14:06.505 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 6AE00701474; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 26/50] wilc1000: reduce amount of time ack_filter_lock is held Date: Thu, 23 Dec 2021 01:14:07 +0000 (UTC) Message-Id: <20211223011358.4031459-27-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvGGquUt9ycIje3WqF?= =?us-ascii?Q?lCafr+1TG2O9DDHkxjFYdcB99nE90QGpbToWeya?= =?us-ascii?Q?nt9YrHssVEPslyq=2FMdXIm7BTKB7tj7bIhBcy7Tg?= =?us-ascii?Q?hLMrs4frDMKt81CSEcu+GVPW2LDjjWAt8ImuUCO?= =?us-ascii?Q?wAaE4DfvmHM7kfTbVwFWqQX3wieADAhPse9ODP4?= =?us-ascii?Q?nLRKa9zMZFc=2Fe6vASnoHQ=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In tcp_process(), only hold the ack_filter_lock while accessing the ack_filter state. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index 81180b2f9f4e1..5ea9129b36925 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -130,15 +130,13 @@ static inline void tcp_process(struct net_device *dev= , struct sk_buff *tqe) const struct tcphdr *tcp_hdr_ptr; u32 ihl, total_length, data_offset; =20 - mutex_lock(&vif->ack_filter_lock); - if (eth_hdr_ptr->h_proto !=3D htons(ETH_P_IP)) - goto out; + return; =20 ip_hdr_ptr =3D buffer + ETH_HLEN; =20 if (ip_hdr_ptr->protocol !=3D IPPROTO_TCP) - goto out; + return; =20 ihl =3D ip_hdr_ptr->ihl << 2; tcp_hdr_ptr =3D buffer + ETH_HLEN + ihl; @@ -150,6 +148,9 @@ static inline void tcp_process(struct net_device *dev, = struct sk_buff *tqe) =20 seq_no =3D ntohl(tcp_hdr_ptr->seq); ack_no =3D ntohl(tcp_hdr_ptr->ack_seq); + + mutex_lock(&vif->ack_filter_lock); + for (i =3D 0; i < f->tcp_session; i++) { u32 j =3D f->ack_session_info[i].seq_num; =20 @@ -163,10 +164,9 @@ static inline void tcp_process(struct net_device *dev,= struct sk_buff *tqe) add_tcp_session(vif, 0, 0, seq_no); =20 add_tcp_pending_ack(vif, ack_no, i, tqe); - } =20 -out: - mutex_unlock(&vif->ack_filter_lock); + mutex_unlock(&vif->ack_filter_lock); + } } =20 static void wilc_wlan_tx_packet_done(struct sk_buff *tqe, int status) --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 D78E2C433EF for ; Thu, 23 Dec 2021 01:17:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346562AbhLWBRR (ORCPT ); Wed, 22 Dec 2021 20:17:17 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18314 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345749AbhLWBOP (ORCPT ); Wed, 22 Dec 2021 20:14:15 -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=VdSmr7LcH0rW8kHWmZpoh/Ig1LSGlhHmXHB0t3cqZGc=; b=AGJAB9NF2r1y61gG1NFibLyjYqebZYsKzYQcyhYBEKFYqqWwu8BuwSFhK0VCpq+UoUxt Fgfp5X8r6vQtUrMwJp0elicdllDHKLvt1X7EGdEuT0VRQYDHOdRYmpuZHKGWYytmh7nhrg hRMcbf+nteyrDWlChGGdXIyMLM+oYUTGSYy7nDrqIf7DW74x8qEoHJs9AHz+jFRha8lz2A tsJj6HzeIfuluuFGT+CUAwMxLaKtxLJRVkxU7ukN9K2xEdsvXTr/g6so2joTiiveH9o4/F 8sawsJ7aa84oUE3iqZkpuMvkg5C79l8hC6IEfUGQsD0exT3joAie/Pq2I2WiDbFw== Received: by filterdrecv-64fcb979b9-6vbpf with SMTP id filterdrecv-64fcb979b9-6vbpf-1-61C3CD5E-35 2021-12-23 01:14:06.683709228 +0000 UTC m=+8644637.687945467 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-6-0 (SG) with ESMTP id OwzaDxMVSaWpyCRXrQezBA Thu, 23 Dec 2021 01:14:06.542 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 73DAF701488; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 27/50] wilc1000: simplify ac_balance() a bit Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-28-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvFH5jXK85cQtbtZt7?= =?us-ascii?Q?SL3jCjJD5yamKyyCopUd3NzO3D=2FhuQ5uOd=2Fdefx?= =?us-ascii?Q?Rnh5BvGJtoyo9c8YpecROwyRILZQe2L38qiqsO8?= =?us-ascii?Q?X42rWYL8lZGUAQYKHueWYFauMysTRqWC5PnLWjm?= =?us-ascii?Q?Mt5LPwzOsSevt8liHKpmpbI98+=2Fy8xZQhoGhIgM?= =?us-ascii?Q?EdiKu7aRHVNn376XDkFYw=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" ac_balance() is never going to fail ("ratio" is always non-NULL), so there is no reason to pretend otherwise. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index 5ea9129b36925..287c0843ba152 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -345,21 +345,23 @@ static inline u8 ac_classify(struct wilc *wilc, struc= t sk_buff *skb) return q_num; } =20 -static inline int ac_balance(struct wilc *wl, u8 *ratio) +/** + * ac_balance() - balance queues by favoring ones with fewer packets pendi= ng + * @wl: Pointer to the wilc structure. + * @ratio: Pointer to array of length NQUEUES in which this function + * returns the number of packets that may be scheduled for each + * access category. + */ +static inline void ac_balance(const struct wilc *wl, u8 *ratio) { u8 i, max_count =3D 0; =20 - if (!ratio) - return -EINVAL; - for (i =3D 0; i < NQUEUES; i++) if (wl->fw[i].count > max_count) max_count =3D wl->fw[i].count; =20 for (i =3D 0; i < NQUEUES; i++) ratio[i] =3D max_count - wl->fw[i].count; - - return 0; } =20 static inline void ac_update_fw_ac_pkt_info(struct wilc *wl, u32 reg) @@ -894,8 +896,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_co= unt) if (wilc->quit) goto out_update_cnt; =20 - if (ac_balance(wilc, ac_desired_ratio)) - return -EINVAL; + ac_balance(wilc, ac_desired_ratio); =20 mutex_lock(&wilc->txq_add_to_head_cs); =20 --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 01C14C4332F for ; Thu, 23 Dec 2021 01:16:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346731AbhLWBQG (ORCPT ); Wed, 22 Dec 2021 20:16:06 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27196 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346221AbhLWBOo (ORCPT ); Wed, 22 Dec 2021 20:14:44 -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=yVIQwUE9JRNbIa/ZfSEZSItfnS3OUxif3uKX0p0Ts4Q=; b=rImcg9Iom5wm2dvirQ5mQuphAMZvnGxdeOhd39ze3yjq4jLPi/gxhVf0fOgBnqVwiR2N Qos7mDvDdO1g0HDa6zLKJTwsRBVjLHtZzfdlnDr6lYcP7NZ1ly11vtTxmFsNPyvoWbFHKA vfAdL9L1lUTbIPmJOkyJ0o2Ctt57qfaWDiBMXRxjJcjS7KbhyfbKXxUljMbpDfNV8nd3Zo RIzpiJgXE2zsjf0i/VuLQCOngjIDnhdRhz6SzXHbybtvnxmSmYTRt+Apx0zq8vLhJg7ToJ x8p4hZLjgs9mJpHzl5N1rvFtTSH22JBUsWT40BraJy1Cw0CIQvROShStiVgt1E0w== Received: by filterdrecv-75ff7b5ffb-bcbbj with SMTP id filterdrecv-75ff7b5ffb-bcbbj-1-61C3CD5E-1A 2021-12-23 01:14:06.714544574 +0000 UTC m=+9687191.029415880 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-3-0 (SG) with ESMTP id 2tIlyEXETV22Sdh0w6UE5A Thu, 23 Dec 2021 01:14:06.581 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 7CD5B7014A3; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 28/50] wilc1000: improve send_packets() a bit Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-29-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvH7VqQfef+8M9fWl+?= =?us-ascii?Q?BgjYTNO1iE732BTkQPVhTFQ+A1qQ3TSiRj3VpHa?= =?us-ascii?Q?EhNKjRi77SgeRSGIId18kL=2FiLTtApC7daijm4nG?= =?us-ascii?Q?tQ9AOZtPMJltjt9orcK3BnaRRlxBO1UExC8KJF5?= =?us-ascii?Q?blJbmFvwyN23qYphPgNU6tb9AoDSwIF=2FYpq1VoR?= =?us-ascii?Q?sRA4TXlxrHnaI25tXHwCA=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Improve the documentation and simplify the code a bit. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index 287c0843ba152..033979cc85b43 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -858,29 +858,26 @@ static int copy_packets(struct wilc *wilc, int entrie= s, u32 *vmm_table, } =20 /** - * send_packets() - Send packets to the chip + * send_packets() - send the transmit buffer to the chip * @wilc: Pointer to the wilc structure. - * @len: The length of the buffer containing the packets to be sent to - * the chip. + * @len: The length of the buffer containing the packets to be to the chip. * - * Send the packets in the VMM table to the chip. + * Send the packets in the transmit buffer to the chip. * * Context: The bus must have been acquired. * - * Return: - * Negative number on error, 0 on success. + * Return: Negative number on error, 0 on success. */ static int send_packets(struct wilc *wilc, int len) { const struct wilc_hif_func *func =3D wilc->hif_func; int ret; - u8 *txb =3D wilc->tx_buffer; =20 ret =3D func->hif_clear_int_ext(wilc, ENABLE_TX_VMM); if (ret) return ret; =20 - return func->hif_block_tx_ext(wilc, 0, txb, len); + return func->hif_block_tx_ext(wilc, 0, wilc->tx_buffer, len); } =20 int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 B73A3C433F5 for ; Thu, 23 Dec 2021 01:17:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346530AbhLWBRN (ORCPT ); Wed, 22 Dec 2021 20:17:13 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18418 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345817AbhLWBOW (ORCPT ); Wed, 22 Dec 2021 20:14:22 -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=f9xzkdOgmpl7Kp4IqvxccUyOsVwln+nUuQ3GXq4ZqFs=; b=ppHdJXk/AG+5xPHnjDps7NgVXLNfN05WI955waa9m12R5zEWDTXDH1dmFrExgZCir0Du Cb1J0XotgzBo8MDC/A0NxgAhJcGk/dLmMEJ1DkkS5CYahcbwq2WhSGn9REnASMdBC6MHLW vvXXDSOnMd4zYH6YiZP85cc8BxjTav9VZRJyuT343UPcKnmBRibGqyZh+3xJz9uNUxR1PZ Y1Vo5aWOg2L2RKdVMK/yh7I8EwNOjQ8gR1Uh9awypLmgajX2iJsH9KVAWaQH16HDPt3AZV D9tivbIVPuwxhvSmSwVtiPRXCNKSVPbjQPoR/DDoDJDYgHPqv16+uMDGiW2Qs8tg== Received: by filterdrecv-7bf5c69d5-w55fp with SMTP id filterdrecv-7bf5c69d5-w55fp-1-61C3CD5E-34 2021-12-23 01:14:06.708063961 +0000 UTC m=+9687231.867084891 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-3-0 (SG) with ESMTP id KTvvbw4FRUKHwSCk21U2EQ Thu, 23 Dec 2021 01:14:06.577 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 85DB07014A9; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 29/50] wilc1000: factor header length calculation into a new function Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-30-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvM=2F6RLlPQwh+26vUz?= =?us-ascii?Q?xaeDWE8+d=2Fa7XnYxrlWl0eXZNjUWX3Z2JuNdED8?= =?us-ascii?Q?I4ROcRQK=2F8Fck6bIRHcj+2h31fZd5siMauqypVg?= =?us-ascii?Q?jEumQn4U2dW1Df3hj55qWS1vuxs4aLsVim+dmjY?= =?us-ascii?Q?PAPysDfcvwCeeZrm7ck2y32vmvjlgJp516nFSNU?= =?us-ascii?Q?6Q+WY9HJI6ZGuz2JfIkJQ=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add a helper function to calculate header length instead of using the same open code twice. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/wlan.c | 43 +++++++++++++------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index 033979cc85b43..1cd9a7761343a 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -602,6 +602,33 @@ void host_sleep_notify(struct wilc *wilc) } EXPORT_SYMBOL_GPL(host_sleep_notify); =20 +/** + * tx_hdr_len() - calculate tx packet header length + * @type: The packet type for which to return the header length. + * + * Calculate the total header size for a given packet type. This size + * includes the 4 bytes required to hold the VMM header. + * + * Return: The total size of the header in bytes. + */ +static u32 tx_hdr_len(u8 type) +{ + switch (type) { + case WILC_NET_PKT: + return ETH_ETHERNET_HDR_OFFSET; + + case WILC_CFG_PKT: + return ETH_CONFIG_PKT_HDR_OFFSET; + + case WILC_MGMT_PKT: + return HOST_HDR_OFFSET; + + default: + pr_err("%s: Invalid packet type %d.", __func__, type); + return 4; + } +} + /** * fill_vmm_table() - Fill VMM table with packets to be sent * @wilc: Pointer to the wilc structure. @@ -658,13 +685,7 @@ static int fill_vmm_table(const struct wilc *wilc, goto out; =20 tx_cb =3D WILC_SKB_TX_CB(tqe_q[ac]); - if (tx_cb->type =3D=3D WILC_CFG_PKT) - vmm_sz =3D ETH_CONFIG_PKT_HDR_OFFSET; - else if (tx_cb->type =3D=3D WILC_NET_PKT) - vmm_sz =3D ETH_ETHERNET_HDR_OFFSET; - else - vmm_sz =3D HOST_HDR_OFFSET; - + vmm_sz =3D tx_hdr_len(tx_cb->type); vmm_sz +=3D tqe_q[ac]->len; vmm_sz =3D ALIGN(vmm_sz, 4); =20 @@ -834,17 +855,13 @@ static int copy_packets(struct wilc *wilc, int entrie= s, u32 *vmm_table, =20 cpu_to_le32s(&header); memcpy(&txb[offset], &header, 4); - if (tx_cb->type =3D=3D WILC_CFG_PKT) { - buffer_offset =3D ETH_CONFIG_PKT_HDR_OFFSET; - } else if (tx_cb->type =3D=3D WILC_NET_PKT) { + buffer_offset =3D tx_hdr_len(tx_cb->type); + if (tx_cb->type =3D=3D WILC_NET_PKT) { int prio =3D tx_cb->q_num; =20 bssid =3D vif->bssid; - buffer_offset =3D ETH_ETHERNET_HDR_OFFSET; memcpy(&txb[offset + 4], &prio, sizeof(prio)); memcpy(&txb[offset + 8], bssid, 6); - } else { - buffer_offset =3D HOST_HDR_OFFSET; } =20 memcpy(&txb[offset + buffer_offset], tqe->data, tqe->len); --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 BE624C433F5 for ; Thu, 23 Dec 2021 01:15:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346636AbhLWBPr (ORCPT ); Wed, 22 Dec 2021 20:15:47 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18394 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345779AbhLWBOT (ORCPT ); Wed, 22 Dec 2021 20:14: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=3vwCxlA4ciJJxDou6+Vb/H7rVta8Jut/SEU831ryMNU=; b=aMLSvbfJFTCyE2NGkfucRE4R2mGDyxR2qAeqVCy6M7NHL3w51yP2L9P0O3/PTJnM4eHm z9fxAMb8WcWmmQaKjB1qMlY3etdM94RthIavutZLG+DkZIzLPrh/ge0ma0beOYgO6Tr2xc 06puuOtJMBVm8MAWTdWj16TVWy1fvqTo4SuV9g5lhhpvIIahxEpkW/yLoS0a/gSGrTQsIH MrdM19HrPlWfNs/kEaIEUYhXvxYi5Lfdi7GRD67kZ+OVUCOc09TcsUJsffvQe/U0BwIl38 rASRv8uHr9/B5lQabJ5+GwxiVqvpLAquD39u7rYgGNbA2tHrAM0F76iPDtawz5TA== Received: by filterdrecv-64fcb979b9-st7n5 with SMTP id filterdrecv-64fcb979b9-st7n5-1-61C3CD5E-3C 2021-12-23 01:14:06.739937721 +0000 UTC m=+8644640.723524771 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-5-0 (SG) with ESMTP id dhLYRvACTEmHBYzBDu_11g Thu, 23 Dec 2021 01:14:06.600 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 8F3127014AD; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 30/50] wilc1000: use more descriptive variable names Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-31-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvFxBP+gfd73CXFX+b?= =?us-ascii?Q?N=2FzdCv1aaMpRvyqQ7QMMfTi3rjMRuYumSNBl00O?= =?us-ascii?Q?AOZq92YF2soepP4nF+7m7Rwi9ECmoO5pYtdjtLb?= =?us-ascii?Q?rl=2F3umoT6k8Gek5XOEDVIQyew2oPLaZNkKO9C6O?= =?us-ascii?Q?CKT0mRaev9RFH6ROm53qOP8EAe4i9jw=2FPD6e7Mm?= =?us-ascii?Q?cfsAjseOnZ6=2FwRwN5u5+A=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Rename "i" to "vmm_table_len" to improve readability and update kernel-doc for send_vmm_table() as well. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/wlan.c | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index 1cd9a7761343a..a4523b0860878 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -712,9 +712,9 @@ static int fill_vmm_table(const struct wilc *wilc, } =20 /** - * send_vmm_table() - Send the VMM table to the chip + * send_vmm_table() - send the VMM table to the chip * @wilc: Pointer to the wilc structure. - * @i: The number of entries in the VMM table. + * @vmm_table_len: The number of entries in the VMM table. * @vmm_table: The VMM table to send. * * Send the VMM table to the chip and get back the number of entries @@ -723,10 +723,10 @@ static int fill_vmm_table(const struct wilc *wilc, * Context: The bus must have been acquired before calling this * function. * - * Return: - * The number of VMM table entries the chip can accept. + * 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) +static int send_vmm_table(struct wilc *wilc, + int vmm_table_len, const u32 *vmm_table) { const struct wilc_hif_func *func; int ret, counter, entries, timeout; @@ -758,7 +758,8 @@ static int send_vmm_table(struct wilc *wilc, int i, con= st u32 *vmm_table) timeout =3D 200; do { ret =3D func->hif_block_tx(wilc, WILC_VMM_TBL_RX_SHADOW_BASE, - (u8 *)vmm_table, (i + 1) * 4); + (u8 *)vmm_table, + (vmm_table_len + 1) * 4); if (ret) break; =20 @@ -899,7 +900,7 @@ static int send_packets(struct wilc *wilc, int len) =20 int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) { - int i, entries, len; + int vmm_table_len, entries, len; u8 ac_desired_ratio[NQUEUES] =3D {0, 0, 0, 0}; u8 vmm_entries_ac[WILC_VMM_TBL_SIZE]; int ret =3D 0; @@ -919,13 +920,13 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_= count) wilc_wlan_txq_filter_dup_tcp_ack(vif->ndev); srcu_read_unlock(&wilc->srcu, srcu_idx); =20 - i =3D fill_vmm_table(wilc, ac_desired_ratio, vmm_table, vmm_entries_ac); - if (i =3D=3D 0) + vmm_table_len =3D fill_vmm_table(wilc, ac_desired_ratio, vmm_table, vmm_e= ntries_ac); + if (vmm_table_len =3D=3D 0) goto out_unlock; =20 acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); =20 - ret =3D send_vmm_table(wilc, i, vmm_table); + ret =3D send_vmm_table(wilc, vmm_table_len, vmm_table); if (ret <=3D 0) { if (ret =3D=3D 0) /* No VMM space available in firmware. Inform --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 6189AC43217 for ; Thu, 23 Dec 2021 01:16:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346092AbhLWBQy (ORCPT ); Wed, 22 Dec 2021 20:16:54 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18438 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345825AbhLWBOX (ORCPT ); Wed, 22 Dec 2021 20:14: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=i32l0pYwrSyAAZKj3vPDSxoH9wI/6IorT8XSw+vG+PQ=; b=qXcfaCONpQOEDT+1cGxzzM6O+Hq9xgQvQNC8IgioZj1aqz2RJzpIVd9gVXdwsaYtdeF2 Wbs6geZ+rJQrZDwOeitskuB6yEJT307phjdcPERrl4yh5319nwKgycSzdK8eIrdXTHMJsP 2WRvSeHd2hAkXxXXoRXFqjN0PVnuxcwlqwl3jOwhn03DqLVNOo9GRcOMTGmnA/D+2w0HH4 19kbmo/+kYgQuM5ly7zyuPuB84hTmFyIJSNxL8ZyX3KI5DfNf2Xh1Osaf6KG37Ro9KkLs9 OhdDenuGga1zAg+QNAo272WjU9JV9OKaHSUZKrHMb7E5WFeuLaUtif1AlagjVW7w== Received: by filterdrecv-canary-69c6c696bc-fss6r with SMTP id filterdrecv-canary-69c6c696bc-fss6r-1-61C3CD5E-33 2021-12-23 01:14:06.745349049 +0000 UTC m=+9768540.518210263 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-2-1 (SG) with ESMTP id OCg6PJjkSGCtTzrY4by5Hw Thu, 23 Dec 2021 01:14:06.619 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 986BB7014D4; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 31/50] wilc1000: eliminate another magic constant Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-32-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvECsuSnE8f3tXIemh?= =?us-ascii?Q?Wexej=2Fxxnh78Q8DU2R=2Fig=2FtGWIowexxuZl2DaJZ?= =?us-ascii?Q?eO3pMmOHOyq2EoHh1bofVI1hSEEeGEYNWeW2kyd?= =?us-ascii?Q?6ZCZYvfEFbfjzTNeIkalXZArgwL3grsfNLk1UfV?= =?us-ascii?Q?07z6+bCaODMs=2FuXf+az3GmnTHMbX5qD7JQCeTJh?= =?us-ascii?Q?fpTeBMcoi9ttQe1Ktw0XA=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Setting bit 1 of the WILC_HOST_VMM_CTL register seems to tell the chip that the VMM table has been updated and is ready for processing. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 3 ++- drivers/net/wireless/microchip/wilc1000/wlan.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index a4523b0860878..cff70f7d38c89 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -763,7 +763,8 @@ static int send_vmm_table(struct wilc *wilc, if (ret) break; =20 - ret =3D func->hif_write_reg(wilc, WILC_HOST_VMM_CTL, 0x2); + ret =3D func->hif_write_reg(wilc, WILC_HOST_VMM_CTL, + WILC_VMM_TABLE_UPDATED); if (ret) break; =20 diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/w= ireless/microchip/wilc1000/wlan.h index f5d32ec93fdb9..11a54320ffd05 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.h +++ b/drivers/net/wireless/microchip/wilc1000/wlan.h @@ -243,6 +243,7 @@ =20 #define WILC_VMM_ENTRY_COUNT GENMASK(8, 3) #define WILC_VMM_ENTRY_AVAILABLE BIT(2) +#define WILC_VMM_TABLE_UPDATED BIT(1) /*******************************************/ /* E0 and later Interrupt flags. */ /*******************************************/ --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 4F407C433EF for ; Thu, 23 Dec 2021 01:17:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345943AbhLWBRa (ORCPT ); Wed, 22 Dec 2021 20:17:30 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27158 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346207AbhLWBOh (ORCPT ); Wed, 22 Dec 2021 20:14:37 -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=EbITibNsBXzvKKlU+piJIV+uEtgNRqVMqmU3tYGIQcU=; b=xzHrFlKjQzAtjaW8yiDPgKpwVk301omL4rrVVi8w8Wn5+ps/av+vh+5OfXPZEERTPYPt /W99RjK/+Ra1HWGnMvN4BkuLRimUWd3HUT5joH31sv2h9xq+esNyqdoHCAOvTFy+FJRevZ ekxP5YtIX8x9iYHauJ9tEFmtAlvociUKCh8SKNsnABibWrDzZZbzoM3m1O+utHpr7+s4yM ZW6SUsBW8M5pZLX+Ee+75eOiQc3+NsnylO+gY7a3n9fIlt317EgfxB64fageRmVHUsGhMJ pT37rWDgO0SGrLHKUVJ+CiSLRoI/7n9vh78VXlW7zNOnWWG11+xLFDlnj3lm1DvQ== Received: by filterdrecv-64fcb979b9-dthbb with SMTP id filterdrecv-64fcb979b9-dthbb-1-61C3CD5E-2A 2021-12-23 01:14:06.798901564 +0000 UTC m=+8644642.033288874 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-5-0 (SG) with ESMTP id EaVvzUYwQcujwsJtTuNFnQ Thu, 23 Dec 2021 01:14:06.651 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id A1A667014DF; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 32/50] wilc1000: introduce vmm_table_entry() helper function Date: Thu, 23 Dec 2021 01:14:07 +0000 (UTC) Message-Id: <20211223011358.4031459-33-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvLgTn20zR8huEqDJ0?= =?us-ascii?Q?MxRBKbzqZl9pgBv8ieFLgCozwXIMY+YaD2HCv+S?= =?us-ascii?Q?nV6T96yvIyZ5Zej8MBI9aX5ZsbvXSxbkqS1vuYr?= =?us-ascii?Q?cpDqKkCkQw1x4o6qvjAf1jgnc7uW=2Fxz=2FU4bUiQI?= =?us-ascii?Q?WE2DLHfW4eB0A4NdBmKEkYTqJDR+3jvOxnILRn=2F?= =?us-ascii?Q?LD8RoX3h4+jY5OsFcq7iQ=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This simplifies fill_vmm_table() a bit more and will become even more useful with the following patches. Signed-off-by: David Mosberger-Tang Reported-by: kernel test robot --- drivers/net/wireless/microchip/wilc1000/wlan.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index cff70f7d38c89..5939ed5b2db68 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -629,6 +629,17 @@ static u32 tx_hdr_len(u8 type) } } =20 +static u32 vmm_table_entry(struct sk_buff *tqe, u32 vmm_sz) +{ + struct wilc_skb_tx_cb *tx_cb =3D WILC_SKB_TX_CB(tqe); + u32 entry; + + entry =3D vmm_sz / 4; + if (tx_cb->type =3D=3D WILC_CFG_PKT) + entry |=3D WILC_VMM_CFG_PKT; + return cpu_to_le32(entry); +} + /** * fill_vmm_table() - Fill VMM table with packets to be sent * @wilc: Pointer to the wilc structure. @@ -691,11 +702,7 @@ static int fill_vmm_table(const struct wilc *wilc, =20 if (sum + vmm_sz > WILC_TX_BUFF_SIZE) goto out; - vmm_table[i] =3D vmm_sz / 4; - if (tx_cb->type =3D=3D WILC_CFG_PKT) - vmm_table[i] |=3D WILC_VMM_CFG_PKT; - - cpu_to_le32s(&vmm_table[i]); + vmm_table[i] =3D vmm_table_entry(tqe_q[ac], vmm_sz); vmm_entries_ac[i] =3D ac; =20 i++; --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 C6814C43219 for ; Thu, 23 Dec 2021 01:16:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346916AbhLWBQg (ORCPT ); Wed, 22 Dec 2021 20:16:36 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27264 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346244AbhLWBOr (ORCPT ); Wed, 22 Dec 2021 20:14:47 -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=rJXQOqUi7Z+t6XaVH9q545zE1/vlk/+8IKkDxm7FsTA=; b=Jq09PeTp4tmdjzejIOn7GRnC8UQC9IhgNf/MfNPwBoqpbYRwFJtGIfqa6r2xAD0hyGmo qUeXV00uwMEkb+EBMYhzu7YgoYrmkruDeMJkoZxKeoTJcnboQeJrEw4B2M1FGAvlJkbiaU WB/+71VeYb3IykMHEHb2bcS8avWSq7PTbPWCksOS36o0zT7DhgudGZA6GnBiYrF1nLHWSV S9NhShvSMR9CQcj9crOZ/p8MSIUZ0tYtKwHEEcuosNiS7sJ0d5U+798B3MQZY/CZFmiBJ5 YnsnbZCm1pOPWeRE86KFDMaJXU5nVe/TvRhIzIjDPQEtai2E4zUlIxm471YQNmEg== Received: by filterdrecv-75ff7b5ffb-v6hzv with SMTP id filterdrecv-75ff7b5ffb-v6hzv-1-61C3CD5E-45 2021-12-23 01:14:06.791119181 +0000 UTC m=+9687188.981580391 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-3-1 (SG) with ESMTP id W-w5aYJ6SZyvTvooy91cCw Thu, 23 Dec 2021 01:14:06.662 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id AB1DB70054A; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 33/50] wilc1000: move ac_desired_ratio calculation to where its needed Date: Thu, 23 Dec 2021 01:14:06 +0000 (UTC) Message-Id: <20211223011358.4031459-34-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvO2CLe60Vy4lC9UTY?= =?us-ascii?Q?Ro5Pro2bUgGjRcBWEHwUu4+dWi6YKfFFjN5hIcG?= =?us-ascii?Q?IpVl0qlV=2FIHf4fP0BO1pHkp5BWIRRkgc3cMGIAw?= =?us-ascii?Q?qMZf07X1j=2FyWToUo8SL=2FPYWzLbuiQSdm=2F1BT3kx?= =?us-ascii?Q?oz+fPVTpqCo=2FVekUAmFMA+LiOxaPOp3Y3XSWU7l?= =?us-ascii?Q?D85MkY20J2F8WyI4WwQKw=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Move ac_desired_ratio calculation to fill_vmm_table() since that's the only place that needs it. Note that it is unnecessary to initialize the array since ac_balance() is guaranteed to fill it in. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index 5939ed5b2db68..64497754a36b1 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -643,8 +643,6 @@ static u32 vmm_table_entry(struct sk_buff *tqe, u32 vmm= _sz) /** * fill_vmm_table() - Fill VMM table with packets to be sent * @wilc: Pointer to the wilc structure. - * @ac_desired_ratio: First-round limit on number of packets to add from t= he - * 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 @@ -664,7 +662,6 @@ static u32 vmm_table_entry(struct sk_buff *tqe, u32 vmm= _sz) * 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]) { @@ -672,6 +669,7 @@ static int fill_vmm_table(const struct wilc *wilc, u8 k, ac; u32 sum; static const u8 ac_preserve_ratio[NQUEUES] =3D {1, 1, 1, 1}; + u8 ac_desired_ratio[NQUEUES]; const u8 *num_pkts_to_add; bool ac_exist =3D 0; int vmm_sz =3D 0; @@ -683,6 +681,8 @@ static int fill_vmm_table(const struct wilc *wilc, =20 i =3D 0; sum =3D 0; + + ac_balance(wilc, ac_desired_ratio); num_pkts_to_add =3D ac_desired_ratio; do { ac_exist =3D 0; @@ -909,7 +909,6 @@ static int send_packets(struct wilc *wilc, int len) int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) { int vmm_table_len, entries, len; - u8 ac_desired_ratio[NQUEUES] =3D {0, 0, 0, 0}; u8 vmm_entries_ac[WILC_VMM_TBL_SIZE]; int ret =3D 0; u32 vmm_table[WILC_VMM_TBL_SIZE]; @@ -919,8 +918,6 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_co= unt) if (wilc->quit) goto out_update_cnt; =20 - ac_balance(wilc, ac_desired_ratio); - mutex_lock(&wilc->txq_add_to_head_cs); =20 srcu_idx =3D srcu_read_lock(&wilc->srcu); @@ -928,7 +925,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_co= unt) wilc_wlan_txq_filter_dup_tcp_ack(vif->ndev); srcu_read_unlock(&wilc->srcu, srcu_idx); =20 - vmm_table_len =3D fill_vmm_table(wilc, ac_desired_ratio, vmm_table, vmm_e= ntries_ac); + vmm_table_len =3D fill_vmm_table(wilc, vmm_table, vmm_entries_ac); if (vmm_table_len =3D=3D 0) goto out_unlock; =20 --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 9FAF5C433EF for ; Thu, 23 Dec 2021 01:17:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346511AbhLWBRC (ORCPT ); Wed, 22 Dec 2021 20:17:02 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18458 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345821AbhLWBOV (ORCPT ); Wed, 22 Dec 2021 20:14: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=/EyEEryj91qJLUiXheTiSQXnfpShGhTXZyiF3Fj6NOE=; b=q/ktgvMgsfoIZL1oIY5FDcoHRa952fgBF/tSQCzetaW6A6iSaECMJBZjNeNkj2K3OeMP nEW33KEzv4pfCdNxtFl7i+KCLMPH2usx8VFOH7uGiFc8MOMwVNJRqlOpSMgSljRda9t5fF ulq7AzGlvmrw75pKEuGZTRhlxn+//l3Ay0JbDTQ2O+hDJCDgNMKIOsgLTQpj/Tc2IKOTEV oZyYAt/d/fL7x61CNKA8SAFggJJ8pjcyDcImy1wO91cMO+pBd+kkzmjlds1WxsxCsUFfv9 Lqn0BQ+8JRP15/3fokjqzAmKPrTIJ01RWskrvTm9Ycdj6tATTfz8Hl+83X6xAKXQ== Received: by filterdrecv-64fcb979b9-zwvj5 with SMTP id filterdrecv-64fcb979b9-zwvj5-1-61C3CD5E-30 2021-12-23 01:14:06.829827724 +0000 UTC m=+8644582.987173852 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-5-1 (SG) with ESMTP id NjOZgUDzQ4eb6TiIrCXIPw Thu, 23 Dec 2021 01:14:06.686 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id B08E5700394; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 34/50] wilc1000: restructure wilc-wlan_handle_txq() for clarity Date: Thu, 23 Dec 2021 01:14:07 +0000 (UTC) Message-Id: <20211223011358.4031459-35-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvPrUup0j1uxIpwHi0?= =?us-ascii?Q?Qdt824iAYJZBYYzjLIm4TfOHHZ+R40nsdoqq+2g?= =?us-ascii?Q?FdQlY5Su9zFVWJ0l69QnER98Ee0W5AyFIAMsCTH?= =?us-ascii?Q?1v5NaNBzWTtQcnbCQSgNbWRC1eHTJEN485YC7Ue?= =?us-ascii?Q?a14cR0pCPHJ3BOTKEFv5aF66AL7q4vKnHloe5BT?= =?us-ascii?Q?mALRSWdFAVkJDj2GFaC3A=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This restructures the function to make it much clearer how the bus hand-off works. The patch is unfortunately a bit difficult to read, but the final code is clearer and eliminates some gotos. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/wlan.c | 43 ++++++++----------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index 64497754a36b1..803d35b18d2e0 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -818,8 +818,8 @@ static int send_vmm_table(struct wilc *wilc, * Context: The txq_add_to_head_cs mutex must still be held when * calling this function. * - * Return: - * Negative number on error, 0 on success. + * Return: Number of bytes copied to the transmit buffer (always + * non-negative). */ static int copy_packets(struct wilc *wilc, int entries, u32 *vmm_table, u8 *vmm_entries_ac) @@ -908,7 +908,7 @@ static int send_packets(struct wilc *wilc, int len) =20 int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) { - int vmm_table_len, entries, len; + int vmm_table_len, entries; u8 vmm_entries_ac[WILC_VMM_TBL_SIZE]; int ret =3D 0; u32 vmm_table[WILC_VMM_TBL_SIZE]; @@ -931,29 +931,24 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_= count) =20 acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); =20 - ret =3D send_vmm_table(wilc, vmm_table_len, vmm_table); - if (ret <=3D 0) { - if (ret =3D=3D 0) - /* No VMM space available in firmware. Inform - * caller to retry later. - */ - ret =3D WILC_VMM_ENTRY_FULL_RETRY; - goto out_release_bus; - } - - release_bus(wilc, WILC_BUS_RELEASE_ONLY); - - entries =3D ret; - len =3D copy_packets(wilc, entries, vmm_table, vmm_entries_ac); - if (len <=3D 0) - goto out_unlock; - - acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); + entries =3D send_vmm_table(wilc, vmm_table_len, vmm_table); =20 - ret =3D send_packets(wilc, len); + release_bus(wilc, (entries > 0 ? + WILC_BUS_RELEASE_ONLY : + WILC_BUS_RELEASE_ALLOW_SLEEP)); =20 -out_release_bus: - release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); + if (entries <=3D 0) { + ret =3D entries; + } else { + ret =3D copy_packets(wilc, entries, vmm_table, vmm_entries_ac); + if (ret > 0) { + acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); + ret =3D send_packets(wilc, ret); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); + } + } + if (ret >=3D 0 && entries < vmm_table_len) + ret =3D WILC_VMM_ENTRY_FULL_RETRY; =20 out_unlock: mutex_unlock(&wilc->txq_add_to_head_cs); --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 174B1C433FE for ; Thu, 23 Dec 2021 01:15:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346156AbhLWBPx (ORCPT ); Wed, 22 Dec 2021 20:15:53 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27236 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346215AbhLWBOj (ORCPT ); Wed, 22 Dec 2021 20:14:39 -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=xzFPhXZu131S24WhCZubllRraK0h+X09hgsH4auEmW4=; b=djZrXPvzTA+tenvtDns76GrrGFaM7cWDR9tozlDMHoxIqe9+LXIVtdvJsz1hf4d0k6Ic YJ6lIA4aCMpnalQrDHzf5+6jM9osn6cMu+Gz49FiGyOyEroePgKxdMK/M8za14oNvOTPzI 35C4sU2LeBk0my/7AP1m6dUEoZnufrbbvAjf8oLshnggyRuZWuJDCz0GmOzzzMaKs1clDX xXCbvW5H3RgfFVwRshdqYrEPEGjx5OtBCLhYVCdRgo0My2C/yVfCEHz3lO9I2EQfyqjFRw p2rTJSiFtpD7FDpAr+39knzavoySljUyGYoNRq+z2ehO8gPB2QpHPS+/nOfxJ9Hw== Received: by filterdrecv-64fcb979b9-tjknx with SMTP id filterdrecv-64fcb979b9-tjknx-1-61C3CD5E-38 2021-12-23 01:14:06.990457231 +0000 UTC m=+8644589.793975669 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-6-1 (SG) with ESMTP id FG5k7M4MSAKXB0gV8TRNhQ Thu, 23 Dec 2021 01:14:06.823 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id B4878700604; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 35/50] wilc1000: introduce copy_and_send_packets() helper function Date: Thu, 23 Dec 2021 01:14:07 +0000 (UTC) Message-Id: <20211223011358.4031459-36-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvBiV+jvdVngOyqcOk?= =?us-ascii?Q?0VU2J+4m=2FBmK9woiA=2Fsth2gm5SOmvaIqU3Ea+Es?= =?us-ascii?Q?=2F+ATfy2JI9lP0biBgmaDlwfMwwY0thaeL=2FcGu1g?= =?us-ascii?Q?SCkobB6SDyfRJV08GQvz8039JqonmqWknhCZrjN?= =?us-ascii?Q?Ua4ACLg4TwsxHiInb2AaLMFyJ6iHotYv3g1olhI?= =?us-ascii?Q?94K+g6SWYpIQNVoQ3I=2F6A=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Continuing the quest of simplifying the txq handler, factor the code to copy and send packets into its own function. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/wlan.c | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index 803d35b18d2e0..18b1e7fad4d71 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -906,6 +906,22 @@ static int send_packets(struct wilc *wilc, int len) return func->hif_block_tx_ext(wilc, 0, wilc->tx_buffer, len); } =20 +static int copy_and_send_packets(struct wilc *wilc, int entries, + u32 vmm_table[WILC_VMM_TBL_SIZE], + u8 vmm_entries_ac[WILC_VMM_TBL_SIZE]) +{ + int len, ret; + + len =3D copy_packets(wilc, entries, vmm_table, vmm_entries_ac); + if (len <=3D 0) + return len; + + acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); + ret =3D send_packets(wilc, len); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); + return ret; +} + int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) { int vmm_table_len, entries; @@ -940,12 +956,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_c= ount) if (entries <=3D 0) { ret =3D entries; } else { - ret =3D copy_packets(wilc, entries, vmm_table, vmm_entries_ac); - if (ret > 0) { - acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); - ret =3D send_packets(wilc, ret); - release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); - } + ret =3D copy_and_send_packets(wilc, entries, vmm_table, vmm_entries_ac); } if (ret >=3D 0 && entries < vmm_table_len) ret =3D WILC_VMM_ENTRY_FULL_RETRY; --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 B05A0C433EF for ; Thu, 23 Dec 2021 01:16:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239861AbhLWBQ3 (ORCPT ); Wed, 22 Dec 2021 20:16:29 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27454 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346265AbhLWBOx (ORCPT ); Wed, 22 Dec 2021 20:14:53 -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=2c/X1EdWX/aLwBtKGFM16h0YJReLWDvNVnx1yZUKCwI=; b=Ck5t/Ozis0iqs/wTDS19vBodqbA5azVMtX0IYMOAfnjZPMWpLM3wtUoCHIRq8nFEHhEx jjmQuiSAxYxnoI8nqAjoHfzkRLcMkHYl6gDP158+b5Hcp/oGfWqVN2pjVWG7WDpAhP6g9s U5o8meQAOFrixEsD5v9I2uWiL9hoecO8R+Wnie1sDW2KXxJYwJ+zGhUQN/3myPz5UmURld fc2Y3k+cswTjkvDAoLJDjHUvDOFECjiJypygGFxTAK6tAq1rJJlSDDjlZSKiu9ruEpHWdY RO/6R7HzeUvCDOoUPLgToQnzKTjrAK9pC2f8cRV02U6RcogmGOa2l0uhctvkYr5w== Received: by filterdrecv-75ff7b5ffb-ndqvq with SMTP id filterdrecv-75ff7b5ffb-ndqvq-1-61C3CD5F-5 2021-12-23 01:14:07.082131275 +0000 UTC m=+9687225.682526901 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-canary-0 (SG) with ESMTP id p8gjty75SwG8apQHg0pwTw Thu, 23 Dec 2021 01:14:06.926 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id B72FD7009E9; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 36/50] wilc1000: introduce transmit path chip queue Date: Thu, 23 Dec 2021 01:14:07 +0000 (UTC) Message-Id: <20211223011358.4031459-37-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvEhJic2zkDB1r+fbU?= =?us-ascii?Q?c8nmpgeA7v6NrfJJORVx0hnOWe=2F=2FipO5kL0BYhA?= =?us-ascii?Q?sRVAYQ+iZyXl2JaXGGqJdDuCTqpBdy+iR1JoNqr?= =?us-ascii?Q?wdaZM3uLPNYkCkJh6UuvTqrjyUcfwipeVwNyhtf?= =?us-ascii?Q?A856nLbnv3k8qwZPuaszPaFWLPSvxdzT+ununJq?= =?us-ascii?Q?KlNOaEODGHcIGN7L14cBA=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This introduces a chip queue that will hold packets ready to be transferred to the chip. A later patch will start using it. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/cfg80211.c | 3 +++ .../net/wireless/microchip/wilc1000/netdev.h | 18 ++++++++++++++++++ drivers/net/wireless/microchip/wilc1000/wlan.c | 5 +++++ 3 files changed, 26 insertions(+) diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.c b/drivers/n= et/wireless/microchip/wilc1000/cfg80211.c index 6f19dee813f2a..6d3635864569f 100644 --- a/drivers/net/wireless/microchip/wilc1000/cfg80211.c +++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.c @@ -1716,6 +1716,9 @@ int wilc_cfg80211_init(struct wilc **wilc, struct dev= ice *dev, int io_type, for (i =3D 0; i < NQUEUES; i++) skb_queue_head_init(&wl->txq[i]); =20 + skb_queue_head_init(&wl->chipq); + wl->chipq_bytes =3D 0; + INIT_LIST_HEAD(&wl->rxq_head.list); INIT_LIST_HEAD(&wl->vif_list); =20 diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h b/drivers/net= /wireless/microchip/wilc1000/netdev.h index 82f38a0e20214..e168f8644c678 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.h +++ b/drivers/net/wireless/microchip/wilc1000/netdev.h @@ -261,6 +261,24 @@ struct wilc { struct wilc_tx_queue_status tx_q_limit; struct rxq_entry_t rxq_head; =20 + /* The chip queue contains sk_buffs that are ready to be + * transferred to the wilc1000 chip. In particular, they + * already have the VMM and Ethernet headers (for net packets) + * and they are padded to a size that is an integer-multiple + * of 4 bytes. + * + * This queue is usually empty on return from + * wilc_wlan_handle_txq(). However, when the chip does fill + * up, the packets that didn't fit will be held until there is + * space again. + * + * This queue is only accessed by the txq handler thread, so + * no locking is required. + */ + struct sk_buff_head chipq; + /* Total number of bytes queued on the chipq: */ + int chipq_bytes; + const struct firmware *firmware; =20 struct device *dev; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index 18b1e7fad4d71..c3802a34defed 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -1263,6 +1263,11 @@ void wilc_wlan_cleanup(struct net_device *dev) struct wilc *wilc =3D vif->wilc; =20 wilc->quit =3D 1; + + while ((tqe =3D __skb_dequeue(&wilc->chipq))) + wilc_wlan_tx_packet_done(tqe, 0); + wilc->chipq_bytes =3D 0; + for (ac =3D 0; ac < NQUEUES; ac++) { while ((tqe =3D skb_dequeue(&wilc->txq[ac]))) wilc_wlan_tx_packet_done(tqe, 0); --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 40EB5C433FE for ; Thu, 23 Dec 2021 01:16:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346475AbhLWBQc (ORCPT ); Wed, 22 Dec 2021 20:16:32 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27384 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346254AbhLWBOu (ORCPT ); Wed, 22 Dec 2021 20:14:50 -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=GoRCB1qp+NT2deD6O9F/OqL86QNfyIxkoZDwvyfsbMo=; b=lFqhO/+PNUc/uADkjVfHwOdQFkGTAjnHitQFjZGkikHzAXCIZE87fwv0ZgPt4pTmm+/H GN6K/yYa6m+WN168nBItYqvn+jF3U67cf/1453LvM9bY5PCIH0m4IiNUWz2TvYGSRhZdup JSFFiBrIKkTSLwQ2AikuTMms+3tUCTF7LlKJSSG2iE0vDVUzx8+kUAlZqFza0n3VsFmspT XMiKp3JHjVLR0ii+k3OB2Si42NReWF3wr7PDChcr5CV1ptFvhpug5H+6EOsVaPY65ZG3CZ 9ZBjf7viyaOJBawFKsTbFBO1NLr6upwsB4GMAGpETcZssOhqPE+R7xRm8c36q6Vw== Received: by filterdrecv-75ff7b5ffb-bdt5z with SMTP id filterdrecv-75ff7b5ffb-bdt5z-1-61C3CD5E-4A 2021-12-23 01:14:06.973210454 +0000 UTC m=+9687191.495886346 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-2-0 (SG) with ESMTP id j9HPaFX1RKqwFyYUORk8dQ Thu, 23 Dec 2021 01:14:06.858 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id B9D61700BB0; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 37/50] wilc1000: introduce set_header() function Date: Thu, 23 Dec 2021 01:14:07 +0000 (UTC) Message-Id: <20211223011358.4031459-38-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvN1V65Kxvy8FSt8Tq?= =?us-ascii?Q?vXxPJ4NYhhzW59EiQOJdXjEbKiDG1I=2FgLb8fMJL?= =?us-ascii?Q?j1arpTJuPbRzYLx7qBu=2FkxTrwwnlEmsfK8WpYLk?= =?us-ascii?Q?Nhy5X1vMIHD1JBHK+oImfhoisLADN1rbvuKAouo?= =?us-ascii?Q?BGw9P5d7tPbU83XrZsdRY71=2FNJO0csLg7k12RBs?= =?us-ascii?Q?oHUkU2AyywpmG4YM3XwEw=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Refactor the transmit packet header initialization into its own set_header() function. Signed-off-by: David Mosberger-Tang Reported-by: kernel test robot --- .../net/wireless/microchip/wilc1000/wlan.c | 56 +++++++++++-------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index c3802a34defed..86b945e5ee076 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -640,6 +640,37 @@ static u32 vmm_table_entry(struct sk_buff *tqe, u32 vm= m_sz) return cpu_to_le32(entry); } =20 +/** + * set_header() - set WILC-specific header + * @wilc: Pointer to the wilc structure. + * @tqe: The packet to add to the chip queue. + * @vmm_sz: The final size of the packet, including VMM header and padding. + * @hdr: Pointer to the header to set + */ +static void set_header(struct wilc *wilc, struct sk_buff *tqe, + u32 vmm_sz, void *hdr) +{ + struct wilc_skb_tx_cb *tx_cb =3D WILC_SKB_TX_CB(tqe); + u32 mgmt_pkt =3D 0, vmm_hdr, prio, data_len =3D tqe->len; + struct wilc_vif *vif; + + /* add the VMM header word: */ + if (tx_cb->type =3D=3D WILC_MGMT_PKT) + mgmt_pkt =3D FIELD_PREP(WILC_VMM_HDR_MGMT_FIELD, 1); + vmm_hdr =3D cpu_to_le32(mgmt_pkt | + FIELD_PREP(WILC_VMM_HDR_TYPE, tx_cb->type) | + FIELD_PREP(WILC_VMM_HDR_PKT_SIZE, data_len) | + FIELD_PREP(WILC_VMM_HDR_BUFF_SIZE, vmm_sz)); + memcpy(hdr, &vmm_hdr, 4); + + if (tx_cb->type =3D=3D WILC_NET_PKT) { + vif =3D netdev_priv(tqe->dev); + prio =3D cpu_to_le32(tx_cb->q_num); + memcpy(hdr + 4, &prio, sizeof(prio)); + memcpy(hdr + 8, vif->bssid, ETH_ALEN); + } +} + /** * fill_vmm_table() - Fill VMM table with packets to be sent * @wilc: Pointer to the wilc structure. @@ -827,7 +858,6 @@ static int copy_packets(struct wilc *wilc, int entries,= u32 *vmm_table, u8 ac_pkt_num_to_chip[NQUEUES] =3D {0, 0, 0, 0}; struct wilc_skb_tx_cb *tx_cb; u8 *txb =3D wilc->tx_buffer; - struct wilc_vif *vif; int i, vmm_sz; u32 offset; =20 @@ -835,9 +865,7 @@ static int copy_packets(struct wilc *wilc, int entries,= u32 *vmm_table, i =3D 0; do { struct sk_buff *tqe; - u32 header, buffer_offset; - char *bssid; - u8 mgmt_ptk =3D 0; + u32 buffer_offset; =20 tqe =3D skb_dequeue(&wilc->txq[vmm_entries_ac[i]]); if (!tqe) @@ -845,7 +873,6 @@ static int copy_packets(struct wilc *wilc, int entries,= u32 *vmm_table, =20 atomic_dec(&wilc->txq_entries); ac_pkt_num_to_chip[vmm_entries_ac[i]]++; - vif =3D netdev_priv(tqe->dev); tx_cb =3D WILC_SKB_TX_CB(tqe); if (vmm_table[i] =3D=3D 0) break; @@ -854,25 +881,8 @@ static int copy_packets(struct wilc *wilc, int entries= , u32 *vmm_table, vmm_sz =3D FIELD_GET(WILC_VMM_BUFFER_SIZE, vmm_table[i]); vmm_sz *=3D 4; =20 - if (tx_cb->type =3D=3D WILC_MGMT_PKT) - mgmt_ptk =3D 1; - - header =3D (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->len) | - FIELD_PREP(WILC_VMM_HDR_BUFF_SIZE, vmm_sz)); - - cpu_to_le32s(&header); - memcpy(&txb[offset], &header, 4); buffer_offset =3D tx_hdr_len(tx_cb->type); - if (tx_cb->type =3D=3D WILC_NET_PKT) { - int prio =3D tx_cb->q_num; - - bssid =3D vif->bssid; - memcpy(&txb[offset + 4], &prio, sizeof(prio)); - memcpy(&txb[offset + 8], bssid, 6); - } - + set_header(wilc, tqe, vmm_sz, txb + offset); memcpy(&txb[offset + buffer_offset], tqe->data, tqe->len); offset +=3D vmm_sz; i++; --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 1E3AEC43217 for ; Thu, 23 Dec 2021 01:16:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345794AbhLWBQp (ORCPT ); Wed, 22 Dec 2021 20:16:45 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27266 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346238AbhLWBOo (ORCPT ); Wed, 22 Dec 2021 20:14:44 -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=9K23OxmeLxKKsYp1RLhSYgHLbwb5m0KZugzfOCo69HU=; b=bb1Vo/ue+ueORZkkzBGSWycDMJPWxoZCGqaiD2IKTAgwkfVWuJDdetlhCbDe/+VxYZOY u8AY4FKVaNfHgV0BSZbqgG/GcRChN4cfMlVZaJ3CrFDVooFijVU+9xvoCzEJ0ycQkNfgH1 GVOTcpJa8V+JBWQi3V9ve/joe9qeG1+2/h0RVEgxSSVmRbY1kntR0IdlwSYO2DHGZnpUVd GvC4NBNvcb6VhGS0oZgQLxgIMwpvbfZ4sjAySCKvvTwq9XWHOmf/qDMt3SASwa+pIjKRrD bovRQVJ89AGbFKOL25UefXuABWPCoC3w5A1gZTRN7XVXd5v+39aIUWtNNy3KPp3g== Received: by filterdrecv-656998cfdd-ptszh with SMTP id filterdrecv-656998cfdd-ptszh-1-61C3CD5E-2F 2021-12-23 01:14:07.004679791 +0000 UTC m=+7955207.654607011 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-5-0 (SG) with ESMTP id qGoUxNdPTmmUnBd6fUdlpA Thu, 23 Dec 2021 01:14:06.863 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id BC8777014EA; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 38/50] wilc1000: take advantage of chip queue Date: Thu, 23 Dec 2021 01:14:07 +0000 (UTC) Message-Id: <20211223011358.4031459-39-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvBgZ7zOwzn4laz2B2?= =?us-ascii?Q?YR5jnghoHbnUyOMtWfZQXLA7QbOSeZLdzBFqeWm?= =?us-ascii?Q?DqHT1dKa0NWNHzFW9Kvr0mgeYzAt0idy+r6l7VJ?= =?us-ascii?Q?FGbV2kpWcJh6CbOnAVW2A4=2FCUqsUwzV8H=2FFkBVK?= =?us-ascii?Q?lBkCoasuy2ySw96UdcAatpRVH2DYQzaa9zWY=2F1O?= =?us-ascii?Q?GBeHOUxqtg8xjXjWHhIfg=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Rather than peeking at the access-category tx queues, move packets scheduled for transmission onto the chip queue. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/wlan.c | 102 +++++++++--------- 1 file changed, 49 insertions(+), 53 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index 86b945e5ee076..eefc0d18c1b5c 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -672,74 +672,79 @@ static void set_header(struct wilc *wilc, struct sk_b= uff *tqe, } =20 /** - * fill_vmm_table() - Fill VMM table with packets to be sent + * fill_vmm_table() - fill VMM table with packets to be sent * @wilc: Pointer to the wilc structure. * @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. * * Fill VMM table with packets waiting to be sent. The packets are * added based on access category (priority) but also balanced to * provide fairness. * - * Context: Since this function peeks at the packet queues, the - * txq_add_to_head_cs mutex must be acquired before calling this - * function. - * * 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, - u32 vmm_table[WILC_VMM_TBL_SIZE], - u8 vmm_entries_ac[WILC_VMM_TBL_SIZE]) +static int fill_vmm_table(struct wilc *wilc, + u32 vmm_table[WILC_VMM_TBL_SIZE]) { int i; u8 k, ac; - u32 sum; static const u8 ac_preserve_ratio[NQUEUES] =3D {1, 1, 1, 1}; u8 ac_desired_ratio[NQUEUES]; const u8 *num_pkts_to_add; bool ac_exist =3D 0; int vmm_sz =3D 0; - struct sk_buff *tqe_q[NQUEUES]; + struct sk_buff *tqe; struct wilc_skb_tx_cb *tx_cb; =20 - for (ac =3D 0; ac < NQUEUES; ac++) - tqe_q[ac] =3D skb_peek(&wilc->txq[ac]); - i =3D 0; - sum =3D 0; + + if (unlikely(wilc->chipq_bytes > 0)) { + /* fill in packets that are already on the chipq: */ + skb_queue_walk(&wilc->chipq, tqe) { + tx_cb =3D WILC_SKB_TX_CB(tqe); + vmm_sz =3D tx_hdr_len(tx_cb->type); + vmm_sz +=3D tqe->len; + vmm_sz =3D ALIGN(vmm_sz, 4); + vmm_table[i++] =3D vmm_table_entry(tqe, vmm_sz); + } + } =20 ac_balance(wilc, ac_desired_ratio); num_pkts_to_add =3D ac_desired_ratio; do { ac_exist =3D 0; for (ac =3D 0; ac < NQUEUES; ac++) { - if (!tqe_q[ac]) + if (skb_queue_len(&wilc->txq[ac]) < 1) continue; =20 ac_exist =3D 1; - for (k =3D 0; k < num_pkts_to_add[ac] && tqe_q[ac]; k++) { + for (k =3D 0; k < num_pkts_to_add[ac]; k++) { if (i >=3D WILC_VMM_TBL_SIZE - 1) goto out; =20 - tx_cb =3D WILC_SKB_TX_CB(tqe_q[ac]); + tqe =3D skb_dequeue(&wilc->txq[ac]); + if (!tqe) + continue; + + tx_cb =3D WILC_SKB_TX_CB(tqe); vmm_sz =3D tx_hdr_len(tx_cb->type); - vmm_sz +=3D tqe_q[ac]->len; + vmm_sz +=3D tqe->len; vmm_sz =3D ALIGN(vmm_sz, 4); =20 - if (sum + vmm_sz > WILC_TX_BUFF_SIZE) + if (wilc->chipq_bytes + vmm_sz > WILC_TX_BUFF_SIZE) { + /* return packet to its queue */ + skb_queue_head(&wilc->txq[ac], tqe); goto out; - vmm_table[i] =3D vmm_table_entry(tqe_q[ac], vmm_sz); - vmm_entries_ac[i] =3D ac; + } + atomic_dec(&wilc->txq_entries); + + __skb_queue_tail(&wilc->chipq, tqe); + wilc->chipq_bytes +=3D tqe->len; =20 + vmm_table[i] =3D vmm_table_entry(tqe, vmm_sz); i++; - sum +=3D vmm_sz; - tqe_q[ac] =3D skb_peek_next(tqe_q[ac], - &wilc->txq[ac]); + } } num_pkts_to_add =3D ac_preserve_ratio; @@ -837,14 +842,11 @@ static int send_vmm_table(struct wilc *wilc, } =20 /** - * copy_packets() - Copy packets to the transmit buffer + * copy_packets() - copy packets to the transmit buffer * @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. + * @entries: The number of packets to copy from the chip queue. * - * Copy a set of packets to the transmit buffer. + * Copy a number of packets to the transmit buffer. * * Context: The txq_add_to_head_cs mutex must still be held when * calling this function. @@ -852,8 +854,7 @@ static int send_vmm_table(struct wilc *wilc, * Return: Number of bytes copied to the transmit buffer (always * non-negative). */ -static int copy_packets(struct wilc *wilc, int entries, u32 *vmm_table, - u8 *vmm_entries_ac) +static int copy_packets(struct wilc *wilc, int entries) { u8 ac_pkt_num_to_chip[NQUEUES] =3D {0, 0, 0, 0}; struct wilc_skb_tx_cb *tx_cb; @@ -867,21 +868,19 @@ static int copy_packets(struct wilc *wilc, int entrie= s, u32 *vmm_table, struct sk_buff *tqe; u32 buffer_offset; =20 - tqe =3D skb_dequeue(&wilc->txq[vmm_entries_ac[i]]); - if (!tqe) + tqe =3D __skb_dequeue(&wilc->chipq); + if (WARN_ON(!tqe)) break; + wilc->chipq_bytes -=3D tqe->len; =20 - atomic_dec(&wilc->txq_entries); - ac_pkt_num_to_chip[vmm_entries_ac[i]]++; tx_cb =3D WILC_SKB_TX_CB(tqe); - if (vmm_table[i] =3D=3D 0) - break; - - le32_to_cpus(&vmm_table[i]); - vmm_sz =3D FIELD_GET(WILC_VMM_BUFFER_SIZE, vmm_table[i]); - vmm_sz *=3D 4; + ac_pkt_num_to_chip[tx_cb->q_num]++; =20 buffer_offset =3D tx_hdr_len(tx_cb->type); + vmm_sz =3D buffer_offset; + vmm_sz +=3D tqe->len; + vmm_sz =3D ALIGN(vmm_sz, 4); + set_header(wilc, tqe, vmm_sz, txb + offset); memcpy(&txb[offset + buffer_offset], tqe->data, tqe->len); offset +=3D vmm_sz; @@ -916,13 +915,11 @@ static int send_packets(struct wilc *wilc, int len) return func->hif_block_tx_ext(wilc, 0, wilc->tx_buffer, len); } =20 -static int copy_and_send_packets(struct wilc *wilc, int entries, - u32 vmm_table[WILC_VMM_TBL_SIZE], - u8 vmm_entries_ac[WILC_VMM_TBL_SIZE]) +static int copy_and_send_packets(struct wilc *wilc, int entries) { int len, ret; =20 - len =3D copy_packets(wilc, entries, vmm_table, vmm_entries_ac); + len =3D copy_packets(wilc, entries); if (len <=3D 0) return len; =20 @@ -935,7 +932,6 @@ static int copy_and_send_packets(struct wilc *wilc, int= entries, int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) { int vmm_table_len, entries; - u8 vmm_entries_ac[WILC_VMM_TBL_SIZE]; int ret =3D 0; u32 vmm_table[WILC_VMM_TBL_SIZE]; int srcu_idx; @@ -951,7 +947,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_co= unt) wilc_wlan_txq_filter_dup_tcp_ack(vif->ndev); srcu_read_unlock(&wilc->srcu, srcu_idx); =20 - vmm_table_len =3D fill_vmm_table(wilc, vmm_table, vmm_entries_ac); + vmm_table_len =3D fill_vmm_table(wilc, vmm_table); if (vmm_table_len =3D=3D 0) goto out_unlock; =20 @@ -966,7 +962,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_co= unt) if (entries <=3D 0) { ret =3D entries; } else { - ret =3D copy_and_send_packets(wilc, entries, vmm_table, vmm_entries_ac); + ret =3D copy_and_send_packets(wilc, entries); } if (ret >=3D 0 && entries < vmm_table_len) ret =3D WILC_VMM_ENTRY_FULL_RETRY; --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 3FBC2C433F5 for ; Thu, 23 Dec 2021 01:16:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346813AbhLWBQV (ORCPT ); Wed, 22 Dec 2021 20:16:21 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27412 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346264AbhLWBOx (ORCPT ); Wed, 22 Dec 2021 20:14:53 -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=ZdHnC/ICI6OpSU7qfH1VoVrAfvudFBK6XDLPwhLw7Ms=; b=HGyIzW+DINtndUkhBAmxAdHPUVDc57ZO/oYi2UkXxu85I8JQtt34MYLD0NMZHPIVckkZ V7mYn94sr8w/cP+YtXDXPNcVzMrkgLaAaDqYFR+fqyYNPZNjxxNtJUNIDDNxoackTk7K8t dc1Ly+m7uL9IYpvHvk6R8i8ySCXwslfqWUzV/ElsloVn07YhUc0gGgfvGh217fnlYAJNDn K/8wyk8Aj5O7JBfM6/W7T7Nnjq9TOIG3pmSZlNKwLdNj0a8qvOs3MXc/HxFsjHy/wY2QZt qDAMgE9BMfAxJFyLMJXVbVQewcjVqharPb5gPCbHExXbcv4Wj/HXu7KhtFY81KOQ== Received: by filterdrecv-7bf5c69d5-plqrp with SMTP id filterdrecv-7bf5c69d5-plqrp-1-61C3CD5E-4E 2021-12-23 01:14:07.00162435 +0000 UTC m=+9687195.598538133 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-2-1 (SG) with ESMTP id _HdNEz2_QZ6cJ9OC_17EnQ Thu, 23 Dec 2021 01:14:06.873 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id BFD7D7014F5; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 39/50] wilc1000: eliminate txq_add_to_head_cs mutex Date: Thu, 23 Dec 2021 01:14:07 +0000 (UTC) Message-Id: <20211223011358.4031459-40-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvMTg55MYAqxjZd=2FNY?= =?us-ascii?Q?MBupDVuLv7j=2F03Wcbcz16=2FVnnLJEBfaOIbI=2FU3u?= =?us-ascii?Q?bx1XABWR3g1bZkHu+ef6gWQG5mjxORSzd8MImbN?= =?us-ascii?Q?N6ZJomAvj334eDkz6ZQGZI5DxKrOJEVemDwuKaz?= =?us-ascii?Q?tEAH0VUwl7sCZzBOGlCCYiqlUXcMOdUKINRcJuW?= =?us-ascii?Q?i3ctaET=2FnV5azqYg57pKw=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Since the tx queue handler is no longer peeking at the transmit queues, we don't need this mutex anymore. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/cfg80211.c | 2 -- drivers/net/wireless/microchip/wilc1000/netdev.h | 3 --- drivers/net/wireless/microchip/wilc1000/wlan.c | 13 +------------ 3 files changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.c b/drivers/n= et/wireless/microchip/wilc1000/cfg80211.c index 6d3635864569f..d87358ca71cf9 100644 --- a/drivers/net/wireless/microchip/wilc1000/cfg80211.c +++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.c @@ -1670,7 +1670,6 @@ static void wlan_init_locks(struct wilc *wl) mutex_init(&wl->vif_mutex); mutex_init(&wl->deinit_lock); =20 - mutex_init(&wl->txq_add_to_head_cs); mutex_init(&wl->tx_q_limit_lock); =20 init_waitqueue_head(&wl->txq_event); @@ -1685,7 +1684,6 @@ void wlan_deinit_locks(struct wilc *wilc) mutex_destroy(&wilc->hif_cs); mutex_destroy(&wilc->rxq_cs); mutex_destroy(&wilc->cfg_cmd_lock); - mutex_destroy(&wilc->txq_add_to_head_cs); mutex_destroy(&wilc->vif_mutex); mutex_destroy(&wilc->deinit_lock); mutex_destroy(&wilc->tx_q_limit_lock); diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h b/drivers/net= /wireless/microchip/wilc1000/netdev.h index e168f8644c678..086b9273bb117 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.h +++ b/drivers/net/wireless/microchip/wilc1000/netdev.h @@ -225,9 +225,6 @@ struct wilc { struct srcu_struct srcu; u8 open_ifcs; =20 - /* protect head of transmit queue */ - struct mutex txq_add_to_head_cs; - /* protect rxq_entry_t receiver queue */ struct mutex rxq_cs; =20 diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index eefc0d18c1b5c..67f5293370d35 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -70,12 +70,9 @@ static void wilc_wlan_txq_add_to_head(struct wilc_vif *v= if, u8 type, u8 q_num, =20 init_txq_entry(tqe, type, q_num); =20 - mutex_lock(&wilc->txq_add_to_head_cs); - skb_queue_head(&wilc->txq[q_num], tqe); atomic_inc(&wilc->txq_entries); =20 - mutex_unlock(&wilc->txq_add_to_head_cs); wake_up_interruptible(&wilc->txq_event); } =20 @@ -848,9 +845,6 @@ static int send_vmm_table(struct wilc *wilc, * * Copy a number of packets to the transmit buffer. * - * Context: The txq_add_to_head_cs mutex must still be held when - * calling this function. - * * Return: Number of bytes copied to the transmit buffer (always * non-negative). */ @@ -940,8 +934,6 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_co= unt) if (wilc->quit) goto out_update_cnt; =20 - mutex_lock(&wilc->txq_add_to_head_cs); - srcu_idx =3D srcu_read_lock(&wilc->srcu); list_for_each_entry_rcu(vif, &wilc->vif_list, list) wilc_wlan_txq_filter_dup_tcp_ack(vif->ndev); @@ -949,7 +941,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_co= unt) =20 vmm_table_len =3D fill_vmm_table(wilc, vmm_table); if (vmm_table_len =3D=3D 0) - goto out_unlock; + goto out_update_cnt; =20 acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); =20 @@ -967,9 +959,6 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_co= unt) if (ret >=3D 0 && entries < vmm_table_len) ret =3D WILC_VMM_ENTRY_FULL_RETRY; =20 -out_unlock: - mutex_unlock(&wilc->txq_add_to_head_cs); - out_update_cnt: *txq_count =3D atomic_read(&wilc->txq_entries); return ret; --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 76743C43219 for ; Thu, 23 Dec 2021 01:16:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346783AbhLWBQT (ORCPT ); Wed, 22 Dec 2021 20:16:19 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27422 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346263AbhLWBOy (ORCPT ); Wed, 22 Dec 2021 20:14:54 -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=HXaP0alwXTa+EUaGACQmixi4C0QDifAyWeipd/C364U=; b=SNp27uMOGIAxB3Rg0Io+eW/LkRik1tfEtBcYaHE08DmgMTAgDHrb2m3XbN4Uf41YTFES gNf4zp/MmowjRXFPPRn7GJdq3HTjDfMR0TLmA1/I2W4YSbUEsK/IHI0xsG/x6DVU1wK5ID rF0EG9fuBKCazZFpsllfaWr2DmQSPDlF8m/Ajo7sK3w0WTolQlyl9JtCpKkKIQlBFX3zKg g+jX2rkSvSsRT8fYu0CufKKMw08NU4M0It+ZnLi7BRiZtv7CO8ZduDwHB4qHAlHdj5JBq9 fYcGBA0JwnUPFefMOqb/zWBGsl1lo/cGJenxnd3T6c95xgBi3+FLfkCGmedIeFuQ== Received: by filterdrecv-7bf5c69d5-v7fwm with SMTP id filterdrecv-7bf5c69d5-v7fwm-1-61C3CD5E-46 2021-12-23 01:14:07.013080821 +0000 UTC m=+9687233.251367922 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-1-1 (SG) with ESMTP id Fs4muI52RmC81AQUs-BOJQ Thu, 23 Dec 2021 01:14:06.863 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id C26E2701501; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 40/50] wilc1000: introduce schedule_packets() function Date: Thu, 23 Dec 2021 01:14:07 +0000 (UTC) Message-Id: <20211223011358.4031459-41-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvMOna4O64C+EU0IbF?= =?us-ascii?Q?+d1EnOG7clc59szXsBOdaG1ztylnbJHADMhMEtQ?= =?us-ascii?Q?p2I=2FxpqLi9YzOWNpcnRckNLLmFj7jbC9J0xuuR=2F?= =?us-ascii?Q?SiFjRfp9lLTFQWhqE0B7hIwOK4vRVe9pgCrPetz?= =?us-ascii?Q?Wevl99UBukZO2hr9CtZZRe42Q8DiAuEGgTpGEK9?= =?us-ascii?Q?eIUDHok9WYhzxohq6oHbQ=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Move the packet scheduling code in its own function for improved readability. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/wlan.c | 78 ++++++++++++------- 1 file changed, 50 insertions(+), 28 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index 67f5293370d35..f01f7bade6189 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -669,22 +669,20 @@ static void set_header(struct wilc *wilc, struct sk_b= uff *tqe, } =20 /** - * fill_vmm_table() - fill VMM table with packets to be sent + * schedule_packets() - schedule packets for transmission * @wilc: Pointer to the wilc structure. + * @vmm_table_len: Current length of the VMM table. * @vmm_table: Pointer to the VMM table to fill. * - * Fill VMM table with packets waiting to be sent. The packets are - * added based on access category (priority) but also balanced to - * provide fairness. - * - * 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. + * Schedule packets from the access-category queues for transmission. + * The scheduling is primarily in order of priority, but also takes + * fairness into account. As many packets as possible are moved to + * the chip queue. The chip queue has space for up to + * WILC_VMM_TBL_SIZE packets or up to WILC_TX_BUFF_SIZE bytes. */ -static int fill_vmm_table(struct wilc *wilc, - u32 vmm_table[WILC_VMM_TBL_SIZE]) +static int schedule_packets(struct wilc *wilc, + int i, u32 vmm_table[WILC_VMM_TBL_SIZE]) { - int i; u8 k, ac; static const u8 ac_preserve_ratio[NQUEUES] =3D {1, 1, 1, 1}; u8 ac_desired_ratio[NQUEUES]; @@ -694,19 +692,6 @@ static int fill_vmm_table(struct wilc *wilc, struct sk_buff *tqe; struct wilc_skb_tx_cb *tx_cb; =20 - i =3D 0; - - if (unlikely(wilc->chipq_bytes > 0)) { - /* fill in packets that are already on the chipq: */ - skb_queue_walk(&wilc->chipq, tqe) { - tx_cb =3D WILC_SKB_TX_CB(tqe); - vmm_sz =3D tx_hdr_len(tx_cb->type); - vmm_sz +=3D tqe->len; - vmm_sz =3D ALIGN(vmm_sz, 4); - vmm_table[i++] =3D vmm_table_entry(tqe, vmm_sz); - } - } - ac_balance(wilc, ac_desired_ratio); num_pkts_to_add =3D ac_desired_ratio; do { @@ -718,7 +703,7 @@ static int fill_vmm_table(struct wilc *wilc, ac_exist =3D 1; for (k =3D 0; k < num_pkts_to_add[ac]; k++) { if (i >=3D WILC_VMM_TBL_SIZE - 1) - goto out; + return i; =20 tqe =3D skb_dequeue(&wilc->txq[ac]); if (!tqe) @@ -732,7 +717,7 @@ static int fill_vmm_table(struct wilc *wilc, if (wilc->chipq_bytes + vmm_sz > WILC_TX_BUFF_SIZE) { /* return packet to its queue */ skb_queue_head(&wilc->txq[ac], tqe); - goto out; + return i; } atomic_dec(&wilc->txq_entries); =20 @@ -746,8 +731,45 @@ static int fill_vmm_table(struct wilc *wilc, } num_pkts_to_add =3D ac_preserve_ratio; } while (ac_exist); -out: - vmm_table[i] =3D 0x0; + return i; +} + +/** + * fill_vmm_table() - fill VMM table with packets to be sent + * @wilc: Pointer to the wilc structure. + * @vmm_table: Pointer to the VMM table to fill. + * + * Fill VMM table with packets waiting to be sent. + * + * 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(struct wilc *wilc, u32 vmm_table[WILC_VMM_TBL_SI= ZE]) +{ + int i; + int vmm_sz =3D 0; + struct sk_buff *tqe; + struct wilc_skb_tx_cb *tx_cb; + + i =3D 0; + + if (unlikely(wilc->chipq_bytes > 0)) { + /* fill in packets that are already on the chipq: */ + skb_queue_walk(&wilc->chipq, tqe) { + tx_cb =3D WILC_SKB_TX_CB(tqe); + vmm_sz =3D tx_hdr_len(tx_cb->type); + vmm_sz +=3D tqe->len; + vmm_sz =3D ALIGN(vmm_sz, 4); + vmm_table[i++] =3D vmm_table_entry(tqe, vmm_sz); + } + } + + i =3D schedule_packets(wilc, i, vmm_table); + if (i > 0) { + WARN_ON(i >=3D WILC_VMM_TBL_SIZE); + vmm_table[i] =3D 0x0; + } return i; } =20 --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 7D2F6C433EF for ; Thu, 23 Dec 2021 01:16:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346714AbhLWBQE (ORCPT ); Wed, 22 Dec 2021 20:16:04 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27304 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346229AbhLWBOn (ORCPT ); Wed, 22 Dec 2021 20:14:43 -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=3Uz4xO2jk3PwsoBap/NCYCWsUTTJtakQF5q2JJp4lHQ=; b=AZzNDwI6isj4Br0GlK+kU9dM02F55UA7gnqhdWD4g8J9QC8JK5gEL8nqvU30FKtTH49i NSw1KGcWfQOGA6WrxwehnMkuTcELkuhfmyefoefLBvWE8H8C9g3zI6qunfFcje3ESFh+is 0nX4c6szL6ltEyjbImHFOT7Uoi7/3YZ7D5Wz3p5PJVqUCheDVgkPrEd9SwH7QjuryPS1pn SQM/GiZHMfnD0rqlnpcHOtg3IqPsbkbUSP7KTY4rm6honUjP9v0kMWvSgrqc/29aIsCmui ICFxsO7sEc2wao74pm2osw1hddjyx5g+Mb2B5P4Ui4DRYXJ1TdE0/ij+1QXT/JgQ== Received: by filterdrecv-656998cfdd-ngmx2 with SMTP id filterdrecv-656998cfdd-ngmx2-1-61C3CD5E-3B 2021-12-23 01:14:07.038024374 +0000 UTC m=+7955207.334259020 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-6-0 (SG) with ESMTP id qOYqVE5dTvSY-kPoDwTdQg Thu, 23 Dec 2021 01:14:06.874 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id C5063701508; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 41/50] wilc1000: use more descriptive variable name Date: Thu, 23 Dec 2021 01:14:07 +0000 (UTC) Message-Id: <20211223011358.4031459-42-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvPuMcF=2FBHm6zz5zzm?= =?us-ascii?Q?psOhjqu7S67FdJWIs8jvoN5AmbDIi6dQ8lNtN54?= =?us-ascii?Q?xxhDmyuQ276OPAzpKlpaoXNFiJAEfxrg0c8r9Es?= =?us-ascii?Q?O9Da3SIjzbjjQ8jb98tgTlDIsTp9my0W9+3Zgj2?= =?us-ascii?Q?9nrdu9XXNulAcIA2sS3c44Jpiv0L0N5xQ6p0eZB?= =?us-ascii?Q?7Q2o2N=2FSrKN2CK=2F3Fk4nw=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Now that the factoring is done, again rename "i" to "vmm_table_len" to improve readability. 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/w= ireless/microchip/wilc1000/wlan.c index f01f7bade6189..f89ea4839aa61 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -681,7 +681,7 @@ static void set_header(struct wilc *wilc, struct sk_buf= f *tqe, * WILC_VMM_TBL_SIZE packets or up to WILC_TX_BUFF_SIZE bytes. */ static int schedule_packets(struct wilc *wilc, - int i, u32 vmm_table[WILC_VMM_TBL_SIZE]) + int vmm_table_len, u32 vmm_table[WILC_VMM_TBL_SIZE]) { u8 k, ac; static const u8 ac_preserve_ratio[NQUEUES] =3D {1, 1, 1, 1}; @@ -702,8 +702,8 @@ static int schedule_packets(struct wilc *wilc, =20 ac_exist =3D 1; for (k =3D 0; k < num_pkts_to_add[ac]; k++) { - if (i >=3D WILC_VMM_TBL_SIZE - 1) - return i; + if (vmm_table_len >=3D WILC_VMM_TBL_SIZE - 1) + return vmm_table_len; =20 tqe =3D skb_dequeue(&wilc->txq[ac]); if (!tqe) @@ -717,21 +717,21 @@ static int schedule_packets(struct wilc *wilc, if (wilc->chipq_bytes + vmm_sz > WILC_TX_BUFF_SIZE) { /* return packet to its queue */ skb_queue_head(&wilc->txq[ac], tqe); - return i; + return vmm_table_len; } atomic_dec(&wilc->txq_entries); =20 __skb_queue_tail(&wilc->chipq, tqe); wilc->chipq_bytes +=3D tqe->len; =20 - vmm_table[i] =3D vmm_table_entry(tqe, vmm_sz); - i++; + vmm_table[vmm_table_len] =3D vmm_table_entry(tqe, vmm_sz); + vmm_table_len++; =20 } } num_pkts_to_add =3D ac_preserve_ratio; } while (ac_exist); - return i; + return vmm_table_len; } =20 /** @@ -747,13 +747,10 @@ static int schedule_packets(struct wilc *wilc, */ static int fill_vmm_table(struct wilc *wilc, u32 vmm_table[WILC_VMM_TBL_SI= ZE]) { - int i; - int vmm_sz =3D 0; + int vmm_table_len =3D 0, vmm_sz =3D 0; struct sk_buff *tqe; struct wilc_skb_tx_cb *tx_cb; =20 - i =3D 0; - if (unlikely(wilc->chipq_bytes > 0)) { /* fill in packets that are already on the chipq: */ skb_queue_walk(&wilc->chipq, tqe) { @@ -761,16 +758,16 @@ static int fill_vmm_table(struct wilc *wilc, u32 vmm_= table[WILC_VMM_TBL_SIZE]) vmm_sz =3D tx_hdr_len(tx_cb->type); vmm_sz +=3D tqe->len; vmm_sz =3D ALIGN(vmm_sz, 4); - vmm_table[i++] =3D vmm_table_entry(tqe, vmm_sz); + vmm_table[vmm_table_len++] =3D vmm_table_entry(tqe, vmm_sz); } } =20 - i =3D schedule_packets(wilc, i, vmm_table); - if (i > 0) { - WARN_ON(i >=3D WILC_VMM_TBL_SIZE); - vmm_table[i] =3D 0x0; + vmm_table_len =3D schedule_packets(wilc, vmm_table_len, vmm_table); + if (vmm_table_len > 0) { + WARN_ON(vmm_table_len >=3D WILC_VMM_TBL_SIZE); + vmm_table[vmm_table_len] =3D 0x0; } - return i; + return vmm_table_len; } =20 /** --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 A3497C433EF for ; Thu, 23 Dec 2021 01:16:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346937AbhLWBQs (ORCPT ); Wed, 22 Dec 2021 20:16:48 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27310 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346233AbhLWBOo (ORCPT ); Wed, 22 Dec 2021 20:14:44 -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=dfBeb34NhlQx9kSnwdfVLwJrGwUjal6SLB3oVtZbo4E=; b=TWgM3B+/1zIiBki4SbXmfYuLUWEujlY5xWduxlkRk2mazS4YvgyERmULCarpZ/CbweMb EViiHe2U3LSwRagfjO1Ump67NEbfkNwbDekK9wuO1FN189EB45sF1UUSJSd7JusKGsZyE+ RFgm2gYF8U8OLo5V9sPcfAR1SqZNVfT9f56BqGV2s0AcYYncjS2pw6qqUZizGr+B+asNci P/4Xnogo9K6IinHEnNQwT1oeTKjyo01jxo32kpk/mnV4WWijqTDVnAg6Y2VvyyY2LwGnGP ZTRCYWn9YNr10qS7Cr5Gz3zgU9Ad2BXbQS6AZeJtYaWpeGyyY344yGXfJdu5mzjw== Received: by filterdrecv-64fcb979b9-ds7qn with SMTP id filterdrecv-64fcb979b9-ds7qn-1-61C3CD5E-32 2021-12-23 01:14:07.03458828 +0000 UTC m=+8644641.963188758 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-6-0 (SG) with ESMTP id -51l937fQTCZaa8cFnq3Fw Thu, 23 Dec 2021 01:14:06.874 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id C7CF770150C; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 42/50] wilc1000: simplify code by adding header/padding to skb Date: Thu, 23 Dec 2021 01:14:07 +0000 (UTC) Message-Id: <20211223011358.4031459-43-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvJwCYg8sr53xntpFM?= =?us-ascii?Q?RamCYBsHW6iylotlCCb9egN=2FBBDuQ1z=2FxYKvh6c?= =?us-ascii?Q?ntcV6X5h9Sln5AMVFLh=2FTmorjPALjoRaSSjxJvm?= =?us-ascii?Q?aplVPjw5TVEPU8gQeh3FSdPy4eIpIreJxPcZVyf?= =?us-ascii?Q?B9DGV0x9k1SL68sIHRoSku+9iiPLbBVlY3KE+HJ?= =?us-ascii?Q?HW2KH5878VOWkpFrw0Guw=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When a packet is moved to the chip queue, push the header and add necessary padding to the socket-buffer directly. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/netdev.c | 4 ++ .../net/wireless/microchip/wilc1000/wlan.c | 65 +++++++++---------- 2 files changed, 33 insertions(+), 36 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c b/drivers/net= /wireless/microchip/wilc1000/netdev.c index 71cb15f042cdd..d9fbff4bfcd30 100644 --- a/drivers/net/wireless/microchip/wilc1000/netdev.c +++ b/drivers/net/wireless/microchip/wilc1000/netdev.c @@ -924,6 +924,10 @@ struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl,= const char *name, if (!ndev) return ERR_PTR(-ENOMEM); =20 + ndev->needed_headroom =3D ETH_CONFIG_PKT_HDR_OFFSET; + /* we may need up to 3 bytes of padding: */ + ndev->needed_tailroom =3D 3; + vif =3D netdev_priv(ndev); ndev->ieee80211_ptr =3D &vif->priv.wdev; strcpy(ndev->name, name); diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index f89ea4839aa61..08f3e96bf72cf 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -626,30 +626,39 @@ static u32 tx_hdr_len(u8 type) } } =20 -static u32 vmm_table_entry(struct sk_buff *tqe, u32 vmm_sz) +static u32 vmm_table_entry(struct sk_buff *tqe) { struct wilc_skb_tx_cb *tx_cb =3D WILC_SKB_TX_CB(tqe); u32 entry; =20 - entry =3D vmm_sz / 4; + entry =3D tqe->len / 4; if (tx_cb->type =3D=3D WILC_CFG_PKT) entry |=3D WILC_VMM_CFG_PKT; return cpu_to_le32(entry); } =20 /** - * set_header() - set WILC-specific header + * add_hdr_and_pad() - prepare a packet for the chip queue * @wilc: Pointer to the wilc structure. * @tqe: The packet to add to the chip queue. + * @hdr_len: The size of the header to add. * @vmm_sz: The final size of the packet, including VMM header and padding. - * @hdr: Pointer to the header to set + * + * Bring a packet into the form required by the chip by adding a + * header and padding as needed. */ -static void set_header(struct wilc *wilc, struct sk_buff *tqe, - u32 vmm_sz, void *hdr) +static void add_hdr_and_pad(struct wilc *wilc, struct sk_buff *tqe, + u32 hdr_len, u32 vmm_sz) { struct wilc_skb_tx_cb *tx_cb =3D WILC_SKB_TX_CB(tqe); u32 mgmt_pkt =3D 0, vmm_hdr, prio, data_len =3D tqe->len; struct wilc_vif *vif; + void *hdr; + + /* grow skb with header and pad bytes, all initialized to 0: */ + hdr =3D skb_push(tqe, hdr_len); + if (vmm_sz > tqe->len) + skb_put(tqe, vmm_sz - tqe->len); =20 /* add the VMM header word: */ if (tx_cb->type =3D=3D WILC_MGMT_PKT) @@ -687,8 +696,8 @@ static int schedule_packets(struct wilc *wilc, static const u8 ac_preserve_ratio[NQUEUES] =3D {1, 1, 1, 1}; u8 ac_desired_ratio[NQUEUES]; const u8 *num_pkts_to_add; + u32 vmm_sz, hdr_len; bool ac_exist =3D 0; - int vmm_sz =3D 0; struct sk_buff *tqe; struct wilc_skb_tx_cb *tx_cb; =20 @@ -710,8 +719,8 @@ static int schedule_packets(struct wilc *wilc, continue; =20 tx_cb =3D WILC_SKB_TX_CB(tqe); - vmm_sz =3D tx_hdr_len(tx_cb->type); - vmm_sz +=3D tqe->len; + hdr_len =3D tx_hdr_len(tx_cb->type); + vmm_sz =3D hdr_len + tqe->len; vmm_sz =3D ALIGN(vmm_sz, 4); =20 if (wilc->chipq_bytes + vmm_sz > WILC_TX_BUFF_SIZE) { @@ -721,12 +730,13 @@ static int schedule_packets(struct wilc *wilc, } atomic_dec(&wilc->txq_entries); =20 + add_hdr_and_pad(wilc, tqe, hdr_len, vmm_sz); + __skb_queue_tail(&wilc->chipq, tqe); wilc->chipq_bytes +=3D tqe->len; =20 - vmm_table[vmm_table_len] =3D vmm_table_entry(tqe, vmm_sz); + vmm_table[vmm_table_len] =3D vmm_table_entry(tqe); vmm_table_len++; - } } num_pkts_to_add =3D ac_preserve_ratio; @@ -747,20 +757,13 @@ static int schedule_packets(struct wilc *wilc, */ static int fill_vmm_table(struct wilc *wilc, u32 vmm_table[WILC_VMM_TBL_SI= ZE]) { - int vmm_table_len =3D 0, vmm_sz =3D 0; + int vmm_table_len =3D 0; struct sk_buff *tqe; - struct wilc_skb_tx_cb *tx_cb; =20 - if (unlikely(wilc->chipq_bytes > 0)) { + if (unlikely(wilc->chipq_bytes > 0)) /* fill in packets that are already on the chipq: */ - skb_queue_walk(&wilc->chipq, tqe) { - tx_cb =3D WILC_SKB_TX_CB(tqe); - vmm_sz =3D tx_hdr_len(tx_cb->type); - vmm_sz +=3D tqe->len; - vmm_sz =3D ALIGN(vmm_sz, 4); - vmm_table[vmm_table_len++] =3D vmm_table_entry(tqe, vmm_sz); - } - } + skb_queue_walk(&wilc->chipq, tqe) + vmm_table[vmm_table_len++] =3D vmm_table_entry(tqe); =20 vmm_table_len =3D schedule_packets(wilc, vmm_table_len, vmm_table); if (vmm_table_len > 0) { @@ -872,15 +875,12 @@ static int copy_packets(struct wilc *wilc, int entrie= s) u8 ac_pkt_num_to_chip[NQUEUES] =3D {0, 0, 0, 0}; struct wilc_skb_tx_cb *tx_cb; u8 *txb =3D wilc->tx_buffer; - int i, vmm_sz; + int i; + struct sk_buff *tqe; u32 offset; =20 offset =3D 0; - i =3D 0; do { - struct sk_buff *tqe; - u32 buffer_offset; - tqe =3D __skb_dequeue(&wilc->chipq); if (WARN_ON(!tqe)) break; @@ -889,15 +889,8 @@ static int copy_packets(struct wilc *wilc, int entries) tx_cb =3D WILC_SKB_TX_CB(tqe); ac_pkt_num_to_chip[tx_cb->q_num]++; =20 - buffer_offset =3D tx_hdr_len(tx_cb->type); - vmm_sz =3D buffer_offset; - vmm_sz +=3D tqe->len; - vmm_sz =3D ALIGN(vmm_sz, 4); - - set_header(wilc, tqe, vmm_sz, txb + offset); - memcpy(&txb[offset + buffer_offset], tqe->data, tqe->len); - offset +=3D vmm_sz; - i++; + memcpy(&txb[offset], tqe->data, tqe->len); + offset +=3D tqe->len; wilc_wlan_tx_packet_done(tqe, 1); } while (--entries); for (i =3D 0; i < NQUEUES; i++) --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 2330AC433FE for ; Thu, 23 Dec 2021 01:16:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346410AbhLWBQA (ORCPT ); Wed, 22 Dec 2021 20:16:00 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27288 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346231AbhLWBOm (ORCPT ); Wed, 22 Dec 2021 20:14:42 -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=DlCBRu7J1bxJ3/LQJt36l7jN/7IIPnFkxtrjOj9W9fc=; b=RktnbaWJYD0OqoDLrEerbGVsR3Dr+51Mjfx2woNob8Pdz3cneHipQRZwJrRZc9OyHBzE MgABOY16CKah7tXtvTk16MJ9LRGXQozIf5v/FmnVO2Ti5BuQd+O4BRde1v5RNHplHDALrK WB4T6PAIuG9B/Xepe/qA2bXxlj9MIC4KJRxKMOICp8cjmrv50TKxmL3yDurQNlb5MVNBfK /DLnSsSTEJo+OvFrKXvZZmVydSU+9qeSR2AS5yDabnb/i7/wfJksS9Ko7pO3w8I2+Ln8Xj R+bQT+YvCL/u7yJ8I7F7k49zY6AN6aUiXVAjyCvsvnX671Y8fZ4afb4Vx6O0Bljg== Received: by filterdrecv-656998cfdd-5st9z with SMTP id filterdrecv-656998cfdd-5st9z-1-61C3CD5F-2 2021-12-23 01:14:07.066588987 +0000 UTC m=+7955191.029031746 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-5-1 (SG) with ESMTP id LkEsxIgnSluBVp_O0u0jcw Thu, 23 Dec 2021 01:14:06.903 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id D1C3570150D; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 43/50] wilc1000: add support for zero-copy transmit of tx packets Date: Thu, 23 Dec 2021 01:14:07 +0000 (UTC) Message-Id: <20211223011358.4031459-44-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvCpc2ftgM2qu67NNB?= =?us-ascii?Q?uHZcfjZzUnbiHUNZbafQh3Mqs3rJrxKIhGH79qo?= =?us-ascii?Q?89Du1mpWVV3Bd5CTB5MIKKbipe9JjI8qjmO70lT?= =?us-ascii?Q?zO5hcqe9PGUOdYeozSzqN=2F1AmHyXEo5IQe4ax8Y?= =?us-ascii?Q?OABy9Pt6aATgSuuuXbekPr8jzLOd9L3wyRioUE4?= =?us-ascii?Q?+vhIbxolesMtmD8=2F3QfdQ=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add the infrastructure to enable zero-copy transmits. This is currently a no-op as the SPI or SDIO drivers will need to implement hif_sk_buffs_tx to take advantage of this. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/wlan.c | 43 ++++++++++++++++++- .../net/wireless/microchip/wilc1000/wlan.h | 2 + 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index 08f3e96bf72cf..d96a7e2a0bd59 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -935,6 +935,44 @@ static int copy_and_send_packets(struct wilc *wilc, in= t entries) return ret; } =20 +/** + * zero_copy_send_packets() - send packets to the chip (copy-free). + * @wilc: Pointer to the wilc structure. + * @entries: The number of packets to send from the VMM table. + * + * Zero-copy version of sending the packets in the VMM table to the + * chip. + * + * Context: The wilc1000 bus must have been released but the chip + * must be awake. + * + * Return: Negative number on error, 0 on success. + */ +static int zero_copy_send_packets(struct wilc *wilc, int entries) +{ + const struct wilc_hif_func *func =3D wilc->hif_func; + struct wilc_skb_tx_cb *tx_cb; + struct sk_buff *tqe; + int ret, i =3D 0; + + acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); + + ret =3D func->hif_clear_int_ext(wilc, ENABLE_TX_VMM); + if (ret =3D=3D 0) + ret =3D func->hif_sk_buffs_tx(wilc, 0, entries, &wilc->chipq); + + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); + + for (i =3D 0; i < entries; ++i) { + tqe =3D __skb_dequeue(&wilc->chipq); + tx_cb =3D WILC_SKB_TX_CB(tqe); + wilc->fw[tx_cb->q_num].count++; + wilc->chipq_bytes -=3D tqe->len; + wilc_wlan_tx_packet_done(tqe, ret =3D=3D 0); + } + return ret; +} + int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) { int vmm_table_len, entries; @@ -966,7 +1004,10 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_= count) if (entries <=3D 0) { ret =3D entries; } else { - ret =3D copy_and_send_packets(wilc, entries); + if (wilc->hif_func->hif_sk_buffs_tx) + ret =3D zero_copy_send_packets(wilc, entries); + else + ret =3D copy_and_send_packets(wilc, entries); } if (ret >=3D 0 && entries < vmm_table_len) ret =3D WILC_VMM_ENTRY_FULL_RETRY; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/w= ireless/microchip/wilc1000/wlan.h index 11a54320ffd05..bda31f0970bda 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.h +++ b/drivers/net/wireless/microchip/wilc1000/wlan.h @@ -367,6 +367,8 @@ struct wilc_hif_func { int (*hif_read_size)(struct wilc *wilc, u32 *size); int (*hif_block_tx_ext)(struct wilc *wilc, u32 addr, u8 *buf, u32 size); int (*hif_block_rx_ext)(struct wilc *wilc, u32 addr, u8 *buf, u32 size); + int (*hif_sk_buffs_tx)(struct wilc *wilc, u32 addr, + size_t num_skbs, struct sk_buff_head *skbs); int (*hif_sync_ext)(struct wilc *wilc, int nint); int (*enable_interrupt)(struct wilc *nic); void (*disable_interrupt)(struct wilc *nic); --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 7E34BC433EF for ; Thu, 23 Dec 2021 01:15:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242168AbhLWBP6 (ORCPT ); Wed, 22 Dec 2021 20:15:58 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27278 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346223AbhLWBOm (ORCPT ); Wed, 22 Dec 2021 20:14:42 -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=lHfpOqhOfpDOCfOX9m8HbTSH198YL4xz6udBaxMWEhU=; b=He/CxrgZEFngolwjXHMJWEKjUhKIOSVokvqKUvxw4wiwguybmmU9i+segEnZplKOvvAG 5jmo4LObHAT+dvq7TfL61pUedZuzA7xhnxG9Yn6r5PRe2IgXT7UISNbitqvuozqKZmImf7 iimBVGIlEBTWSA5uCU57sYi2VtMP5BN//v1fvoU+KWrLQzm10T13c+t/adNTE4aITX7LTh B+8GmGlr0SOSWfl4f0hs8xcK6UAyYy71iptESF+BUtz7P5CBGJYLylyC15jowYBKtpqs2o 2g12eiVTJOVDT2YOcE+QWqGq5uO6lDsiOTqBbdpHenorb0i7f8cPtSbCxQ4vuE1w== Received: by filterdrecv-656998cfdd-gwqfx with SMTP id filterdrecv-656998cfdd-gwqfx-1-61C3CD5F-2 2021-12-23 01:14:07.065548949 +0000 UTC m=+7955180.472261611 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-4-0 (SG) with ESMTP id jn2DgsfWQie8Tv6IdcNhoA Thu, 23 Dec 2021 01:14:06.899 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id DAF3270150E; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 44/50] wilc1000: don't allocate tx_buffer when zero-copy is available Date: Thu, 23 Dec 2021 01:14:07 +0000 (UTC) Message-Id: <20211223011358.4031459-45-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvCku2d01bUPHXOooM?= =?us-ascii?Q?P+=2FUf3qjDaNo4LbXVJ1cRCS8pJYe4aPxCLVg3LP?= =?us-ascii?Q?M7wKTY3qogKRr+YpQH0519OH2M8hpB54iw3Xliv?= =?us-ascii?Q?7NRVCjYht7AX+HB1hqNDi6F43cGXXsX0q3Ov8yJ?= =?us-ascii?Q?ZxZHVy156avRLeJRAoHRG2QDKUQ+QKajLrAgapC?= =?us-ascii?Q?2voZ6btNWDr4NVuHxJCog=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" If a driver supports zero-copy transmit transfers, there is no need to have a transmit buffer. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/w= ireless/microchip/wilc1000/wlan.c index d96a7e2a0bd59..d46d6e8122c8d 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -1604,12 +1604,12 @@ int wilc_wlan_init(struct net_device *dev) =20 init_q_limits(wilc); =20 - if (!wilc->tx_buffer) + if (!wilc->hif_func->hif_sk_buffs_tx && !wilc->tx_buffer) { wilc->tx_buffer =3D kmalloc(WILC_TX_BUFF_SIZE, GFP_KERNEL); - - if (!wilc->tx_buffer) { - ret =3D -ENOBUFS; - goto fail; + if (!wilc->tx_buffer) { + ret =3D -ENOBUFS; + goto fail; + } } =20 if (!wilc->rx_buffer) --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 9A514C433F5 for ; Thu, 23 Dec 2021 01:16:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346929AbhLWBQj (ORCPT ); Wed, 22 Dec 2021 20:16:39 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27358 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346243AbhLWBOp (ORCPT ); Wed, 22 Dec 2021 20:14:45 -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=O3ZizfkdwvjAFL0IllFWvZYbWlz/CPB//NPk13szDnA=; b=XTCcYYMiXOfOO8UZtTG2f4+h7DnLy2umVMF+CdELsqaDItfv4WYfrK+AW4TM2ZY7Wiz5 hc3RNIYrxa5LoCQedwb+b4jaEdcBZJYqBWbR4RQ8qhU01QPzbUblFv4RAINGa0R6UPBXr6 accQA7xeA371StT45tuT9cpy/iWPU8Cc1EdmRZPoG56rEypnktm6AM3IilMihvm75KNBEl IYvFNEPcfLHWEJxS/lqNTlroQHVDUvrDRGPQMaB1D4AHnh2U4hQjkmVZ5g0sJmVEvTrB2J bH8gzmyLyFuYSgzbupsRv9Fozsi72vtPL1ZnYAQrsXhBhPwVXMFITMWAGBNyENTg== Received: by filterdrecv-64fcb979b9-6vbpf with SMTP id filterdrecv-64fcb979b9-6vbpf-1-61C3CD5F-5 2021-12-23 01:14:07.110980273 +0000 UTC m=+8644638.115216542 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-5-1 (SG) with ESMTP id TsQv68ysQ0ubKGaRoRZ4qw Thu, 23 Dec 2021 01:14:06.927 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id E53EE701518; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 45/50] wilc1000: move struct wilc_spi declaration Date: Thu, 23 Dec 2021 01:14:07 +0000 (UTC) Message-Id: <20211223011358.4031459-46-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvH9Cvv=2F5ehKJw4467?= =?us-ascii?Q?7quhFIAFUnbiUWmbmmTg6+hqXGuYJ3ieEzuxpbm?= =?us-ascii?Q?7Je+yt+BbiVHKqzw5OrYGLhvWgBHh5hmLhcwiGx?= =?us-ascii?Q?vUDvb09wx1aTcHtWXta2tqSykUGcpxENuXbfHgf?= =?us-ascii?Q?4jsGU=2FjvTtzO1inI253zcbm3p25fq0VAhXBfw9A?= =?us-ascii?Q?sJCvUMz2Rvkvv44n+cUSg=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Just move the structure down by a few lines so that a later patch can be understood more easily. No functional change. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/spi.c | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/spi.c b/drivers/net/wi= reless/microchip/wilc1000/spi.c index 2c2ed4b09efd5..5f73b3d2d2112 100644 --- a/drivers/net/wireless/microchip/wilc1000/spi.c +++ b/drivers/net/wireless/microchip/wilc1000/spi.c @@ -41,17 +41,6 @@ MODULE_PARM_DESC(enable_crc16, */ #define WILC_SPI_RSP_HDR_EXTRA_DATA 8 =20 -struct wilc_spi { - bool isinit; /* true if SPI protocol has been configured */ - bool probing_crc; /* true if we're probing chip's CRC config */ - bool crc7_enabled; /* true if crc7 is currently enabled */ - bool crc16_enabled; /* true if crc16 is currently enabled */ - struct wilc_gpios { - struct gpio_desc *enable; /* ENABLE GPIO or NULL */ - struct gpio_desc *reset; /* RESET GPIO or NULL */ - } gpios; -}; - static const struct wilc_hif_func wilc_hif_spi; =20 static int wilc_spi_reset(struct wilc *wilc); @@ -109,6 +98,17 @@ static int wilc_spi_reset(struct wilc *wilc); #define WILC_SPI_COMMAND_STAT_SUCCESS 0 #define WILC_GET_RESP_HDR_START(h) (((h) >> 4) & 0xf) =20 +struct wilc_spi { + bool isinit; /* true if SPI protocol has been configured */ + bool probing_crc; /* true if we're probing chip's CRC config */ + bool crc7_enabled; /* true if crc7 is currently enabled */ + bool crc16_enabled; /* true if crc16 is currently enabled */ + struct wilc_gpios { + struct gpio_desc *enable; /* ENABLE GPIO or NULL */ + struct gpio_desc *reset; /* RESET GPIO or NULL */ + } gpios; +}; + struct wilc_spi_cmd { u8 cmd_type; union { --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 C6C75C433EF for ; Thu, 23 Dec 2021 01:16:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346068AbhLWBQ5 (ORCPT ); Wed, 22 Dec 2021 20:16:57 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18762 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345847AbhLWBOY (ORCPT ); Wed, 22 Dec 2021 20:14:24 -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=K3gvUb3OfxsaOhe9tlq0tGnjjw1iUXxBhXljWscLEpA=; b=EyL6nlfgr9jVdtVhMT6au8qt34Za+LdjzKKipZCKpqlgz6G1wl5F3+25Hbw0xEDLe2wu FrihvBjOH6zXmTgA3DRnJftUG5FCjuj5rCxeHcC251pZQuyGFJCwfV5v7gDc1e/y/avUCB 0UO1lhho1nSvG87xayM8xWqixfBePLN9481Ei9NJQ53z6p07N2K4bk1XHoWIKjhnDSnikd 6bOlQ5ulnfrVrLW5DvvVKo4ESFryeS2RHRZcYuHoU/LyoDffXjFEEavVG+/Ri/6snSR7Ul NGt1Q+S0RbMcoGGgtYpyydfsRRVmyTHAieajpg3t3EgvBkqMFC0e4bMSQph529TA== Received: by filterdrecv-75ff7b5ffb-ndqvq with SMTP id filterdrecv-75ff7b5ffb-ndqvq-1-61C3CD5F-F 2021-12-23 01:14:07.170941284 +0000 UTC m=+9687225.771336929 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-2-0 (SG) with ESMTP id IA6WsOnwRGSzJ75Zl9-9BQ Thu, 23 Dec 2021 01:14:07.020 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id EE86B70152F; Wed, 22 Dec 2021 18:14:05 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 46/50] wilc1000: remove duplicate CRC calculation code Date: Thu, 23 Dec 2021 01:14:07 +0000 (UTC) Message-Id: <20211223011358.4031459-47-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvCNKwj+DYMFZnlIhP?= =?us-ascii?Q?R3K1iY1ejP=2F1ZZy1gRWB3YD8=2FXZCKVGtzkSucLw?= =?us-ascii?Q?WRtW7fomsuWltgqRjiEBKbxvD+9e=2Fp2qcVJwvSk?= =?us-ascii?Q?YmBPk=2FjZutd8UUMr8rhQpmJwu39LuLE4gR1E+Nl?= =?us-ascii?Q?6AqvFLt0CGv4K+GMCLAgNtfyiN=2FsVx3=2FW12+sXV?= =?us-ascii?Q?TND+x+XmcmKUXHyI7NTzA=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Factor two copies of the same calculation into a single instance. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/spi.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/spi.c b/drivers/net/wi= reless/microchip/wilc1000/spi.c index 5f73b3d2d2112..189907580d921 100644 --- a/drivers/net/wireless/microchip/wilc1000/spi.c +++ b/drivers/net/wireless/microchip/wilc1000/spi.c @@ -658,7 +658,7 @@ static int wilc_spi_dma_rw(struct wilc *wilc, u8 cmd, u= 32 adr, u8 *b, u32 sz) u8 wb[32], rb[32]; int cmd_len, resp_len; int retry, ix =3D 0; - u8 crc[2]; + u8 crc[2], *crc7; struct wilc_spi_cmd *c; struct wilc_spi_rsp_data *r; =20 @@ -673,8 +673,6 @@ static int wilc_spi_dma_rw(struct wilc *wilc, u8 cmd, u= 32 adr, u8 *b, u32 sz) c->u.dma_cmd.size[0] =3D sz >> 8; c->u.dma_cmd.size[1] =3D sz; cmd_len =3D offsetof(struct wilc_spi_cmd, u.dma_cmd.crc); - if (spi_priv->crc7_enabled) - c->u.dma_cmd.crc[0] =3D wilc_get_crc7(wb, cmd_len); } else if (cmd =3D=3D CMD_DMA_EXT_WRITE || cmd =3D=3D CMD_DMA_EXT_READ) { c->u.dma_cmd_ext.addr[0] =3D adr >> 16; c->u.dma_cmd_ext.addr[1] =3D adr >> 8; @@ -683,15 +681,16 @@ static int wilc_spi_dma_rw(struct wilc *wilc, u8 cmd,= u32 adr, u8 *b, u32 sz) c->u.dma_cmd_ext.size[1] =3D sz >> 8; c->u.dma_cmd_ext.size[2] =3D sz; cmd_len =3D offsetof(struct wilc_spi_cmd, u.dma_cmd_ext.crc); - if (spi_priv->crc7_enabled) - c->u.dma_cmd_ext.crc[0] =3D wilc_get_crc7(wb, cmd_len); } else { dev_err(&spi->dev, "dma read write cmd [%x] not supported\n", cmd); return -EINVAL; } - if (spi_priv->crc7_enabled) + if (spi_priv->crc7_enabled) { + crc7 =3D wb + cmd_len; + *crc7 =3D wilc_get_crc7(wb, cmd_len); cmd_len +=3D 1; + } =20 resp_len =3D sizeof(*r); =20 --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 141A8C433FE for ; Thu, 23 Dec 2021 01:16:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346870AbhLWBQZ (ORCPT ); Wed, 22 Dec 2021 20:16:25 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27440 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346262AbhLWBOx (ORCPT ); Wed, 22 Dec 2021 20:14:53 -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=xddQg0IvMbQSPuAc5H694hthTJIRjKrXhZw1xq1hEks=; b=Wrmx8l0su8dp9ndnFNO6sOW5lBaz+uiSFn7IMZNva52x3OVqh2+M/sZoOYrQVQTYyRs8 Md/+jjaQSKOr8aoFyr6TuKZsXSXEMia5qHZsgwWiDmnGAen0fPe1z+f3jjOQArqNr1dsT5 FnGMg9TlUXC3+VHoFrFYzpd7WxFc1I1umCcCnBPmcCXIMxJhmn7CJPF6Lcv9DJz0MfbSr9 1ZD5xWt5xk86qtbENBu5Oz6SogHrZ1GNfgSqsYi9Ntw+gnUg3xB3K7VIRXMRHOycOwW5Kk Yh9HSkAtrTOkCyIHSAztMVeWqXQvdI7AEJTRYhkXwph7WSPBrZK3FGmz4I9fxNag== Received: by filterdrecv-7bf5c69d5-5zdgz with SMTP id filterdrecv-7bf5c69d5-5zdgz-1-61C3CD5F-9 2021-12-23 01:14:07.092312815 +0000 UTC m=+9687226.301035880 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-2-0 (SG) with ESMTP id VtsPa1YnRSSp8kNi4WOeEw Thu, 23 Dec 2021 01:14:06.971 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 03A30701537; Wed, 22 Dec 2021 18:14:06 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 47/50] wilc1000: factor SPI DMA command initialization code into a function Date: Thu, 23 Dec 2021 01:14:07 +0000 (UTC) Message-Id: <20211223011358.4031459-48-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvANxWyaBzmrT8i6kB?= =?us-ascii?Q?IwcOApodCCbwNMcx6CCkJweUuGfzFJsSRyTzgz3?= =?us-ascii?Q?Qq5GQeAeySg3GXqJwB66FAOqWelVjAimJ3EHSeX?= =?us-ascii?Q?KaQFQV50GpNDqd6go3HUqQsVWe8uk5KewzCWteY?= =?us-ascii?Q?uCOD6=2FOlLY6OZwvCCmx1X6g3wUpkFW74bRzwQr7?= =?us-ascii?Q?9f=2FmbxJoG55lhc1NsyROA=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Introduce wilc_spi_dma_init_cmd() as a helper function as this will come in handy later. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/spi.c | 41 +++++++++++++------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/spi.c b/drivers/net/wi= reless/microchip/wilc1000/spi.c index 189907580d921..3e2022b43ee70 100644 --- a/drivers/net/wireless/microchip/wilc1000/spi.c +++ b/drivers/net/wireless/microchip/wilc1000/spi.c @@ -650,21 +650,14 @@ static int wilc_spi_write_cmd(struct wilc *wilc, u8 c= md, u32 adr, u32 data, return 0; } =20 -static int wilc_spi_dma_rw(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 = sz) +static int wilc_spi_dma_init_cmd(struct wilc *wilc, struct wilc_spi_cmd *c, + u8 cmd, u32 adr, u32 sz) { struct spi_device *spi =3D to_spi_device(wilc->dev); struct wilc_spi *spi_priv =3D wilc->bus_data; - u16 crc_recv, crc_calc; - u8 wb[32], rb[32]; - int cmd_len, resp_len; - int retry, ix =3D 0; - u8 crc[2], *crc7; - struct wilc_spi_cmd *c; - struct wilc_spi_rsp_data *r; + int cmd_len; + u8 *crc7; =20 - memset(wb, 0x0, sizeof(wb)); - memset(rb, 0x0, sizeof(rb)); - c =3D (struct wilc_spi_cmd *)wb; c->cmd_type =3D cmd; if (cmd =3D=3D CMD_DMA_WRITE || cmd =3D=3D CMD_DMA_READ) { c->u.dma_cmd.addr[0] =3D adr >> 16; @@ -687,10 +680,32 @@ static int wilc_spi_dma_rw(struct wilc *wilc, u8 cmd,= u32 adr, u8 *b, u32 sz) return -EINVAL; } if (spi_priv->crc7_enabled) { - crc7 =3D wb + cmd_len; - *crc7 =3D wilc_get_crc7(wb, cmd_len); + crc7 =3D (u8 *)c + cmd_len; + *crc7 =3D wilc_get_crc7((u8 *)c, cmd_len); cmd_len +=3D 1; } + return cmd_len; +} + +static int wilc_spi_dma_rw(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 = sz) +{ + struct spi_device *spi =3D to_spi_device(wilc->dev); + struct wilc_spi *spi_priv =3D wilc->bus_data; + u16 crc_recv, crc_calc; + u8 wb[32], rb[32]; + int cmd_len, resp_len; + int retry, ix =3D 0; + u8 crc[2]; + struct wilc_spi_cmd *c; + struct wilc_spi_rsp_data *r; + + memset(wb, 0x0, sizeof(wb)); + memset(rb, 0x0, sizeof(rb)); + c =3D (struct wilc_spi_cmd *)wb; + + cmd_len =3D wilc_spi_dma_init_cmd(wilc, c, cmd, adr, sz); + if (cmd_len < 0) + return -EINVAL; =20 resp_len =3D sizeof(*r); =20 --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 4DE21C433EF for ; Thu, 23 Dec 2021 01:16:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346426AbhLWBQL (ORCPT ); Wed, 22 Dec 2021 20:16:11 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27376 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346245AbhLWBOq (ORCPT ); Wed, 22 Dec 2021 20:14:46 -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=xa4Us+PL63HXTtD7NxFyiz9UQq8xrKpb1fAV6hO+Qos=; b=WiZqrxgJlOKay0jg9TQu/g1baC7D/NHFCmEBfBMFkyg2Y/etuV58hyWZC1NZspf9lXvi f/jbkAQqQ85c1JPaBNTUTKfyzpKvp8/hrhdK0FQ6zM9aU6x6UaII3FO8FBWU24e5QecB7Y 7bIYYro2Bc9OBEWb3px/lQv2rb07DekYdzV6yUktA2Zn1cft2a5mThYNtCoFrrnDx7Gve3 90zLzkaEh/l3Jkug+xb6kRY+zKClA1e91wxm+uBSS0N0T2QEpCK/h3npFW1Yfdq15Cynx6 C6NgCT0pnOr/k43D0G1uleBotenNddXjH4pYkftOpD8MQ26k0VRwwAWl+WkMJKqg== Received: by filterdrecv-656998cfdd-gwqfx with SMTP id filterdrecv-656998cfdd-gwqfx-1-61C3CD5F-8 2021-12-23 01:14:07.173124434 +0000 UTC m=+7955180.579837087 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-4-0 (SG) with ESMTP id qmYqcDsPSkiR11jDDKCxIg Thu, 23 Dec 2021 01:14:07.006 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 0D143701564; Wed, 22 Dec 2021 18:14:06 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 48/50] wilc1000: introduce function to find and check DMA response Date: Thu, 23 Dec 2021 01:14:07 +0000 (UTC) Message-Id: <20211223011358.4031459-49-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvHaV6O7GMUw=2FW4PJd?= =?us-ascii?Q?G4gRHrkryCd=2F53ygKA8OXI7MLM8aSLx7D5aeIlN?= =?us-ascii?Q?Edbxks55dlrMYbZ9kHO1bo7vRbn7Y8d2hC1aSCb?= =?us-ascii?Q?21oTOMfn+Zo0RhKHLMiFSwscVNdiWwbAlBaY1xx?= =?us-ascii?Q?=2FSuIxojWa+K18TMEWg0ziNo9r67rZ3h1qPunt+N?= =?us-ascii?Q?2waf0iru1bcfQSSIGsnYA=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Refactor DMA response checking from spi_data_rsp() into its own function spi_data_check_rsp() as that will come in handy later. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/spi.c | 52 +++++++++++-------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/spi.c b/drivers/net/wi= reless/microchip/wilc1000/spi.c index 3e2022b43ee70..8951202ed76e2 100644 --- a/drivers/net/wireless/microchip/wilc1000/spi.c +++ b/drivers/net/wireless/microchip/wilc1000/spi.c @@ -80,6 +80,18 @@ static int wilc_spi_reset(struct wilc *wilc); #define PROTOCOL_REG_CRC16_MASK GENMASK(3, 3) #define PROTOCOL_REG_CRC7_MASK GENMASK(2, 2) =20 +/* The response to data packets is two bytes long. For efficiency's + * sake, when DMAing data to WILC, we ignore the responses for all + * data packets except the final one. The downside of this + * optimization is that when the final data packet is short, we may + * receive (part of) the response to the second-to-last packet before + * the one for the final packet. To handle this, we always read 4 + * bytes and then search for the last byte that contains the "Response + * Start" code (0xc in the top 4 bits). We then know that this byte + * is the first response byte of the final data packet. + */ +#define WILC_SPI_DATA_RSP_BYTES 4 + /* * The SPI data packet size may be any integer power of two in the * range from 256 to 8192 bytes. @@ -950,31 +962,13 @@ static int wilc_spi_write_reg(struct wilc *wilc, u32 = addr, u32 data) return 0; } =20 -static int spi_data_rsp(struct wilc *wilc, u8 cmd) +static int spi_data_check_rsp(struct wilc *wilc, + u8 rsp[WILC_SPI_DATA_RSP_BYTES]) { struct spi_device *spi =3D to_spi_device(wilc->dev); - int result, i; - u8 rsp[4]; - - /* - * The response to data packets is two bytes long. For - * efficiency's sake, wilc_spi_write() wisely ignores the - * responses for all packets but the final one. The downside - * of that optimization is that when the final data packet is - * short, we may receive (part of) the response to the - * second-to-last packet before the one for the final packet. - * To handle this, we always read 4 bytes and then search for - * the last byte that contains the "Response Start" code (0xc - * in the top 4 bits). We then know that this byte is the - * first response byte of the final data packet. - */ - result =3D wilc_spi_rx(wilc, rsp, sizeof(rsp)); - if (result) { - dev_err(&spi->dev, "Failed bus error...\n"); - return result; - } + int i; =20 - for (i =3D sizeof(rsp) - 2; i >=3D 0; --i) + for (i =3D WILC_SPI_DATA_RSP_BYTES - 2; i >=3D 0; --i) if (FIELD_GET(RSP_START_FIELD, rsp[i]) =3D=3D RSP_START_TAG) break; =20 @@ -996,6 +990,20 @@ static int spi_data_rsp(struct wilc *wilc, u8 cmd) return 0; } =20 +static int spi_data_rsp(struct wilc *wilc, u8 cmd) +{ + struct spi_device *spi =3D to_spi_device(wilc->dev); + u8 rsp[WILC_SPI_DATA_RSP_BYTES]; + int result; + + result =3D wilc_spi_rx(wilc, rsp, sizeof(rsp)); + if (result) { + dev_err(&spi->dev, "Failed bus error...\n"); + return result; + } + return spi_data_check_rsp(wilc, rsp); +} + static int wilc_spi_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size) { struct spi_device *spi =3D to_spi_device(wilc->dev); --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 0AFD8C433FE for ; Thu, 23 Dec 2021 01:16:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242379AbhLWBQ2 (ORCPT ); Wed, 22 Dec 2021 20:16:28 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27438 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346260AbhLWBOw (ORCPT ); Wed, 22 Dec 2021 20:14:52 -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=svs2sMYtjbzn9WErfCKbNYr+L40h6C9hhF2fxm1TnUc=; b=x5CHkg+U/AEUeKShQraCsCFovxrHQLqVVY/1oVhOKnNHL4TqqZwG/RAWfahTKh7Nj2ET 80zTsD30QLICLXvuzyBP+gAIHfKQoM/88ORaUjOBji9u5S5KxmxDDISb6qrfDlGBYXutJ1 a1rteALps9iD7gSXjz5pk7IRzDz+o9ejNZBBBgstyPvZmIY6nX3+PROOoPxiMwZTjgLjDL AFg7sz5eQhWi06Qekx3CrCJJmclFYsB0c+zJ0ga+WVUX4VWXinod9JHurcLiMh8yLDi/ql O7llWzrRjRjziC0CMbS2uiXAV1Utbt8nwS/3ufKEOzFZwB0uvn6iavnqOWyDH0Iw== Received: by filterdrecv-7bf5c69d5-w55fp with SMTP id filterdrecv-7bf5c69d5-w55fp-1-61C3CD5F-3 2021-12-23 01:14:07.106510197 +0000 UTC m=+9687232.265531122 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-2-0 (SG) with ESMTP id exmKzqKWQoOJwtrusg6-sw Thu, 23 Dec 2021 01:14:06.969 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 16A1B70156B; Wed, 22 Dec 2021 18:14:06 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 49/50] wilc1000: implement zero-copy transmit support for SPI Date: Thu, 23 Dec 2021 01:14:07 +0000 (UTC) Message-Id: <20211223011358.4031459-50-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvIXjviVKntPmow2Ps?= =?us-ascii?Q?Uz0li20mrVt8rN+SLyzZEQOCNzWH1oSVsNrpOx1?= =?us-ascii?Q?b+zybfU=2FkDGwNSPAcuq2hGsZfhMBjwTsly4gWQO?= =?us-ascii?Q?A9uZogifsSR4qho1Sa83ZZt=2FGnMPkHQbz0LxdIb?= =?us-ascii?Q?JdwL1896S8j1vv2TmKNvifZbvmImRS8R9vKR1MF?= =?us-ascii?Q?CKfUuI5sHl8YA5zs1cduA=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This enables zero-copy transmits for the SPI driver. Maybe something similar could be implemented for the SDIO driver, but I'm not really familiar with it. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/spi.c | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) diff --git a/drivers/net/wireless/microchip/wilc1000/spi.c b/drivers/net/wi= reless/microchip/wilc1000/spi.c index 8951202ed76e2..8d94f111ffc49 100644 --- a/drivers/net/wireless/microchip/wilc1000/spi.c +++ b/drivers/net/wireless/microchip/wilc1000/spi.c @@ -44,6 +44,8 @@ MODULE_PARM_DESC(enable_crc16, static const struct wilc_hif_func wilc_hif_spi; =20 static int wilc_spi_reset(struct wilc *wilc); +static int wilc_spi_write_sk_buffs(struct wilc *wilc, u32 addr, + size_t num_skbs, struct sk_buff_head *skbs); =20 /******************************************** * @@ -107,9 +109,33 @@ static int wilc_spi_reset(struct wilc *wilc); #define DATA_PKT_LOG_SZ DATA_PKT_LOG_SZ_MAX #define DATA_PKT_SZ (1 << DATA_PKT_LOG_SZ) =20 +#define DATA_START_TAG 0xf0 +#define DATA_ORDER_FIRST 0x01 +#define DATA_ORDER_INNER 0x02 +#define DATA_ORDER_LAST 0x03 + #define WILC_SPI_COMMAND_STAT_SUCCESS 0 #define WILC_GET_RESP_HDR_START(h) (((h) >> 4) & 0xf) =20 +/* wilc_spi_write_sk_buffs() needs the following max. number of SPI + * transfers: + * + * - 1 transfer to send the CMD_DMA_EXT_WRITE command + * - 1 transfer per sk_buff (at most WILC_VMM_TBL_SIZE of them) + * - for each data packet: + * + 1 transfer for the data start tag + * + 1 transfer for the current sk_buff (if it spans + * the boundary of a data packet) + * + 1 transfer for the optional CRC16 + * - 1 transfer to read the DMA response bytes + */ +#define MAX_DATA_PKTS DIV_ROUND_UP(WILC_TX_BUFF_SIZE, DATA_PKT_SZ) +#define MAX_SPI_XFERS \ + (1 \ + + WILC_VMM_TBL_SIZE \ + + 3 * MAX_DATA_PKTS \ + + 1) + struct wilc_spi { bool isinit; /* true if SPI protocol has been configured */ bool probing_crc; /* true if we're probing chip's CRC config */ @@ -119,6 +145,11 @@ struct wilc_spi { struct gpio_desc *enable; /* ENABLE GPIO or NULL */ struct gpio_desc *reset; /* RESET GPIO or NULL */ } gpios; + /* Scratch space used by wilc_spi_write_sk_buffs() for SPI + * transfers and the data packets' CRCs. + */ + struct spi_transfer xfer[MAX_SPI_XFERS]; + u8 crc[2 * MAX_DATA_PKTS]; }; =20 struct wilc_spi_cmd { @@ -1037,6 +1068,136 @@ static int wilc_spi_write(struct wilc *wilc, u32 ad= dr, u8 *buf, u32 size) return spi_data_rsp(wilc, CMD_DMA_EXT_WRITE); } =20 +static void wilc_spi_add_xfer(struct spi_message *msg, + struct spi_transfer **xferp, + size_t len, const void *tx_buf, void *rx_buf) +{ + struct spi_transfer *xfer =3D *xferp; + + xfer->tx_buf =3D tx_buf; + xfer->rx_buf =3D rx_buf; + xfer->len =3D len; + spi_message_add_tail(xfer, msg); + *xferp =3D xfer + 1; +} + +/** + * wilc_spi_write_sk_buffs() - Zero-copy write sk_buffs to the chip. + * @wilc: Pointer to the wilc structure. + * @addr: The WILC address to transfer the data to. + * @num_skbs: The length of the skbs array. + * @skbs: The queue containing the sk_buffs to transmit. + * + * Zero-copy transfer one or more sk_buffs to the WILC chip. At most + * WILC_VMM_TBL_SIZE sk_buffs may be transmitted and the total size of + * the data in the sk_buffs must not exceed WILC_VMM_TBL_SIZE. + * + * Context: The caller must hold ownership of the SPI bus through a + * call to acquire_bus(). + * + * Return: Zero on success, negative number on error. + */ +static int wilc_spi_write_sk_buffs(struct wilc *wilc, u32 addr, size_t num= _skbs, + struct sk_buff_head *skbs) +{ + static const u8 data_hdr_first =3D DATA_START_TAG | DATA_ORDER_FIRST; + static const u8 data_hdr_inner =3D DATA_START_TAG | DATA_ORDER_INNER; + static const u8 data_hdr_last =3D DATA_START_TAG | DATA_ORDER_LAST; + size_t num_data_packets =3D 0, total_bytes =3D 0, num_sent, n, space; + struct spi_device *spi =3D to_spi_device(wilc->dev); + struct wilc_spi *spi_priv =3D wilc->bus_data; + u8 rsp[WILC_SPI_DATA_RSP_BYTES], *crc; + int i, ret, cmd_len; + struct spi_transfer *xfer; + struct wilc_spi_cmd cmd; + struct spi_message msg; + struct sk_buff *skb; + const u8 *data_hdr; + u16 crc_calc; + + /* setup the SPI message and transfers: */ + + spi_message_init(&msg); + msg.spi =3D spi; + + skb =3D skb_peek(skbs); + for (i =3D 0; i < num_skbs; ++i) { + n =3D skb->len; + total_bytes +=3D n; + skb =3D skb_peek_next(skb, skbs); + } + + num_data_packets =3D DIV_ROUND_UP(total_bytes, DATA_PKT_SZ); + skb =3D skb_peek(skbs); + num_sent =3D 0; + xfer =3D spi_priv->xfer; + crc =3D spi_priv->crc; + + cmd_len =3D wilc_spi_dma_init_cmd(wilc, &cmd, CMD_DMA_EXT_WRITE, + addr, total_bytes); + if (cmd_len < 0) { + dev_err(&spi->dev, "Failed to init DMA command."); + return -EINVAL; + } + wilc_spi_add_xfer(&msg, &xfer, cmd_len, &cmd, NULL); + + for (i =3D 0; i < num_data_packets; ++i) { + space =3D DATA_PKT_SZ; + crc_calc =3D 0xffff; + + /* write data packet's start header: */ + if (i =3D=3D num_data_packets - 1) + data_hdr =3D &data_hdr_last; + else if (i =3D=3D 0) + data_hdr =3D &data_hdr_first; + else + data_hdr =3D &data_hdr_inner; + wilc_spi_add_xfer(&msg, &xfer, 1, data_hdr, NULL); + + /* write packet data: */ + do { + n =3D skb->len - num_sent; + if (n > space) + n =3D space; + wilc_spi_add_xfer(&msg, &xfer, n, + skb->data + num_sent, NULL); + if (spi_priv->crc16_enabled) + crc_calc =3D crc_itu_t(crc_calc, + skb->data + num_sent, n); + num_sent +=3D n; + space -=3D n; + + if (num_sent >=3D skb->len) { + skb =3D skb_peek_next(skb, skbs); + --num_skbs; + num_sent =3D 0; + } + } while (space > 0 && num_skbs > 0); + + /* write optional CRC16 checksum: */ + if (spi_priv->crc16_enabled) { + crc[0] =3D crc_calc >> 8; + crc[1] =3D crc_calc; + wilc_spi_add_xfer(&msg, &xfer, 2, crc, NULL); + crc +=3D 2; + } + } + /* last transfer reads the response bytes: */ + wilc_spi_add_xfer(&msg, &xfer, sizeof(rsp), NULL, rsp); + + WARN_ON((u8 *)xfer - (u8 *)spi_priv->xfer > sizeof(spi_priv->xfer)); + WARN_ON(crc - spi_priv->crc > sizeof(spi_priv->crc)); + + ret =3D spi_sync(spi, &msg); + if (ret < 0) { + dev_err(&spi->dev, "spi_sync() failed: ret=3D%d\n", ret); + return -EINVAL; + } + + /* Check if the chip received the data correctly: */ + return spi_data_check_rsp(wilc, rsp); +} + /******************************************** * * Bus interfaces @@ -1275,6 +1436,7 @@ static const struct wilc_hif_func wilc_hif_spi =3D { .hif_read_size =3D wilc_spi_read_size, .hif_block_tx_ext =3D wilc_spi_write, .hif_block_rx_ext =3D wilc_spi_read, + .hif_sk_buffs_tx =3D wilc_spi_write_sk_buffs, .hif_sync_ext =3D wilc_spi_sync_ext, .hif_reset =3D wilc_spi_reset, }; --=20 2.25.1 From nobody Wed Jul 1 09:56:28 2026 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 4D9EEC433F5 for ; Thu, 23 Dec 2021 01:16:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346744AbhLWBQI (ORCPT ); Wed, 22 Dec 2021 20:16:08 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27334 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346237AbhLWBOp (ORCPT ); Wed, 22 Dec 2021 20:14:45 -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=yps8dWzMUKU9RpPhjdHxIE2MYXvMyKmHNVpEu8C+Av8=; b=YDmkak+OJEFHYXe/bj0Hi6XL2ELKUc4fCQN0z5nFM2oYV6GPyJxBnSq9OPl6vD1wKRHA cOcYfPSCr3Eckn5sQ4WMg/PwZIf6yjIPG9KgH8qSbL3TfcKGTfo3mIrcm/KuaUg+Fww3ch M03YDD0sBTbfHuCZFpFHard5V3ByPZK66/6RACPSdLgc6lgNBuBOu38VdUbEfrIUR4jNXc WVC+ivPgLdV6s7LL1FPa1EHQ5Pu05r+Ry5C7lBNumIwlMeHLccJ7hl0A1x2uon7n6DF4ZP vlRBywOeK3Atj11UpaYoWdlKgueDtgXMsgbDFpwAzU9oVNjYWTRd9iiBK9jUQG2Q== Received: by filterdrecv-656998cfdd-phncc with SMTP id filterdrecv-656998cfdd-phncc-1-61C3CD5F-4 2021-12-23 01:14:07.130091855 +0000 UTC m=+7955208.316338637 Received: from pearl.egauge.net (unknown) by geopod-ismtpd-6-0 (SG) with ESMTP id cnVlM2Y7Qw-Hv8JFSNpx_A Thu, 23 Dec 2021 01:14:06.990 +0000 (UTC) Received: by pearl.egauge.net (Postfix, from userid 1000) id 20C9E700BFC; Wed, 22 Dec 2021 18:14:06 -0700 (MST) From: David Mosberger-Tang Subject: [PATCH v2 50/50] wilc1000: add module parameter "disable_zero_copy_tx" to SPI driver Date: Thu, 23 Dec 2021 01:14:07 +0000 (UTC) Message-Id: <20211223011358.4031459-51-davidm@egauge.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211223011358.4031459-1-davidm@egauge.net> References: <20211223011358.4031459-1-davidm@egauge.net> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?+kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT=2Fkh?= =?us-ascii?Q?ET6RJF6+Prbl0h=2FEtF1rRLvNU=2FAiSwPXGwNeF4R?= =?us-ascii?Q?8pktv6qIQV9=2FvaYSYgd73qzUc+WcF+3KTLAn0Dz?= =?us-ascii?Q?BHXeSqbDC7G4R7ZfYu1EAHyy3Sq2tG4byisGyd2?= =?us-ascii?Q?qmo38tC9F5T2qmg=2Fpn8TXE3jyaOiU+UDITPGro4?= =?us-ascii?Q?e5Jq6l2P2YbawALWFgyfe3o6Pmduip+K2qFF1qs?= =?us-ascii?Q?=2F7vQHUWDarfmxjBGFKTPw=3D=3D?= 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== Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add a module parameter to disable the zero-copy transmit path. This is useful for testing and performance measurement, for example. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/spi.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/spi.c b/drivers/net/wi= reless/microchip/wilc1000/spi.c index 8d94f111ffc49..588cec326a74b 100644 --- a/drivers/net/wireless/microchip/wilc1000/spi.c +++ b/drivers/net/wireless/microchip/wilc1000/spi.c @@ -31,6 +31,11 @@ MODULE_PARM_DESC(enable_crc16, "\t\t\tData transfers can be large and the CPU-cycle cost\n" "\t\t\tof enabling this may be substantial."); =20 +static bool disable_zero_copy_tx; +module_param(disable_zero_copy_tx, bool, 0644); +MODULE_PARM_DESC(disable_zero_copy_tx, + "Disable zero-copy when sending packets."); + /* * For CMD_SINGLE_READ and CMD_INTERNAL_READ, WILC may insert one or * more zero bytes between the command response and the DATA Start tag @@ -41,7 +46,7 @@ MODULE_PARM_DESC(enable_crc16, */ #define WILC_SPI_RSP_HDR_EXTRA_DATA 8 =20 -static const struct wilc_hif_func wilc_hif_spi; +static struct wilc_hif_func wilc_hif_spi; =20 static int wilc_spi_reset(struct wilc *wilc); static int wilc_spi_write_sk_buffs(struct wilc *wilc, u32 addr, @@ -254,6 +259,9 @@ static int wilc_bus_probe(struct spi_device *spi) if (!spi_priv) return -ENOMEM; =20 + if (!disable_zero_copy_tx) + wilc_hif_spi.hif_sk_buffs_tx =3D wilc_spi_write_sk_buffs; + ret =3D wilc_cfg80211_init(&wilc, &spi->dev, WILC_HIF_SPI, &wilc_hif_spi); if (ret) goto free; @@ -1424,7 +1432,7 @@ static int wilc_spi_sync_ext(struct wilc *wilc, int n= int) } =20 /* Global spi HIF function table */ -static const struct wilc_hif_func wilc_hif_spi =3D { +static struct wilc_hif_func wilc_hif_spi =3D { .hif_init =3D wilc_spi_init, .hif_deinit =3D wilc_spi_deinit, .hif_read_reg =3D wilc_spi_read_reg, @@ -1436,7 +1444,6 @@ static const struct wilc_hif_func wilc_hif_spi =3D { .hif_read_size =3D wilc_spi_read_size, .hif_block_tx_ext =3D wilc_spi_write, .hif_block_rx_ext =3D wilc_spi_read, - .hif_sk_buffs_tx =3D wilc_spi_write_sk_buffs, .hif_sync_ext =3D wilc_spi_sync_ext, .hif_reset =3D wilc_spi_reset, }; --=20 2.25.1