From patchwork Thu Dec 23 01:14:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697847 X-Patchwork-Delegate: kvalo@adurom.com 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 A23CFC43217 for ; Thu, 23 Dec 2021 01:16:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345848AbhLWBOH (ORCPT ); Wed, 22 Dec 2021 20:14:07 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:17728 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235345AbhLWBOG (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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvFFgikHEO6TrfMipfR5df56socHUWL2usMYlQYxi9mNZe3jUS8vaJZg3E+EW8ovRMMV2T/wpc1krcS5fB6jrNH91fVEvmXwfCFc0qA2xa4gl+xAx7Wqx7j3CAOPc89Afa7aXeGrR+8sjKRZQz0+yuTZPgQw3hxhyDUgwCV+6pg6+bJWCAvPelpJDy4p8jwAnBg== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The wilc_tx_queue_status queue is relatively large and there is absolutely no need to initialize it while holding a spinlock. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/netdev.h | 1 - .../net/wireless/microchip/wilc1000/wlan.c | 32 +++++++++++-------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h b/drivers/net/wireless/microchip/wilc1000/netdev.h index 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; }; struct wilc { diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/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 @@ #define WAKE_UP_TRIAL_RETRY 10000 +static const u8 factors[NQUEUES] = {1, 1, 1, 1}; + static inline bool is_wilc1000(u32 id) { return (id & (~WILC_CHIP_REV_FIELD)) == WILC_1000_BASE_ID; @@ -283,10 +285,23 @@ static int wilc_wlan_txq_add_cfg_pkt(struct wilc_vif *vif, u8 *buffer, return 1; } +static void init_q_limits(struct wilc *wl) +{ + struct wilc_tx_queue_status *q = &wl->tx_q_limit; + int i; + + for (i = 0; i < AC_BUFFER_SIZE; i++) + q->buffer[i] = i % NQUEUES; + + for (i = 0; i < NQUEUES; i++) { + q->cnt[i] = AC_BUFFER_SIZE * factors[i] / NQUEUES; + q->sum += q->cnt[i]; + } + q->end_index = AC_BUFFER_SIZE - 1; +} + static bool is_ac_q_limit(struct wilc *wl, u8 q_num) { - u8 factors[NQUEUES] = {1, 1, 1, 1}; - u16 i; unsigned long flags; struct wilc_tx_queue_status *q = &wl->tx_q_limit; u8 end_index; @@ -294,17 +309,6 @@ static bool is_ac_q_limit(struct wilc *wl, u8 q_num) bool ret = false; spin_lock_irqsave(&wl->txq_spinlock, flags); - if (!q->initialized) { - for (i = 0; i < AC_BUFFER_SIZE; i++) - q->buffer[i] = i % NQUEUES; - - for (i = 0; i < NQUEUES; i++) { - q->cnt[i] = AC_BUFFER_SIZE * factors[i] / NQUEUES; - q->sum += q->cnt[i]; - } - q->end_index = AC_BUFFER_SIZE - 1; - q->initialized = 1; - } end_index = q->end_index; q->cnt[q->buffer[end_index]] -= factors[q->buffer[end_index]]; @@ -1484,6 +1488,8 @@ int wilc_wlan_init(struct net_device *dev) goto fail; } + init_q_limits(wilc); + if (!wilc->tx_buffer) wilc->tx_buffer = kmalloc(WILC_TX_BUFF_SIZE, GFP_KERNEL); From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697808 X-Patchwork-Delegate: kvalo@adurom.com 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 0CC70C43217 for ; Thu, 23 Dec 2021 01:14:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345854AbhLWBOI (ORCPT ); Wed, 22 Dec 2021 20:14:08 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:17760 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238369AbhLWBOH (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:06 +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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvKKbokcqBZrOnU5kEpG8h+syelvS85jzqTtTcv7YHcinBYmG949gzYNeS+CPI21kQiP7YmP1MedO60V8pEhFGOBd10okyUtsBu7T9PvInMPjvAeIPsHSjoC7t1Sp7cStInnp01xhPqxamxTfGzHEr0j+7a70R+PU3Hkn3CetHkL6jToN6bok6N2HazAG7QD0zg== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Completion structs are essentially counting semaphores: every complete() call wakes up exactly one thread, either immediately (when there are waiters queued) or in the future (when a waiter arrives). This isn't really the appropriate synchronization structure for the wilc1000 transmit queue handler (wilc_wlan_handle_txq) because it will consume zero, one, or more packets on each call. Instead, use a waitqueue as a condition variable: wake_up_interruptible() wakes up the tx queue handler from a call to wait_event_interruptible() whenever something interesting happens and it then takes the appropriate action. This has a couple of benefits: - Since the transmit queue handler often transfers multiple packets to the chip on each call, repeated calls to wait_for_completion() when there is no actual work to do are avoided. - When the transmit queue handler cannot transfer any packets at all, it'll simply give up the current time slice and then tries again. Previously, the transmit would stall until a new packet showed up (which potentially could cause extended stalls). It would be even better to wait for a "tx queue not full" interrupt but, sadly, I'm told the wilc1000 firmware doesn't provide that. - There is no longer any need for wilc_wlan_txq_filter_dup_tcp_ack() to adjust the completion structs wait count by calling wait_for_completion_timeout() for each dropped packet. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/cfg80211.c | 2 +- drivers/net/wireless/microchip/wilc1000/netdev.c | 13 +++++++++---- drivers/net/wireless/microchip/wilc1000/netdev.h | 2 +- drivers/net/wireless/microchip/wilc1000/wlan.c | 12 ++---------- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.c b/drivers/net/wireless/microchip/wilc1000/cfg80211.c index 8d8378bafd9b0..be387a8abb6af 100644 --- a/drivers/net/wireless/microchip/wilc1000/cfg80211.c +++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.c @@ -1692,7 +1692,7 @@ static void wlan_init_locks(struct wilc *wl) spin_lock_init(&wl->txq_spinlock); mutex_init(&wl->txq_add_to_head_cs); - init_completion(&wl->txq_event); + init_waitqueue_head(&wl->txq_event); init_completion(&wl->cfg_event); init_completion(&wl->sync_event); init_completion(&wl->txq_thread_started); diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c b/drivers/net/wireless/microchip/wilc1000/netdev.c index 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 = vp; + long timeout; complete(&wl->txq_thread_started); while (1) { - wait_for_completion(&wl->txq_event); + wait_event_interruptible(wl->txq_event, + (wl->txq_entries > 0 || wl->close)); if (wl->close) { complete(&wl->txq_thread_started); @@ -170,6 +172,11 @@ static int wilc_txq_task(void *vp) } srcu_read_unlock(&wl->srcu, srcu_idx); } + if (ret == WILC_VMM_ENTRY_FULL_RETRY) { + timeout = msecs_to_jiffies(1); + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(timeout); + } } while (ret == WILC_VMM_ENTRY_FULL_RETRY && !wl->close); } return 0; @@ -419,12 +426,11 @@ static void wlan_deinitialize_threads(struct net_device *dev) wl->close = 1; - complete(&wl->txq_event); - if (wl->txq_thread) { kthread_stop(wl->txq_thread); wl->txq_thread = NULL; } + wake_up_interruptible(&wl->txq_event); } static void wilc_wlan_deinitialize(struct net_device *dev) @@ -446,7 +452,6 @@ static void wilc_wlan_deinitialize(struct net_device *dev) wl->hif_func->disable_interrupt(wl); mutex_unlock(&wl->hif_cs); } - complete(&wl->txq_event); wlan_deinitialize_threads(dev); deinit_irq(dev); diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h b/drivers/net/wireless/microchip/wilc1000/netdev.h index 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 { struct completion cfg_event; struct completion sync_event; - struct completion txq_event; + wait_queue_head_t txq_event; struct completion txq_thread_started; struct task_struct *txq_thread; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 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, spin_unlock_irqrestore(&wilc->txq_spinlock, flags); - complete(&wilc->txq_event); + wake_up_interruptible(&wilc->txq_event); } static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, u8 q_num, @@ -94,7 +94,7 @@ static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, u8 q_num, spin_unlock_irqrestore(&wilc->txq_spinlock, flags); mutex_unlock(&wilc->txq_add_to_head_cs); - complete(&wilc->txq_event); + wake_up_interruptible(&wilc->txq_event); } #define NOT_TCP_ACK (-1) @@ -196,7 +196,6 @@ static void wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) struct wilc *wilc = vif->wilc; struct tcp_ack_filter *f = &vif->ack_filter; u32 i = 0; - u32 dropped = 0; unsigned long flags; spin_lock_irqsave(&wilc->txq_spinlock, flags); @@ -226,7 +225,6 @@ static void wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) tqe->tx_complete_func(tqe->priv, tqe->status); kfree(tqe); - dropped++; } } } @@ -239,12 +237,6 @@ static void wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) f->pending_base = 0; spin_unlock_irqrestore(&wilc->txq_spinlock, flags); - - while (dropped > 0) { - wait_for_completion_timeout(&wilc->txq_event, - msecs_to_jiffies(1)); - dropped--; - } } void wilc_enable_tcp_ack_filter(struct wilc_vif *vif, bool value) From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697815 X-Patchwork-Delegate: kvalo@adurom.com 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 2D23FC433FE for ; Thu, 23 Dec 2021 01:14:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345865AbhLWBOK (ORCPT ); Wed, 22 Dec 2021 20:14:10 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:17820 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238606AbhLWBOI (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:06 +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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvHpcdJyjK68kH7SarFuF+9wd2pQ9CycCQS3psyU5a2BgiM9NfanPTTGnr3zYONbprcPrw1z/H8X3gZmbkZcyk3eq+fr83XEx3gSMR0Z10l2+CJFL26+enQo/Ysb1/iWfuhOIxBR86fy4pjLegTo7fhk6MVngzUqvWmyvNI0SXFCEEZUt8gLKfb+ukzUSlQcP8w== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This is in preparation of switching the transmit queue to struct sk_buffs. There is no functional change other than moving the location of the structure. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/netdev.h | 1 + .../net/wireless/microchip/wilc1000/wlan.c | 28 +++++++++---------- .../net/wireless/microchip/wilc1000/wlan.h | 1 - 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h b/drivers/net/wireless/microchip/wilc1000/netdev.h index 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 { struct txq_handle txq[NQUEUES]; int txq_entries; + struct txq_fw_recv_queue_stat fw[NQUEUES]; struct wilc_tx_queue_status tx_q_limit; struct rxq_entry_t rxq_head; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 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 *ratio) return -EINVAL; for (i = 0; i < NQUEUES; i++) - if (wl->txq[i].fw.count > max_count) - max_count = wl->txq[i].fw.count; + if (wl->fw[i].count > max_count) + max_count = wl->fw[i].count; for (i = 0; i < NQUEUES; i++) - ratio[i] = max_count - wl->txq[i].fw.count; + ratio[i] = max_count - wl->fw[i].count; return 0; } static inline void ac_update_fw_ac_pkt_info(struct wilc *wl, u32 reg) { - wl->txq[AC_BK_Q].fw.count = FIELD_GET(BK_AC_COUNT_FIELD, reg); - wl->txq[AC_BE_Q].fw.count = FIELD_GET(BE_AC_COUNT_FIELD, reg); - wl->txq[AC_VI_Q].fw.count = FIELD_GET(VI_AC_COUNT_FIELD, reg); - wl->txq[AC_VO_Q].fw.count = FIELD_GET(VO_AC_COUNT_FIELD, reg); - - wl->txq[AC_BK_Q].fw.acm = FIELD_GET(BK_AC_ACM_STAT_FIELD, reg); - wl->txq[AC_BE_Q].fw.acm = FIELD_GET(BE_AC_ACM_STAT_FIELD, reg); - wl->txq[AC_VI_Q].fw.acm = FIELD_GET(VI_AC_ACM_STAT_FIELD, reg); - wl->txq[AC_VO_Q].fw.acm = FIELD_GET(VO_AC_ACM_STAT_FIELD, reg); + wl->fw[AC_BK_Q].count = FIELD_GET(BK_AC_COUNT_FIELD, reg); + wl->fw[AC_BE_Q].count = FIELD_GET(BE_AC_COUNT_FIELD, reg); + wl->fw[AC_VI_Q].count = FIELD_GET(VI_AC_COUNT_FIELD, reg); + wl->fw[AC_VO_Q].count = FIELD_GET(VO_AC_COUNT_FIELD, reg); + + wl->fw[AC_BK_Q].acm = FIELD_GET(BK_AC_ACM_STAT_FIELD, reg); + wl->fw[AC_BE_Q].acm = FIELD_GET(BE_AC_ACM_STAT_FIELD, reg); + wl->fw[AC_VI_Q].acm = FIELD_GET(VI_AC_ACM_STAT_FIELD, reg); + wl->fw[AC_VO_Q].acm = FIELD_GET(VO_AC_ACM_STAT_FIELD, reg); } static inline u8 ac_change(struct wilc *wilc, u8 *ac) { do { - if (wilc->txq[*ac].fw.acm == 0) + if (wilc->fw[*ac].acm == 0) return 0; (*ac)++; } while (*ac < NQUEUES); @@ -920,7 +920,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) kfree(tqe); } while (--entries); for (i = 0; i < NQUEUES; i++) - wilc->txq[i].fw.count += ac_pkt_num_to_chip[i]; + wilc->fw[i].count += ac_pkt_num_to_chip[i]; acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/wireless/microchip/wilc1000/wlan.h index eb7978166d73e..9b33262909e2f 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.h +++ b/drivers/net/wireless/microchip/wilc1000/wlan.h @@ -341,7 +341,6 @@ struct txq_fw_recv_queue_stat { struct txq_handle { struct txq_entry_t txq_head; u16 count; - struct txq_fw_recv_queue_stat fw; }; struct rxq_entry_t { From patchwork Thu Dec 23 01:14:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697807 X-Patchwork-Delegate: kvalo@adurom.com 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 05472C433EF for ; Thu, 23 Dec 2021 01:14:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238586AbhLWBOH (ORCPT ); Wed, 22 Dec 2021 20:14:07 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:17724 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229977AbhLWBOG (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvKRPg1r8DnHgLz9uTsd8CBTF3hyA386sin/BGCA3+pABmTC/MMOPAidllHc49Lyg8vU82CAz1L5iTJI+eUXDHHMJHNXjXwX10OCCI+IuAPAil+xXSpY49/latOl7ILwS1Qzl0IvqEJT49Zt2WoJ2ILX16DMDTaGdwDw/COR5tcz4JsZWkwVffG3bAvjeeC/jUw== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The functions are almost identical, so factor the common code into new function wilc_wlan_cfg_apply_wid(). No functional change. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/wlan.c | 79 ++++++++++--------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/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; } -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 wid, + 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 start, u16 wid, u8 *buffer, wilc->cfg_frame_offset = 0; offset = wilc->cfg_frame_offset; - ret_size = wilc_wlan_cfg_set_wid(wilc->cfg_frame.frame, offset, - wid, buffer, buffer_size); + if (set) + ret_size = wilc_wlan_cfg_set_wid(wilc->cfg_frame.frame, offset, + wid, buffer, buffer_size); + else + ret_size = wilc_wlan_cfg_get_wid(wilc->cfg_frame.frame, offset, + wid); offset += ret_size; wilc->cfg_frame_offset = offset; @@ -1299,9 +1323,11 @@ int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, return ret_size; } - netdev_dbg(vif->ndev, "%s: seqno[%d]\n", __func__, wilc->cfg_seq_no); + netdev_dbg(vif->ndev, "%s: %s seqno[%d]\n", + __func__, set ? "set" : "get", wilc->cfg_seq_no); - if (wilc_wlan_cfg_commit(vif, WILC_CFG_SET, drv_handler)) + if (wilc_wlan_cfg_commit(vif, set ? WILC_CFG_SET : WILC_CFG_QUERY, + drv_handler)) ret_size = 0; if (!wait_for_completion_timeout(&wilc->cfg_event, @@ -1317,41 +1343,18 @@ int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, return ret_size; } +int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, + u32 buffer_size, int commit, u32 drv_handler) +{ + return wilc_wlan_cfg_apply_wid(vif, start, wid, buffer, buffer_size, + commit, drv_handler, true); +} + int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, u16 wid, int commit, u32 drv_handler) { - u32 offset; - int ret_size; - struct wilc *wilc = vif->wilc; - - mutex_lock(&wilc->cfg_cmd_lock); - - if (start) - wilc->cfg_frame_offset = 0; - - offset = wilc->cfg_frame_offset; - ret_size = wilc_wlan_cfg_get_wid(wilc->cfg_frame.frame, offset, wid); - offset += ret_size; - wilc->cfg_frame_offset = offset; - - if (!commit) { - mutex_unlock(&wilc->cfg_cmd_lock); - return ret_size; - } - - if (wilc_wlan_cfg_commit(vif, WILC_CFG_QUERY, drv_handler)) - ret_size = 0; - - if (!wait_for_completion_timeout(&wilc->cfg_event, - WILC_CFG_PKTS_TIMEOUT)) { - netdev_dbg(vif->ndev, "%s: Timed Out\n", __func__); - ret_size = 0; - } - wilc->cfg_frame_offset = 0; - wilc->cfg_seq_no += 1; - mutex_unlock(&wilc->cfg_cmd_lock); - - return ret_size; + return wilc_wlan_cfg_apply_wid(vif, start, wid, NULL, 0, + commit, drv_handler, false); } int wilc_send_config_pkt(struct wilc_vif *vif, u8 mode, struct wid *wids, From patchwork Thu Dec 23 01:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697837 X-Patchwork-Delegate: kvalo@adurom.com 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 1229CC433FE for ; Thu, 23 Dec 2021 01:15:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346629AbhLWBPq (ORCPT ); Wed, 22 Dec 2021 20:15:46 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27468 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346270AbhLWBOy (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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvCKFafSZUZYOu1P05CEj+Zsb9CK5JKRSqsrljNdImB023LgVhJEGXKH0RMK5+rzygP7Kr/ZNSpO4YzuYBgPGjO6yc2LKBDTr7yb9UlyMnNUywGeQc90+SCr5T5+Dm4KakrmZ5IjG6vTZ4E3Eg1Aww2XHbHyLCzySlK+WJCrzBfJXss5zZvn0gQj6KXHjFICusg== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Factor common tx packet-done handling code into a function. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/wlan.c | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 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); } +static void wilc_wlan_tx_packet_done(struct txq_entry_t *tqe, int status) +{ + tqe->status = status; + if (tqe->tx_complete_func) + tqe->tx_complete_func(tqe->priv, tqe->status); + if (tqe->ack_idx != NOT_TCP_ACK && tqe->ack_idx < MAX_PENDING_ACKS) + tqe->vif->ack_filter.pending_acks[tqe->ack_idx].txqe = NULL; + kfree(tqe); +} + static void wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) { struct wilc_vif *vif = netdev_priv(dev); @@ -220,11 +230,7 @@ static void wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) tqe = f->pending_acks[i].txqe; if (tqe) { wilc_wlan_txq_remove(wilc, tqe->q_num, tqe); - tqe->status = 1; - if (tqe->tx_complete_func) - tqe->tx_complete_func(tqe->priv, - tqe->status); - kfree(tqe); + wilc_wlan_tx_packet_done(tqe, 1); } } } @@ -911,13 +917,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) tqe->buffer, tqe->buffer_size); offset += vmm_sz; i++; - tqe->status = 1; - if (tqe->tx_complete_func) - tqe->tx_complete_func(tqe->priv, tqe->status); - if (tqe->ack_idx != NOT_TCP_ACK && - tqe->ack_idx < MAX_PENDING_ACKS) - vif->ack_filter.pending_acks[tqe->ack_idx].txqe = NULL; - kfree(tqe); + wilc_wlan_tx_packet_done(tqe, 1); } while (--entries); for (i = 0; i < NQUEUES; i++) wilc->fw[i].count += ac_pkt_num_to_chip[i]; @@ -1236,11 +1236,8 @@ void wilc_wlan_cleanup(struct net_device *dev) wilc->quit = 1; for (ac = 0; ac < NQUEUES; ac++) { - while ((tqe = wilc_wlan_txq_remove_from_head(wilc, ac))) { - if (tqe->tx_complete_func) - tqe->tx_complete_func(tqe->priv, 0); - kfree(tqe); - } + while ((tqe = wilc_wlan_txq_remove_from_head(wilc, ac))) + wilc_wlan_tx_packet_done(tqe, 0); } while ((rqe = wilc_wlan_rxq_remove(wilc))) From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697824 X-Patchwork-Delegate: kvalo@adurom.com 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 C93A3C433F5 for ; Thu, 23 Dec 2021 01:15:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346199AbhLWBPN (ORCPT ); Wed, 22 Dec 2021 20:15:13 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18104 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241147AbhLWBOJ (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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvDVRIOLZX/uaqgwgepdd/OprcOg8eS0wCEoSluFg9GT2EE9PHLrMK+sWkumqROGfcg1jVIacE+3XCYucS1+AoWeHVMFxKkXf4xz8FgMkzRjCTEK32TqwwNRrxxcMbWx0fQGIcRXEbaoXb9BmB2TZym/5F2qNQOGyy21oM9A+o9SUt8qVTHCnHaIVl3ALh5HFlg== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This is just to improve code clarity. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 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); } +static void wilc_wlan_txq_drop_net_pkt(struct txq_entry_t *tqe) +{ + struct wilc *wilc = tqe->vif->wilc; + + wilc_wlan_txq_remove(wilc, tqe->q_num, tqe); + wilc_wlan_tx_packet_done(tqe, 1); +} + static void wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) { struct wilc_vif *vif = netdev_priv(dev); @@ -228,10 +236,8 @@ static void wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) struct txq_entry_t *tqe; tqe = f->pending_acks[i].txqe; - if (tqe) { - wilc_wlan_txq_remove(wilc, tqe->q_num, tqe); - wilc_wlan_tx_packet_done(tqe, 1); - } + if (tqe) + wilc_wlan_txq_drop_net_pkt(tqe); } } f->pending_acks_idx = 0; From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697822 X-Patchwork-Delegate: kvalo@adurom.com 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 374FFC433FE for ; Thu, 23 Dec 2021 01:15:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346083AbhLWBPH (ORCPT ); Wed, 22 Dec 2021 20:15:07 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18028 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239866AbhLWBOK (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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvDKrArIMv0ekRFhsmfMLkKZAX5foC3EIyVvusbxrwy0G4rOImm0QqeNxD5K9LJ+WXaZDsNQsAFlQRJjojhhxrTyhUMjHuiBV8s8RQ/46enSKaA5bsuMxuYazZGW5nVWFhvcqsiZ/d2FSfk3SZOIWeOaTkDD+31tSqawxNGSS4OiDRuZX/3b+zqgN/4W9bgbwQA== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Packet drops are important events so we should remember to count them. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 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) static void wilc_wlan_txq_drop_net_pkt(struct txq_entry_t *tqe) { - struct wilc *wilc = tqe->vif->wilc; + struct wilc_vif *vif = tqe->vif; + struct wilc *wilc = vif->wilc; + + vif->ndev->stats.tx_dropped++; wilc_wlan_txq_remove(wilc, tqe->q_num, tqe); wilc_wlan_tx_packet_done(tqe, 1); From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697856 X-Patchwork-Delegate: kvalo@adurom.com 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 21B43C433F5 for ; Thu, 23 Dec 2021 01:16:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238970AbhLWBQx (ORCPT ); Wed, 22 Dec 2021 20:16:53 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18066 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241485AbhLWBOL (ORCPT ); Wed, 22 Dec 2021 20:14:11 -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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvH8QYPm77HLoqzd6ipELrLw2hwsFT5BXPNL6oemUucAN0NCztY18dpLknIyWtZNrLRCDESJBCsE8mIZKewcdLRAa1rrH1/izV1K2APE0q4A9RJOPNsCLtXazbgRqml7YksQDI5yMR4nTy80lGtdHlPAJLEoKmveMJB7EtAtM+UF1EplFX7gJ2voIbRKOikt/0Q== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The queue type for management packets was initialized to AC_BE_Q (best-effort queue) but the packet was then actually added to the AC_VO_Q queue (voice, or highest-priority queue). This fixes the inconsistency by setting the type to AC_VO_Q. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 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 = buffer_size; tqe->tx_complete_func = tx_complete_fn; tqe->priv = priv; - tqe->q_num = AC_BE_Q; + tqe->q_num = AC_VO_Q; tqe->ack_idx = NOT_TCP_ACK; tqe->vif = vif; wilc_wlan_txq_add_to_tail(dev, AC_VO_Q, tqe); From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697825 X-Patchwork-Delegate: kvalo@adurom.com 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 BEEDCC4332F for ; Thu, 23 Dec 2021 01:15:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346295AbhLWBPO (ORCPT ); Wed, 22 Dec 2021 20:15:14 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:17990 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238855AbhLWBOI (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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvCb1xlyXRSrVqQqxdc6y8Gj6yOsjIp2cOckDjzQ6eQStIL96U5Dw3ROdQNJIrQjv46xS5QYahfsOrfwiSRwctE9BA6Pm2r1K1fPP82yflmMomDmyZdvLZWYhaInErFLLAIdvPxLJ8rsgLaNG/LgaBTXhbpe1t9wdzMnXlIWkJFOGAo0JjKpAThfBPfTWcVW5TQ== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This patch just adds some helper variables. I suppose they improve readability, but the real reason for this patch is to make the forthcoming sk_buff rework patch shorter and more obvious. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 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) static void wilc_wlan_tx_packet_done(struct txq_entry_t *tqe, int status) { + struct wilc_vif *vif = tqe->vif; + int ack_idx = tqe->ack_idx; + tqe->status = status; if (tqe->tx_complete_func) tqe->tx_complete_func(tqe->priv, tqe->status); - if (tqe->ack_idx != NOT_TCP_ACK && tqe->ack_idx < MAX_PENDING_ACKS) - tqe->vif->ack_filter.pending_acks[tqe->ack_idx].txqe = NULL; + if (ack_idx != NOT_TCP_ACK && ack_idx < MAX_PENDING_ACKS) + vif->ack_filter.pending_acks[ack_idx].txqe = NULL; kfree(tqe); } From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697821 X-Patchwork-Delegate: kvalo@adurom.com 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 C2273C433FE for ; Thu, 23 Dec 2021 01:15:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346042AbhLWBPE (ORCPT ); Wed, 22 Dec 2021 20:15:04 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18142 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345727AbhLWBOR (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvCJLlBTC4xumxACeWN+4uQ8hRebKr63nOnFFNqzj5hYSEwCbOzbV+zULcwe6Kk0CVpAqADDFfmHNMM/vUvf/WXTloE9Brp85VBtF3Xk1MuChiO1UWg7sRWOwhdC9Xs3hFoQ5EhksYXzYzSsZK/vu/fw2uBtCmluiMdMD+WDsBaV8kYyvFvS2lEPzmCBhoBc0VQ== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This ensures that the fields are initialized consistently for all packets on the tx queues. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/wlan.c | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 77dd91c23faad..781c40f2c930c 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -12,8 +12,12 @@ #define WAKE_UP_TRIAL_RETRY 10000 +#define NOT_TCP_ACK (-1) + static const u8 factors[NQUEUES] = {1, 1, 1, 1}; +static void tcp_process(struct net_device *, struct txq_entry_t *); + static inline bool is_wilc1000(u32 id) { return (id & (~WILC_CHIP_REV_FIELD)) == WILC_1000_BASE_ID; @@ -60,13 +64,26 @@ wilc_wlan_txq_remove_from_head(struct wilc *wilc, u8 q_num) return tqe; } -static void wilc_wlan_txq_add_to_tail(struct net_device *dev, u8 q_num, +static void init_txq_entry(struct txq_entry_t *tqe, struct wilc_vif *vif, + u8 type, enum ip_pkt_priority q_num) +{ + tqe->vif = vif; + tqe->q_num = q_num; + tqe->type = type; + tqe->ack_idx = NOT_TCP_ACK; +} + +static void wilc_wlan_txq_add_to_tail(struct net_device *dev, u8 type, u8 q_num, struct txq_entry_t *tqe) { unsigned long flags; struct wilc_vif *vif = netdev_priv(dev); struct wilc *wilc = vif->wilc; + init_txq_entry(tqe, vif, type, q_num); + if (type == WILC_NET_PKT && vif->ack_filter.enabled) + tcp_process(dev, tqe); + spin_lock_irqsave(&wilc->txq_spinlock, flags); list_add_tail(&tqe->list, &wilc->txq[q_num].txq_head.list); @@ -78,12 +95,14 @@ static void wilc_wlan_txq_add_to_tail(struct net_device *dev, u8 q_num, wake_up_interruptible(&wilc->txq_event); } -static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, u8 q_num, +static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, u8 type, u8 q_num, struct txq_entry_t *tqe) { unsigned long flags; struct wilc *wilc = vif->wilc; + init_txq_entry(tqe, vif, type, q_num); + mutex_lock(&wilc->txq_add_to_head_cs); spin_lock_irqsave(&wilc->txq_spinlock, flags); @@ -97,8 +116,6 @@ static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, u8 q_num, wake_up_interruptible(&wilc->txq_event); } -#define NOT_TCP_ACK (-1) - static inline void add_tcp_session(struct wilc_vif *vif, u32 src_prt, u32 dst_prt, u32 seq) { @@ -281,16 +298,12 @@ static int wilc_wlan_txq_add_cfg_pkt(struct wilc_vif *vif, u8 *buffer, return 0; } - tqe->type = WILC_CFG_PKT; tqe->buffer = buffer; tqe->buffer_size = buffer_size; tqe->tx_complete_func = NULL; tqe->priv = NULL; - tqe->q_num = AC_VO_Q; - tqe->ack_idx = NOT_TCP_ACK; - tqe->vif = vif; - wilc_wlan_txq_add_to_head(vif, AC_VO_Q, tqe); + wilc_wlan_txq_add_to_head(vif, WILC_CFG_PKT, AC_VO_Q, tqe); return 1; } @@ -452,15 +465,12 @@ int wilc_wlan_txq_add_net_pkt(struct net_device *dev, tx_complete_fn(tx_data, 0); return 0; } - tqe->type = WILC_NET_PKT; tqe->buffer = buffer; tqe->buffer_size = buffer_size; tqe->tx_complete_func = tx_complete_fn; tqe->priv = tx_data; - tqe->vif = vif; q_num = ac_classify(wilc, tx_data->skb); - tqe->q_num = q_num; if (ac_change(wilc, &q_num)) { tx_complete_fn(tx_data, 0); kfree(tqe); @@ -468,10 +478,7 @@ int wilc_wlan_txq_add_net_pkt(struct net_device *dev, } if (is_ac_q_limit(wilc, q_num)) { - tqe->ack_idx = NOT_TCP_ACK; - if (vif->ack_filter.enabled) - tcp_process(dev, tqe); - wilc_wlan_txq_add_to_tail(dev, q_num, tqe); + wilc_wlan_txq_add_to_tail(dev, WILC_NET_PKT, q_num, tqe); } else { tx_complete_fn(tx_data, 0); kfree(tqe); @@ -505,15 +512,11 @@ int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer, tx_complete_fn(priv, 0); return 0; } - tqe->type = WILC_MGMT_PKT; tqe->buffer = buffer; tqe->buffer_size = buffer_size; tqe->tx_complete_func = tx_complete_fn; tqe->priv = priv; - tqe->q_num = AC_VO_Q; - tqe->ack_idx = NOT_TCP_ACK; - tqe->vif = vif; - wilc_wlan_txq_add_to_tail(dev, AC_VO_Q, tqe); + wilc_wlan_txq_add_to_tail(dev, WILC_MGMT_PKT, AC_VO_Q, tqe); return 1; } From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697846 X-Patchwork-Delegate: kvalo@adurom.com 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 6378BC433FE for ; Thu, 23 Dec 2021 01:16:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345885AbhLWBOM (ORCPT ); Wed, 22 Dec 2021 20:14:12 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18058 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241539AbhLWBOL (ORCPT ); Wed, 22 Dec 2021 20:14:11 -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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvMpnkY6SXEETBOQObcjnMOudSn0Sbh67pCS5DMiOw3ECgFuH/G/UpuN+chI5OwysiIgY+5fa81Ji5w2rnvCHgzL9XvNa5Gi3mrC8WCw3DNCHfI9kzP6xXAFlFRDhuSXsgfyrHZllD71DIoTn9gy5Sp8E7ijoN9oMZyBbpO6AwSWhyKlqE+YPUzcRPqRFD6/rvA== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This is in preparation of converting the tx queue to struct sk_buffs entries. atomic_t isn't necessary for the current code, but it is a safe change. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/netdev.c | 3 ++- drivers/net/wireless/microchip/wilc1000/netdev.h | 2 +- drivers/net/wireless/microchip/wilc1000/wlan.c | 12 ++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c b/drivers/net/wireless/microchip/wilc1000/netdev.c index 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)); 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; struct txq_handle txq[NQUEUES]; - int txq_entries; + atomic_t txq_entries; struct txq_fw_recv_queue_stat fw[NQUEUES]; struct wilc_tx_queue_status tx_q_limit; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 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 -= 1; + atomic_dec(&wilc->txq_entries); wilc->txq[q_num].count--; } @@ -57,7 +57,7 @@ wilc_wlan_txq_remove_from_head(struct wilc *wilc, u8 q_num) tqe = list_first_entry(&wilc->txq[q_num].txq_head.list, struct txq_entry_t, list); list_del(&tqe->list); - wilc->txq_entries -= 1; + atomic_dec(&wilc->txq_entries); wilc->txq[q_num].count--; } spin_unlock_irqrestore(&wilc->txq_spinlock, flags); @@ -87,7 +87,7 @@ static void wilc_wlan_txq_add_to_tail(struct net_device *dev, u8 type, u8 q_num, spin_lock_irqsave(&wilc->txq_spinlock, flags); list_add_tail(&tqe->list, &wilc->txq[q_num].txq_head.list); - wilc->txq_entries += 1; + atomic_inc(&wilc->txq_entries); wilc->txq[q_num].count++; spin_unlock_irqrestore(&wilc->txq_spinlock, flags); @@ -108,7 +108,7 @@ static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, u8 type, u8 q_num, spin_lock_irqsave(&wilc->txq_spinlock, flags); list_add(&tqe->list, &wilc->txq[q_num].txq_head.list); - wilc->txq_entries += 1; + atomic_inc(&wilc->txq_entries); wilc->txq[q_num].count++; spin_unlock_irqrestore(&wilc->txq_spinlock, flags); @@ -484,7 +484,7 @@ int wilc_wlan_txq_add_net_pkt(struct net_device *dev, kfree(tqe); } - return wilc->txq_entries; + return atomic_read(&wilc->txq_entries); } int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer, @@ -952,7 +952,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) mutex_unlock(&wilc->txq_add_to_head_cs); out_update_cnt: - *txq_count = wilc->txq_entries; + *txq_count = atomic_read(&wilc->txq_entries); return ret; } From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697854 X-Patchwork-Delegate: kvalo@adurom.com 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 444E1C43219 for ; Thu, 23 Dec 2021 01:16:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346243AbhLWBQq (ORCPT ); Wed, 22 Dec 2021 20:16:46 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18168 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345744AbhLWBOS (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvCI5wdCf6k9nSTiV8Y5orYAp30zrmhpmPpWiYcIZ7KjBx7mrhBRbhHE8NiP1IDsjpJ8qs9/442dFh+0K0Pmp3hUHC8lODUdX+ntzBnLYE2IaWJX4eai4FbMT34Qw3MGNWEykZaWB8GGGF2xXywET1MbC3Eg9qZALuiIpEzCxN9/3fXt6/4iQxm46velendSlig== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This cleanup makes the switch to sk_buff queues easier. There is no functional change. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 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 *vif, int type, struct wilc *wilc = vif->wilc; struct wilc_cfg_frame *cfg = &wilc->cfg_frame; int t_len = wilc->cfg_frame_offset + sizeof(struct wilc_cfg_cmd_hdr); + struct wilc_cfg_cmd_hdr *hdr; - if (type == WILC_CFG_SET) - cfg->hdr.cmd_type = 'W'; - else - cfg->hdr.cmd_type = 'Q'; - - cfg->hdr.seq_no = wilc->cfg_seq_no % 256; - cfg->hdr.total_len = cpu_to_le16(t_len); - cfg->hdr.driver_handler = cpu_to_le32(drv_handler); + hdr = &cfg->hdr; + hdr->cmd_type = (type == WILC_CFG_SET) ? 'W' : 'Q'; + hdr->seq_no = wilc->cfg_seq_no % 256; + hdr->total_len = cpu_to_le16(t_len); + hdr->driver_handler = cpu_to_le32(drv_handler); wilc->cfg_seq_no = cfg->hdr.seq_no; if (!wilc_wlan_txq_add_cfg_pkt(vif, (u8 *)&cfg->hdr, t_len)) From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697823 X-Patchwork-Delegate: kvalo@adurom.com 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 33D51C433EF for ; Thu, 23 Dec 2021 01:15:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346168AbhLWBPK (ORCPT ); Wed, 22 Dec 2021 20:15:10 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:17976 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239208AbhLWBOJ (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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvGypGrhqGxl/EY3id+trAVDjgRqjwx0dK6tKpD39ADl8w+Ha58BsfUJSRdeVHdNMmSbtm+kB4TnuFscnap7cx5MDhnALE6m+re/SYVfZp3JrnHUgS+SSyKh6AQmtV/vCgVm2d+KQKvbwkut+a3BiLgtc7D++R9UZxKbrzqsgt+6ZwtRHjpUIXCuWdysFUmy4WQ== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Always keep the config packet sequence number in the valid range from 0..255. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 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, hdr = &cfg->hdr; hdr->cmd_type = (type == WILC_CFG_SET) ? 'W' : 'Q'; - hdr->seq_no = wilc->cfg_seq_no % 256; + hdr->seq_no = wilc->cfg_seq_no; hdr->total_len = cpu_to_le16(t_len); hdr->driver_handler = cpu_to_le32(drv_handler); - wilc->cfg_seq_no = cfg->hdr.seq_no; if (!wilc_wlan_txq_add_cfg_pkt(vif, (u8 *)&cfg->hdr, t_len)) return -1; @@ -1347,7 +1346,7 @@ static int wilc_wlan_cfg_apply_wid(struct wilc_vif *vif, int start, u16 wid, } wilc->cfg_frame_offset = 0; - wilc->cfg_seq_no += 1; + wilc->cfg_seq_no = (wilc->cfg_seq_no + 1) % 256; mutex_unlock(&wilc->cfg_cmd_lock); return ret_size; From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697810 X-Patchwork-Delegate: kvalo@adurom.com 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 114BFC433F5 for ; Thu, 23 Dec 2021 01:14:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345872AbhLWBOL (ORCPT ); Wed, 22 Dec 2021 20:14:11 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18022 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241033AbhLWBOK (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvOR25dwhR8xVxUiJRPvfwopFiHKgJmz5nG7pPD2E+83y/m+RHtKjsCtpgPwMsMrHiC8Af1aM9ryNHWuHG4x4Wz1++nSOzK3jSJ6JgMnkw0hAX3NkgydUr1dORcy+DcVGZMDc/gQHHtTAy02gev1cQtcyxLUgxm3I224ZUAec/YSM+c/2r2enVWr1iMriACv+pQ== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Granted, this case is mostly theoretical as the queue should never be empty in this place, and hence tqe should never be NULL, but it's still wrong to count a packet that doesn't exist. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 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 = 0; tqe = wilc_wlan_txq_remove_from_head(wilc, vmm_entries_ac[i]); - ac_pkt_num_to_chip[vmm_entries_ac[i]]++; if (!tqe) break; + ac_pkt_num_to_chip[vmm_entries_ac[i]]++; vif = tqe->vif; if (vmm_table[i] == 0) break; From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697812 X-Patchwork-Delegate: kvalo@adurom.com 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 930C2C433EF for ; Thu, 23 Dec 2021 01:14:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345892AbhLWBOS (ORCPT ); Wed, 22 Dec 2021 20:14:18 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18304 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345743AbhLWBOO (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvJVai0WXMG1+HQN6ov2CuUX1YfqzWiuT0Ki8nekpKI3Qgbj3UWNGvbRSOCBP2hth34cttp0FYFVAL1+SeTew/1FmVFT3z6VRoH4F7M3a6ZNBxLo7Gh+ucGBBRLDR1YvRwWEqACi2Ym6izrJBIiZZI2ElVkMbqYuvQ8U+2X8cf4UQe62Rc9J/M64pY0B606ua/Q== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This is in preparation of the next patch, which removes struct wilc_skb_tx_cb in favor of struct sk_buffs. That change requires moving the driver-private state for tx packets from struct txq_entry_t to the "control buffer" (cb field) of struct sk_buff. Making that move now makes the next patch a bit smaller and easier to understand. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/wlan.c | 36 +++++++++++-------- .../net/wireless/microchip/wilc1000/wlan.h | 7 ++++ 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 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 = WILC_SKB_TX_CB(tqe); + tqe->vif = vif; - tqe->q_num = q_num; - tqe->type = type; - tqe->ack_idx = NOT_TCP_ACK; + tx_cb->type = type; + tx_cb->q_num = q_num; + tx_cb->ack_idx = NOT_TCP_ACK; } static void wilc_wlan_txq_add_to_tail(struct net_device *dev, u8 type, u8 q_num, @@ -143,6 +145,7 @@ static inline void add_tcp_pending_ack(struct wilc_vif *vif, u32 ack, u32 session_index, struct txq_entry_t *txqe) { + struct wilc_skb_tx_cb *tx_cb = WILC_SKB_TX_CB(txqe); struct tcp_ack_filter *f = &vif->ack_filter; u32 i = f->pending_base + f->pending_acks_idx; @@ -150,7 +153,7 @@ static inline void add_tcp_pending_ack(struct wilc_vif *vif, u32 ack, f->pending_acks[i].ack_num = ack; f->pending_acks[i].txqe = txqe; f->pending_acks[i].session_index = session_index; - txqe->ack_idx = i; + tx_cb->ack_idx = i; f->pending_acks_idx++; } } @@ -210,7 +213,8 @@ static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe) static void wilc_wlan_tx_packet_done(struct txq_entry_t *tqe, int status) { struct wilc_vif *vif = tqe->vif; - int ack_idx = tqe->ack_idx; + struct wilc_skb_tx_cb *tx_cb = WILC_SKB_TX_CB(tqe); + int ack_idx = tx_cb->ack_idx; tqe->status = status; if (tqe->tx_complete_func) @@ -224,10 +228,11 @@ static void wilc_wlan_txq_drop_net_pkt(struct txq_entry_t *tqe) { struct wilc_vif *vif = tqe->vif; struct wilc *wilc = vif->wilc; + struct wilc_skb_tx_cb *tx_cb = WILC_SKB_TX_CB(tqe); vif->ndev->stats.tx_dropped++; - wilc_wlan_txq_remove(wilc, tqe->q_num, tqe); + wilc_wlan_txq_remove(wilc, tx_cb->q_num, tqe); wilc_wlan_tx_packet_done(tqe, 1); } @@ -728,6 +733,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) bool max_size_over = 0, ac_exist = 0; int vmm_sz = 0; struct txq_entry_t *tqe_q[NQUEUES]; + struct wilc_skb_tx_cb *tx_cb; int ret = 0; int counter; int timeout; @@ -772,9 +778,10 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) break; } - if (tqe_q[ac]->type == WILC_CFG_PKT) + tx_cb = WILC_SKB_TX_CB(tqe_q[ac]); + if (tx_cb->type == WILC_CFG_PKT) vmm_sz = ETH_CONFIG_PKT_HDR_OFFSET; - else if (tqe_q[ac]->type == WILC_NET_PKT) + else if (tx_cb->type == WILC_NET_PKT) vmm_sz = ETH_ETHERNET_HDR_OFFSET; else vmm_sz = HOST_HDR_OFFSET; @@ -787,7 +794,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) break; } vmm_table[i] = vmm_sz / 4; - if (tqe_q[ac]->type == WILC_CFG_PKT) + if (tx_cb->type == WILC_CFG_PKT) vmm_table[i] |= BIT(10); cpu_to_le32s(&vmm_table[i]); @@ -898,6 +905,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) ac_pkt_num_to_chip[vmm_entries_ac[i]]++; vif = tqe->vif; + tx_cb = WILC_SKB_TX_CB(tqe); if (vmm_table[i] == 0) break; @@ -905,20 +913,20 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) vmm_sz = FIELD_GET(WILC_VMM_BUFFER_SIZE, vmm_table[i]); vmm_sz *= 4; - if (tqe->type == WILC_MGMT_PKT) + if (tx_cb->type == WILC_MGMT_PKT) mgmt_ptk = 1; - header = (FIELD_PREP(WILC_VMM_HDR_TYPE, tqe->type) | + header = (FIELD_PREP(WILC_VMM_HDR_TYPE, tx_cb->type) | FIELD_PREP(WILC_VMM_HDR_MGMT_FIELD, mgmt_ptk) | FIELD_PREP(WILC_VMM_HDR_PKT_SIZE, tqe->buffer_size) | FIELD_PREP(WILC_VMM_HDR_BUFF_SIZE, vmm_sz)); cpu_to_le32s(&header); memcpy(&txb[offset], &header, 4); - if (tqe->type == WILC_CFG_PKT) { + if (tx_cb->type == WILC_CFG_PKT) { buffer_offset = ETH_CONFIG_PKT_HDR_OFFSET; - } else if (tqe->type == WILC_NET_PKT) { - int prio = tqe->q_num; + } else if (tx_cb->type == WILC_NET_PKT) { + int prio = tx_cb->q_num; bssid = tqe->vif->bssid; buffer_offset = ETH_ETHERNET_HDR_OFFSET; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/wireless/microchip/wilc1000/wlan.h index 9b33262909e2f..295795a8060ac 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.h +++ b/drivers/net/wireless/microchip/wilc1000/wlan.h @@ -333,6 +333,13 @@ struct txq_entry_t { void (*tx_complete_func)(void *priv, int status); }; +#define wilc_skb_tx_cb txq_entry_t + +static inline struct wilc_skb_tx_cb *WILC_SKB_TX_CB(struct txq_entry_t *tqe) +{ + return (struct wilc_skb_tx_cb *)tqe; +} + struct txq_fw_recv_queue_stat { u8 acm; u8 count; From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697849 X-Patchwork-Delegate: kvalo@adurom.com 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 BF784C433EF for ; Thu, 23 Dec 2021 01:16:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346033AbhLWBQj (ORCPT ); Wed, 22 Dec 2021 20:16:39 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18456 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345834AbhLWBOX (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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvBaesWnzz8DgI6OeP3k/b9yhMUCRwjat2o7MKZjMnxFxIBda51KS6HT1H7X8BkNArp3AvLUMmnRzfwdCXOIycATgXanD5QiuY1rEl5kVos+GFWk1ATXVwzUUPyUeOOhy96QajSkw3494YXhQ3tpL7YXvKNfP5HuOwThTCp5QB5ML+2rhByuBof1UoDku6zNtjA== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Convert the transmit path to use normal socket-buffer operations rather than driver-specific structures and functions. This ends up deleting a fair amount of code and otherwise mostly consists of switching struct txq_entry_t to struct sk_buff. Signed-off-by: David Mosberger-Tang --- .../wireless/microchip/wilc1000/cfg80211.c | 35 +-- drivers/net/wireless/microchip/wilc1000/mon.c | 36 +-- .../net/wireless/microchip/wilc1000/netdev.c | 26 +- .../net/wireless/microchip/wilc1000/netdev.h | 7 +- .../net/wireless/microchip/wilc1000/wlan.c | 281 +++++++----------- .../net/wireless/microchip/wilc1000/wlan.h | 50 +--- 6 files changed, 137 insertions(+), 298 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.c b/drivers/net/wireless/microchip/wilc1000/cfg80211.c index be387a8abb6af..d352b7dd03283 100644 --- a/drivers/net/wireless/microchip/wilc1000/cfg80211.c +++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.c @@ -1038,14 +1038,6 @@ void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size) cfg80211_rx_mgmt(&priv->wdev, freq, 0, buff, size, 0); } -static void wilc_wfi_mgmt_tx_complete(void *priv, int status) -{ - struct wilc_p2p_mgmt_data *pv_data = priv; - - kfree(pv_data->buff); - kfree(pv_data); -} - static void wilc_wfi_remain_on_channel_expired(void *data, u64 cookie) { struct wilc_vif *vif = data; @@ -1124,7 +1116,7 @@ static int mgmt_tx(struct wiphy *wiphy, const u8 *buf = params->buf; size_t len = params->len; const struct ieee80211_mgmt *mgmt; - struct wilc_p2p_mgmt_data *mgmt_tx; + struct sk_buff *skb; struct wilc_vif *vif = netdev_priv(wdev->netdev); struct wilc_priv *priv = &vif->priv; struct host_if_drv *wfi_drv = priv->hif_drv; @@ -1141,20 +1133,11 @@ static int mgmt_tx(struct wiphy *wiphy, if (!ieee80211_is_mgmt(mgmt->frame_control)) goto out; - mgmt_tx = kmalloc(sizeof(*mgmt_tx), GFP_KERNEL); - if (!mgmt_tx) { - ret = -ENOMEM; - goto out; - } - - mgmt_tx->buff = kmemdup(buf, len, GFP_KERNEL); - if (!mgmt_tx->buff) { - ret = -ENOMEM; - kfree(mgmt_tx); - goto out; - } + skb = wilc_wlan_alloc_skb(vif, len); + if (!skb) + return -ENOMEM; - mgmt_tx->size = len; + skb_put_data(skb, buf, len); if (ieee80211_is_probe_resp(mgmt->frame_control)) { wilc_set_mac_chnl_num(vif, chan->hw_value); @@ -1176,7 +1159,7 @@ static int mgmt_tx(struct wiphy *wiphy, goto out_set_timeout; vendor_ie = cfg80211_find_vendor_ie(WLAN_OUI_WFA, WLAN_OUI_TYPE_WFA_P2P, - mgmt_tx->buff + ie_offset, + skb->data + ie_offset, len - ie_offset); if (!vendor_ie) goto out_set_timeout; @@ -1189,9 +1172,7 @@ static int mgmt_tx(struct wiphy *wiphy, out_txq_add_pkt: - wilc_wlan_txq_add_mgmt_pkt(wdev->netdev, mgmt_tx, - mgmt_tx->buff, mgmt_tx->size, - wilc_wfi_mgmt_tx_complete); + wilc_wlan_txq_add_mgmt_pkt(wdev->netdev, skb); out: @@ -1732,7 +1713,7 @@ int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type, wl->hif_func = ops; for (i = 0; i < NQUEUES; i++) - INIT_LIST_HEAD(&wl->txq[i].txq_head.list); + skb_queue_head_init(&wl->txq[i]); INIT_LIST_HEAD(&wl->rxq_head.list); INIT_LIST_HEAD(&wl->vif_list); diff --git a/drivers/net/wireless/microchip/wilc1000/mon.c b/drivers/net/wireless/microchip/wilc1000/mon.c index 6bd63934c2d84..0b1c4f266cca5 100644 --- a/drivers/net/wireless/microchip/wilc1000/mon.c +++ b/drivers/net/wireless/microchip/wilc1000/mon.c @@ -95,45 +95,21 @@ void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size) netif_rx(skb); } -struct tx_complete_mon_data { - int size; - void *buff; -}; - -static void mgmt_tx_complete(void *priv, int status) -{ - struct tx_complete_mon_data *pv_data = priv; - /* - * in case of fully hosting mode, the freeing will be done - * in response to the cfg packet - */ - kfree(pv_data->buff); - - kfree(pv_data); -} - static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len) { - struct tx_complete_mon_data *mgmt_tx = NULL; + struct wilc_vif *vif = netdev_priv(dev); + struct sk_buff *skb; if (!dev) return -EFAULT; netif_stop_queue(dev); - mgmt_tx = kmalloc(sizeof(*mgmt_tx), GFP_ATOMIC); - if (!mgmt_tx) - return -ENOMEM; - - mgmt_tx->buff = kmemdup(buf, len, GFP_ATOMIC); - if (!mgmt_tx->buff) { - kfree(mgmt_tx); + skb = wilc_wlan_alloc_skb(vif, len); + if (!skb) return -ENOMEM; - } - - mgmt_tx->size = len; + skb_put_data(skb, buf, len); - wilc_wlan_txq_add_mgmt_pkt(dev, mgmt_tx, mgmt_tx->buff, mgmt_tx->size, - mgmt_tx_complete); + wilc_wlan_txq_add_mgmt_pkt(dev, skb); netif_wake_queue(dev); return 0; diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c b/drivers/net/wireless/microchip/wilc1000/netdev.c index 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); } -static void wilc_tx_complete(void *priv, int status) -{ - struct tx_complete_data *pv_data = priv; - - dev_kfree_skb(pv_data->skb); - kfree(pv_data); -} - netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev) { struct wilc_vif *vif = netdev_priv(ndev); struct wilc *wilc = vif->wilc; - struct tx_complete_data *tx_data = NULL; int queue_count; if (skb->dev != ndev) { @@ -738,22 +729,9 @@ netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev) return NETDEV_TX_OK; } - tx_data = kmalloc(sizeof(*tx_data), GFP_ATOMIC); - if (!tx_data) { - dev_kfree_skb(skb); - netif_wake_queue(ndev); - return NETDEV_TX_OK; - } - - tx_data->buff = skb->data; - tx_data->size = skb->len; - tx_data->skb = skb; - vif->netstats.tx_packets++; - vif->netstats.tx_bytes += tx_data->size; - queue_count = wilc_wlan_txq_add_net_pkt(ndev, tx_data, - tx_data->buff, tx_data->size, - wilc_tx_complete); + vif->netstats.tx_bytes += skb->len; + queue_count = wilc_wlan_txq_add_net_pkt(ndev, skb); if (queue_count > FLOW_CONTROL_UPPER_THRESHOLD) { int srcu_idx; diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.h b/drivers/net/wireless/microchip/wilc1000/netdev.h index 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; }; struct tcp_ack_filter { @@ -246,15 +246,14 @@ struct wilc { /* lock to protect issue of wid command to firmware */ struct mutex cfg_cmd_lock; - struct wilc_cfg_frame cfg_frame; - u32 cfg_frame_offset; + struct sk_buff *cfg_skb; u8 cfg_seq_no; u8 *rx_buffer; u32 rx_buffer_offset; u8 *tx_buffer; - struct txq_handle txq[NQUEUES]; + struct sk_buff_head txq[NQUEUES]; atomic_t txq_entries; struct txq_fw_recv_queue_stat fw[NQUEUES]; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index c352e939f1901..a970ddf43edf0 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -16,7 +16,7 @@ static const u8 factors[NQUEUES] = {1, 1, 1, 1}; -static void tcp_process(struct net_device *, struct txq_entry_t *); +static void tcp_process(struct net_device *, struct sk_buff *); static inline bool is_wilc1000(u32 id) { @@ -37,48 +37,19 @@ static inline void release_bus(struct wilc *wilc, enum bus_release release) mutex_unlock(&wilc->hif_cs); } -static void wilc_wlan_txq_remove(struct wilc *wilc, u8 q_num, - struct txq_entry_t *tqe) -{ - list_del(&tqe->list); - atomic_dec(&wilc->txq_entries); - wilc->txq[q_num].count--; -} - -static struct txq_entry_t * -wilc_wlan_txq_remove_from_head(struct wilc *wilc, u8 q_num) -{ - struct txq_entry_t *tqe = NULL; - unsigned long flags; - - spin_lock_irqsave(&wilc->txq_spinlock, flags); - - if (!list_empty(&wilc->txq[q_num].txq_head.list)) { - tqe = list_first_entry(&wilc->txq[q_num].txq_head.list, - struct txq_entry_t, list); - list_del(&tqe->list); - atomic_dec(&wilc->txq_entries); - wilc->txq[q_num].count--; - } - spin_unlock_irqrestore(&wilc->txq_spinlock, flags); - return tqe; -} - -static void init_txq_entry(struct txq_entry_t *tqe, struct wilc_vif *vif, +static void init_txq_entry(struct sk_buff *tqe, struct wilc_vif *vif, u8 type, enum ip_pkt_priority q_num) { struct wilc_skb_tx_cb *tx_cb = WILC_SKB_TX_CB(tqe); - tqe->vif = vif; tx_cb->type = type; tx_cb->q_num = q_num; tx_cb->ack_idx = NOT_TCP_ACK; } static void wilc_wlan_txq_add_to_tail(struct net_device *dev, u8 type, u8 q_num, - struct txq_entry_t *tqe) + struct sk_buff *tqe) { - unsigned long flags; struct wilc_vif *vif = netdev_priv(dev); struct wilc *wilc = vif->wilc; @@ -86,34 +57,24 @@ static void wilc_wlan_txq_add_to_tail(struct net_device *dev, u8 type, u8 q_num, if (type == WILC_NET_PKT && vif->ack_filter.enabled) tcp_process(dev, tqe); - spin_lock_irqsave(&wilc->txq_spinlock, flags); - - list_add_tail(&tqe->list, &wilc->txq[q_num].txq_head.list); + skb_queue_tail(&wilc->txq[q_num], tqe); atomic_inc(&wilc->txq_entries); - wilc->txq[q_num].count++; - - spin_unlock_irqrestore(&wilc->txq_spinlock, flags); wake_up_interruptible(&wilc->txq_event); } static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, u8 type, u8 q_num, - struct txq_entry_t *tqe) + struct sk_buff *tqe) { - unsigned long flags; struct wilc *wilc = vif->wilc; init_txq_entry(tqe, vif, type, q_num); mutex_lock(&wilc->txq_add_to_head_cs); - spin_lock_irqsave(&wilc->txq_spinlock, flags); - - list_add(&tqe->list, &wilc->txq[q_num].txq_head.list); + skb_queue_head(&wilc->txq[q_num], tqe); atomic_inc(&wilc->txq_entries); - wilc->txq[q_num].count++; - spin_unlock_irqrestore(&wilc->txq_spinlock, flags); mutex_unlock(&wilc->txq_add_to_head_cs); wake_up_interruptible(&wilc->txq_event); } @@ -143,7 +104,7 @@ static inline void update_tcp_session(struct wilc_vif *vif, u32 index, u32 ack) static inline void add_tcp_pending_ack(struct wilc_vif *vif, u32 ack, u32 session_index, - struct txq_entry_t *txqe) + struct sk_buff *txqe) { struct wilc_skb_tx_cb *tx_cb = WILC_SKB_TX_CB(txqe); struct tcp_ack_filter *f = &vif->ack_filter; @@ -158,9 +119,9 @@ static inline void add_tcp_pending_ack(struct wilc_vif *vif, u32 ack, } } -static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe) +static inline void tcp_process(struct net_device *dev, struct sk_buff *tqe) { - void *buffer = tqe->buffer; + void *buffer = tqe->data; const struct ethhdr *eth_hdr_ptr = buffer; int i; unsigned long flags; @@ -210,29 +171,30 @@ static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe) spin_unlock_irqrestore(&wilc->txq_spinlock, flags); } -static void wilc_wlan_tx_packet_done(struct txq_entry_t *tqe, int status) +static void wilc_wlan_tx_packet_done(struct sk_buff *tqe, int status) { - struct wilc_vif *vif = tqe->vif; + struct wilc_vif *vif = netdev_priv(tqe->dev); struct wilc_skb_tx_cb *tx_cb = WILC_SKB_TX_CB(tqe); int ack_idx = tx_cb->ack_idx; - tqe->status = status; - if (tqe->tx_complete_func) - tqe->tx_complete_func(tqe->priv, tqe->status); if (ack_idx != NOT_TCP_ACK && ack_idx < MAX_PENDING_ACKS) vif->ack_filter.pending_acks[ack_idx].txqe = NULL; - kfree(tqe); + if (status) + dev_consume_skb_any(tqe); + else + dev_kfree_skb_any(tqe); } -static void wilc_wlan_txq_drop_net_pkt(struct txq_entry_t *tqe) +static void wilc_wlan_txq_drop_net_pkt(struct sk_buff *tqe) { - struct wilc_vif *vif = tqe->vif; + struct wilc_vif *vif = netdev_priv(tqe->dev); struct wilc *wilc = vif->wilc; struct wilc_skb_tx_cb *tx_cb = WILC_SKB_TX_CB(tqe); vif->ndev->stats.tx_dropped++; - wilc_wlan_txq_remove(wilc, tx_cb->q_num, tqe); + skb_unlink(tqe, &wilc->txq[tx_cb->q_num]); + atomic_dec(&wilc->txq_entries); wilc_wlan_tx_packet_done(tqe, 1); } @@ -261,7 +223,7 @@ static void wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) bigger_ack_num = f->ack_session_info[index].bigger_ack_num; if (f->pending_acks[i].ack_num < bigger_ack_num) { - struct txq_entry_t *tqe; + struct sk_buff *tqe; tqe = f->pending_acks[i].txqe; if (tqe) @@ -284,30 +246,17 @@ void wilc_enable_tcp_ack_filter(struct wilc_vif *vif, bool value) vif->ack_filter.enabled = value; } -static int wilc_wlan_txq_add_cfg_pkt(struct wilc_vif *vif, u8 *buffer, - u32 buffer_size) +static int wilc_wlan_txq_add_cfg_pkt(struct wilc_vif *vif, struct sk_buff *tqe) { - struct txq_entry_t *tqe; struct wilc *wilc = vif->wilc; netdev_dbg(vif->ndev, "Adding config packet ...\n"); if (wilc->quit) { netdev_dbg(vif->ndev, "Return due to clear function\n"); - complete(&wilc->cfg_event); - return 0; - } - - tqe = kmalloc(sizeof(*tqe), GFP_ATOMIC); - if (!tqe) { - complete(&wilc->cfg_event); + dev_kfree_skb_any(tqe); return 0; } - tqe->buffer = buffer; - tqe->buffer_size = buffer_size; - tqe->tx_complete_func = NULL; - tqe->priv = NULL; - wilc_wlan_txq_add_to_head(vif, WILC_CFG_PKT, AC_VO_Q, tqe); return 1; @@ -354,7 +303,7 @@ static bool is_ac_q_limit(struct wilc *wl, u8 q_num) else q_limit = (q->cnt[q_num] * FLOW_CONTROL_UPPER_THRESHOLD / q->sum) + 1; - if (wl->txq[q_num].count <= q_limit) + if (skb_queue_len(&wl->txq[q_num]) <= q_limit) ret = true; spin_unlock_irqrestore(&wl->txq_spinlock, flags); @@ -442,12 +391,8 @@ static inline u8 ac_change(struct wilc *wilc, u8 *ac) return 1; } -int wilc_wlan_txq_add_net_pkt(struct net_device *dev, - struct tx_complete_data *tx_data, u8 *buffer, - u32 buffer_size, - void (*tx_complete_fn)(void *, int)) +int wilc_wlan_txq_add_net_pkt(struct net_device *dev, struct sk_buff *tqe) { - struct txq_entry_t *tqe; struct wilc_vif *vif = netdev_priv(dev); struct wilc *wilc; u8 q_num; @@ -455,109 +400,50 @@ int wilc_wlan_txq_add_net_pkt(struct net_device *dev, wilc = vif->wilc; if (wilc->quit) { - tx_complete_fn(tx_data, 0); + dev_kfree_skb_any(tqe); return 0; } if (!wilc->initialized) { - tx_complete_fn(tx_data, 0); + dev_kfree_skb_any(tqe); return 0; } - tqe = kmalloc(sizeof(*tqe), GFP_ATOMIC); - - if (!tqe) { - tx_complete_fn(tx_data, 0); - return 0; - } - tqe->buffer = buffer; - tqe->buffer_size = buffer_size; - tqe->tx_complete_func = tx_complete_fn; - tqe->priv = tx_data; - - q_num = ac_classify(wilc, tx_data->skb); + q_num = ac_classify(wilc, tqe); if (ac_change(wilc, &q_num)) { - tx_complete_fn(tx_data, 0); - kfree(tqe); + dev_kfree_skb_any(tqe); return 0; } if (is_ac_q_limit(wilc, q_num)) { wilc_wlan_txq_add_to_tail(dev, WILC_NET_PKT, q_num, tqe); } else { - tx_complete_fn(tx_data, 0); - kfree(tqe); + dev_kfree_skb(tqe); } return atomic_read(&wilc->txq_entries); } -int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer, - u32 buffer_size, - void (*tx_complete_fn)(void *, int)) +int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, struct sk_buff *tqe) { - struct txq_entry_t *tqe; struct wilc_vif *vif = netdev_priv(dev); struct wilc *wilc; wilc = vif->wilc; if (wilc->quit) { - tx_complete_fn(priv, 0); + dev_kfree_skb_any(tqe); return 0; } if (!wilc->initialized) { - tx_complete_fn(priv, 0); + dev_kfree_skb_any(tqe); return 0; } - tqe = kmalloc(sizeof(*tqe), GFP_ATOMIC); - - if (!tqe) { - tx_complete_fn(priv, 0); - return 0; - } - tqe->buffer = buffer; - tqe->buffer_size = buffer_size; - tqe->tx_complete_func = tx_complete_fn; - tqe->priv = priv; wilc_wlan_txq_add_to_tail(dev, WILC_MGMT_PKT, AC_VO_Q, tqe); return 1; } -static struct txq_entry_t *wilc_wlan_txq_get_first(struct wilc *wilc, u8 q_num) -{ - struct txq_entry_t *tqe = NULL; - unsigned long flags; - - spin_lock_irqsave(&wilc->txq_spinlock, flags); - - if (!list_empty(&wilc->txq[q_num].txq_head.list)) - tqe = list_first_entry(&wilc->txq[q_num].txq_head.list, - struct txq_entry_t, list); - - spin_unlock_irqrestore(&wilc->txq_spinlock, flags); - - return tqe; -} - -static struct txq_entry_t *wilc_wlan_txq_get_next(struct wilc *wilc, - struct txq_entry_t *tqe, - u8 q_num) -{ - unsigned long flags; - - spin_lock_irqsave(&wilc->txq_spinlock, flags); - - if (!list_is_last(&tqe->list, &wilc->txq[q_num].txq_head.list)) - tqe = list_next_entry(tqe, list); - else - tqe = NULL; - spin_unlock_irqrestore(&wilc->txq_spinlock, flags); - - return tqe; -} - static void wilc_wlan_rxq_add(struct wilc *wilc, struct rxq_entry_t *rqe) { if (wilc->quit) @@ -732,7 +618,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) u32 offset = 0; bool max_size_over = 0, ac_exist = 0; int vmm_sz = 0; - struct txq_entry_t *tqe_q[NQUEUES]; + struct sk_buff *tqe_q[NQUEUES]; struct wilc_skb_tx_cb *tx_cb; int ret = 0; int counter; @@ -758,7 +644,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) srcu_read_unlock(&wilc->srcu, srcu_idx); for (ac = 0; ac < NQUEUES; ac++) - tqe_q[ac] = wilc_wlan_txq_get_first(wilc, ac); + tqe_q[ac] = skb_peek(&wilc->txq[ac]); i = 0; sum = 0; @@ -786,7 +672,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) else vmm_sz = HOST_HDR_OFFSET; - vmm_sz += tqe_q[ac]->buffer_size; + vmm_sz += tqe_q[ac]->len; vmm_sz = ALIGN(vmm_sz, 4); if ((sum + vmm_sz) > WILC_TX_BUFF_SIZE) { @@ -802,9 +688,8 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) i++; sum += vmm_sz; - tqe_q[ac] = wilc_wlan_txq_get_next(wilc, - tqe_q[ac], - ac); + tqe_q[ac] = skb_peek_next(tqe_q[ac], + &wilc->txq[ac]); } } num_pkts_to_add = ac_preserve_ratio; @@ -894,17 +779,18 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) offset = 0; i = 0; do { - struct txq_entry_t *tqe; + struct sk_buff *tqe; u32 header, buffer_offset; char *bssid; u8 mgmt_ptk = 0; - tqe = wilc_wlan_txq_remove_from_head(wilc, vmm_entries_ac[i]); + tqe = skb_dequeue(&wilc->txq[vmm_entries_ac[i]]); if (!tqe) break; + atomic_dec(&wilc->txq_entries); ac_pkt_num_to_chip[vmm_entries_ac[i]]++; - vif = tqe->vif; + vif = netdev_priv(tqe->dev); tx_cb = WILC_SKB_TX_CB(tqe); if (vmm_table[i] == 0) break; @@ -918,7 +804,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) header = (FIELD_PREP(WILC_VMM_HDR_TYPE, tx_cb->type) | FIELD_PREP(WILC_VMM_HDR_MGMT_FIELD, mgmt_ptk) | - FIELD_PREP(WILC_VMM_HDR_PKT_SIZE, tqe->buffer_size) | + FIELD_PREP(WILC_VMM_HDR_PKT_SIZE, tqe->len) | FIELD_PREP(WILC_VMM_HDR_BUFF_SIZE, vmm_sz)); cpu_to_le32s(&header); @@ -928,7 +814,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) } else if (tx_cb->type == WILC_NET_PKT) { int prio = tx_cb->q_num; - bssid = tqe->vif->bssid; + bssid = vif->bssid; buffer_offset = ETH_ETHERNET_HDR_OFFSET; memcpy(&txb[offset + 4], &prio, sizeof(prio)); memcpy(&txb[offset + 8], bssid, 6); @@ -936,8 +822,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) buffer_offset = HOST_HDR_OFFSET; } - memcpy(&txb[offset + buffer_offset], - tqe->buffer, tqe->buffer_size); + memcpy(&txb[offset + buffer_offset], tqe->data, tqe->len); offset += vmm_sz; i++; wilc_wlan_tx_packet_done(tqe, 1); @@ -1251,7 +1136,7 @@ int wilc_wlan_stop(struct wilc *wilc, struct wilc_vif *vif) void wilc_wlan_cleanup(struct net_device *dev) { - struct txq_entry_t *tqe; + struct sk_buff *tqe, *cfg_skb; struct rxq_entry_t *rqe; u8 ac; struct wilc_vif *vif = netdev_priv(dev); @@ -1259,9 +1144,15 @@ void wilc_wlan_cleanup(struct net_device *dev) wilc->quit = 1; for (ac = 0; ac < NQUEUES; ac++) { - while ((tqe = wilc_wlan_txq_remove_from_head(wilc, ac))) + while ((tqe = skb_dequeue(&wilc->txq[ac]))) wilc_wlan_tx_packet_done(tqe, 0); } + atomic_set(&wilc->txq_entries, 0); + cfg_skb = wilc->cfg_skb; + if (cfg_skb) { + wilc->cfg_skb = NULL; + dev_kfree_skb_any(cfg_skb); + } while ((rqe = wilc_wlan_rxq_remove(wilc))) kfree(rqe); @@ -1273,21 +1164,52 @@ void wilc_wlan_cleanup(struct net_device *dev) wilc->hif_func->hif_deinit(wilc); } +struct sk_buff *wilc_wlan_alloc_skb(struct wilc_vif *vif, size_t len) +{ + size_t size, headroom; + struct sk_buff *skb; + + headroom = vif->ndev->needed_headroom; + size = headroom + len + vif->ndev->needed_tailroom; + skb = netdev_alloc_skb(vif->ndev, size); + if (!skb) { + netdev_err(vif->ndev, "Failed to alloc skb"); + return NULL; + } + skb_reserve(skb, headroom); + return skb; +} + +static struct sk_buff *alloc_cfg_skb(struct wilc_vif *vif) +{ + struct sk_buff *skb; + + skb = wilc_wlan_alloc_skb(vif, (sizeof(struct wilc_cfg_cmd_hdr) + + WILC_MAX_CFG_FRAME_SIZE)); + if (!skb) + return NULL; + skb_reserve(skb, sizeof(struct wilc_cfg_cmd_hdr)); + return skb; +} + static int wilc_wlan_cfg_commit(struct wilc_vif *vif, int type, u32 drv_handler) { struct wilc *wilc = vif->wilc; - struct wilc_cfg_frame *cfg = &wilc->cfg_frame; - int t_len = wilc->cfg_frame_offset + sizeof(struct wilc_cfg_cmd_hdr); struct wilc_cfg_cmd_hdr *hdr; + struct sk_buff *cfg_skb = wilc->cfg_skb; - hdr = &cfg->hdr; + hdr = skb_push(cfg_skb, sizeof(*hdr)); hdr->cmd_type = (type == WILC_CFG_SET) ? 'W' : 'Q'; hdr->seq_no = wilc->cfg_seq_no; - hdr->total_len = cpu_to_le16(t_len); + hdr->total_len = cpu_to_le16(cfg_skb->len); hdr->driver_handler = cpu_to_le32(drv_handler); + /* We are about to pass ownership of cfg_skb to the tx queue + * (or it'll be destroyed, in case the queue is full): + */ + wilc->cfg_skb = NULL; - if (!wilc_wlan_txq_add_cfg_pkt(vif, (u8 *)&cfg->hdr, t_len)) + if (!wilc_wlan_txq_add_cfg_pkt(vif, cfg_skb)) return -1; return 0; @@ -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 = vif->wilc; mutex_lock(&wilc->cfg_cmd_lock); - if (start) - wilc->cfg_frame_offset = 0; + if (start) { + WARN_ON(wilc->cfg_skb); + wilc->cfg_skb = alloc_cfg_skb(vif); + if (!wilc->cfg_skb) { + netdev_dbg(vif->ndev, "Failed to alloc cfg_skb"); + mutex_unlock(&wilc->cfg_cmd_lock); + return 0; + } + } - offset = wilc->cfg_frame_offset; if (set) - ret_size = wilc_wlan_cfg_set_wid(wilc->cfg_frame.frame, offset, + ret_size = wilc_wlan_cfg_set_wid(skb_tail_pointer(wilc->cfg_skb), 0, wid, buffer, buffer_size); else - ret_size = wilc_wlan_cfg_get_wid(wilc->cfg_frame.frame, offset, - wid); - offset += ret_size; - wilc->cfg_frame_offset = offset; + ret_size = wilc_wlan_cfg_get_wid(skb_tail_pointer(wilc->cfg_skb), 0, wid); + if (ret_size == 0) + netdev_dbg(vif->ndev, + "Failed to add WID 0x%x to %s cfg packet\n", + wid, set ? "set" : "query"); + + skb_put(wilc->cfg_skb, ret_size); if (!commit) { mutex_unlock(&wilc->cfg_cmd_lock); @@ -1353,7 +1283,6 @@ static int wilc_wlan_cfg_apply_wid(struct wilc_vif *vif, int start, u16 wid, ret_size = 0; } - wilc->cfg_frame_offset = 0; wilc->cfg_seq_no = (wilc->cfg_seq_no + 1) % 256; mutex_unlock(&wilc->cfg_cmd_lock); diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/wireless/microchip/wilc1000/wlan.h index 295795a8060ac..10618327133ce 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.h +++ b/drivers/net/wireless/microchip/wilc1000/wlan.h @@ -320,24 +320,19 @@ enum ip_pkt_priority { AC_BK_Q = 3 }; -struct txq_entry_t { - struct list_head list; - int type; - u8 q_num; - int ack_idx; - u8 *buffer; - int buffer_size; - void *priv; - int status; - struct wilc_vif *vif; - void (*tx_complete_func)(void *priv, int status); +/* When queueing a tx packet, this info is stored in the sk_buff's + * control buffer (cb). + */ +struct wilc_skb_tx_cb { + u8 type; /* one of WILC_*_PKT */ + enum ip_pkt_priority q_num; /* AC queue this packet is on */ + int ack_idx; /* TCP ack index */ }; -#define wilc_skb_tx_cb txq_entry_t - -static inline struct wilc_skb_tx_cb *WILC_SKB_TX_CB(struct txq_entry_t *tqe) +static inline struct wilc_skb_tx_cb *WILC_SKB_TX_CB(struct sk_buff *skb) { - return (struct wilc_skb_tx_cb *)tqe; + BUILD_BUG_ON(sizeof(struct wilc_skb_tx_cb) > sizeof(skb->cb)); + return (struct wilc_skb_tx_cb *)&skb->cb[0]; } struct txq_fw_recv_queue_stat { @@ -345,11 +340,6 @@ struct txq_fw_recv_queue_stat { u8 count; }; -struct txq_handle { - struct txq_entry_t txq_head; - u16 count; -}; - struct rxq_entry_t { struct list_head list; u8 *buffer; @@ -382,12 +372,6 @@ struct wilc_hif_func { #define WILC_MAX_CFG_FRAME_SIZE 1468 -struct tx_complete_data { - int size; - void *buff; - struct sk_buff *skb; -}; - struct wilc_cfg_cmd_hdr { u8 cmd_type; u8 seq_no; @@ -395,11 +379,6 @@ struct wilc_cfg_cmd_hdr { __le32 driver_handler; }; -struct wilc_cfg_frame { - struct wilc_cfg_cmd_hdr hdr; - u8 frame[WILC_MAX_CFG_FRAME_SIZE]; -}; - struct wilc_cfg_rsp { u8 type; u8 seq_no; @@ -411,19 +390,16 @@ int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer, u32 buffer_size); int wilc_wlan_start(struct wilc *wilc); int wilc_wlan_stop(struct wilc *wilc, struct wilc_vif *vif); -int wilc_wlan_txq_add_net_pkt(struct net_device *dev, - struct tx_complete_data *tx_data, u8 *buffer, - u32 buffer_size, - void (*tx_complete_fn)(void *, int)); +int wilc_wlan_txq_add_net_pkt(struct net_device *dev, struct sk_buff *skb); int wilc_wlan_handle_txq(struct wilc *wl, u32 *txq_count); void wilc_handle_isr(struct wilc *wilc); +struct sk_buff *wilc_wlan_alloc_skb(struct wilc_vif *vif, size_t len); void wilc_wlan_cleanup(struct net_device *dev); int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, u32 buffer_size, int commit, u32 drv_handler); int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, u16 wid, int commit, u32 drv_handler); -int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer, - u32 buffer_size, void (*func)(void *, int)); +int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, struct sk_buff *skb); void wilc_enable_tcp_ack_filter(struct wilc_vif *vif, bool value); int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc); netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *dev); From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697819 X-Patchwork-Delegate: kvalo@adurom.com 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 59BC9C433F5 for ; Thu, 23 Dec 2021 01:15:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242123AbhLWBPD (ORCPT ); Wed, 22 Dec 2021 20:15:03 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18392 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345778AbhLWBOS (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvF57zItUWDc68Njwzom2zBXkmJEYQhgSnJ3Qik1UqW8tfJqfcvcHJvYKbKbeuYAkOQbStMz/kx2DZvHrec6MDTSXoPeHfQ30Jn64mYapEM6cFSVZC5yNLKFMy+3asG+BKmETyDaaibIk2a63mfIXzpD9nAkTOmhI2kX6/o/KBEOmajhd11D9h2kJw2g1q8bM1w== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org With the tx-path switched to sk_buffs, there is no longer any need for the "vif" argument in init_txq_entry(). Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 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 bus_release release) mutex_unlock(&wilc->hif_cs); } -static void init_txq_entry(struct sk_buff *tqe, struct wilc_vif *vif, +static void init_txq_entry(struct sk_buff *tqe, u8 type, enum ip_pkt_priority q_num) { struct wilc_skb_tx_cb *tx_cb = WILC_SKB_TX_CB(tqe); @@ -53,7 +53,7 @@ static void wilc_wlan_txq_add_to_tail(struct net_device *dev, u8 type, u8 q_num, struct wilc_vif *vif = netdev_priv(dev); struct wilc *wilc = vif->wilc; - init_txq_entry(tqe, vif, type, q_num); + init_txq_entry(tqe, type, q_num); if (type == WILC_NET_PKT && vif->ack_filter.enabled) tcp_process(dev, tqe); @@ -68,7 +68,7 @@ static void wilc_wlan_txq_add_to_head(struct wilc_vif *vif, u8 type, u8 q_num, { struct wilc *wilc = vif->wilc; - init_txq_entry(tqe, vif, type, q_num); + init_txq_entry(tqe, type, q_num); mutex_lock(&wilc->txq_add_to_head_cs); From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697855 X-Patchwork-Delegate: kvalo@adurom.com 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 32376C4332F for ; Thu, 23 Dec 2021 01:16:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346944AbhLWBQu (ORCPT ); Wed, 22 Dec 2021 20:16:50 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18332 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345756AbhLWBOP (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvN/gGHiwjRLSHlTP90xv/CkD5McJdotNU1IWUaiA5rlUOQzfOXej2buH57ZdJ8RFuS2M85fKVNxTd4qP8KXY0N/vYRJvT6WAFpJ9OWf/K9Cp5VYr6j0au8o7JGF2BAIqs8+HDQhMl1cJXRNRpbuJNidBmSVQl8DPyz9+dAtNpXhLRmkOkXChY+vDlVaU1uHN7g== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This makes the code easier to read and less error prone. There are no functional changes in this patch. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/wlan.c | 206 +++++++++++++----- 1 file changed, 157 insertions(+), 49 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/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); -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 the + * respective queue. + * @vmm_table: Pointer to the VMM table to fill. + * @vmm_entries_ac: Pointer to the queue-number table to fill. + * For each packet added to the VMM table, this will be filled in + * with the queue-number (access-category) that the packet is coming + * from. + * + * 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 = 0; + int i; u8 k, ac; u32 sum; - u32 reg; - u8 ac_desired_ratio[NQUEUES] = {0, 0, 0, 0}; u8 ac_preserve_ratio[NQUEUES] = {1, 1, 1, 1}; u8 *num_pkts_to_add; - u8 vmm_entries_ac[WILC_VMM_TBL_SIZE]; - u32 offset = 0; bool max_size_over = 0, ac_exist = 0; int vmm_sz = 0; struct sk_buff *tqe_q[NQUEUES]; struct wilc_skb_tx_cb *tx_cb; - int ret = 0; - int counter; - int timeout; - u32 vmm_table[WILC_VMM_TBL_SIZE]; - u8 ac_pkt_num_to_chip[NQUEUES] = {0, 0, 0, 0}; - const struct wilc_hif_func *func; - int srcu_idx; - u8 *txb = wilc->tx_buffer; - struct wilc_vif *vif; - - if (wilc->quit) - goto out_update_cnt; - - if (ac_balance(wilc, ac_desired_ratio)) - return -EINVAL; - - mutex_lock(&wilc->txq_add_to_head_cs); - - srcu_idx = srcu_read_lock(&wilc->srcu); - list_for_each_entry_rcu(vif, &wilc->vif_list, list) - wilc_wlan_txq_filter_dup_tcp_ack(vif->ndev); - srcu_read_unlock(&wilc->srcu, srcu_idx); for (ac = 0; ac < NQUEUES; ac++) tqe_q[ac] = skb_peek(&wilc->txq[ac]); @@ -695,11 +695,31 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) num_pkts_to_add = ac_preserve_ratio; } while (!max_size_over && ac_exist); - if (i == 0) - goto out_unlock; vmm_table[i] = 0x0; + return i; +} + +/** + * send_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; - acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); counter = 0; func = wilc->hif_func; do { @@ -721,7 +741,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) } while (!wilc->quit); if (ret) - goto out_release_bus; + return ret; timeout = 200; do { @@ -759,22 +779,38 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) break; reg &= ~BIT(0); ret = func->hif_write_reg(wilc, WILC_HOST_TX_CTRL, reg); + } else { + ret = entries; } } while (0); + return ret; +} - if (ret) - goto out_release_bus; - - if (entries == 0) { - /* - * No VMM space available in firmware so retry to transmit - * the packet from tx queue. - */ - ret = WILC_VMM_ENTRY_FULL_RETRY; - goto out_release_bus; - } - - release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); +/** + * copy_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] = {0, 0, 0, 0}; + struct wilc_skb_tx_cb *tx_cb; + u8 *txb = wilc->tx_buffer; + struct wilc_vif *vif; + int i, vmm_sz; + u32 offset; offset = 0; i = 0; @@ -829,16 +865,88 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) } while (--entries); for (i = 0; i < NQUEUES; i++) wilc->fw[i].count += ac_pkt_num_to_chip[i]; + return offset; +} - acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); +/** + * send_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 = wilc->hif_func; + int ret; + u8 *txb = wilc->tx_buffer; ret = func->hif_clear_int_ext(wilc, ENABLE_TX_VMM); if (ret) - goto out_release_bus; + return ret; + + 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] = {0, 0, 0, 0}; + u8 vmm_entries_ac[WILC_VMM_TBL_SIZE]; + int ret = 0; + u32 vmm_table[WILC_VMM_TBL_SIZE]; + int srcu_idx; + struct wilc_vif *vif; + + if (wilc->quit) + goto out_update_cnt; + + if (ac_balance(wilc, ac_desired_ratio)) + return -EINVAL; + + mutex_lock(&wilc->txq_add_to_head_cs); + + srcu_idx = srcu_read_lock(&wilc->srcu); + list_for_each_entry_rcu(vif, &wilc->vif_list, list) + wilc_wlan_txq_filter_dup_tcp_ack(vif->ndev); + srcu_read_unlock(&wilc->srcu, srcu_idx); + + i = fill_vmm_table(wilc, ac_desired_ratio, vmm_table, vmm_entries_ac); + if (i == 0) + goto out_unlock; + + acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); + + ret = send_vmm_table(wilc, i, vmm_table); + + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); + + if (ret < 0) + goto out_unlock; + + entries = ret; + if (entries == 0) { + /* No VMM space available in firmware. Inform caller + * to retry later. + */ + ret = WILC_VMM_ENTRY_FULL_RETRY; + goto out_unlock; + } + + len = copy_packets(wilc, entries, vmm_table, vmm_entries_ac); + if (len <= 0) + goto out_unlock; + + acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); - ret = func->hif_block_tx_ext(wilc, 0, txb, offset); + ret = send_packets(wilc, len); -out_release_bus: release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); out_unlock: From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697851 X-Patchwork-Delegate: kvalo@adurom.com 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 36EE5C433EF for ; Thu, 23 Dec 2021 01:16:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346100AbhLWBQn (ORCPT ); Wed, 22 Dec 2021 20:16:43 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18428 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345807AbhLWBOV (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvP9gs2xqRpyIBtGYRlDavY3uO9Y96GusEhphEvR8U2Or9IV1GN9AtCEUroMXcil4bWWz0vBANOAMeohSevp9gTXvyUMIATv1RdH+nd5xkzLSLN5y/X21psbKKk3gVo1z303Rgz0VCC8csbnJLJ1naS/JqTtOjlf/Hx6B4/fN31hgfZiFTADVolu+57qdFW5PxQ== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Putting the chip to sleep and waking it up again is relatively slow, so there is no point to put the chip to sleep for the short time it takes to copy a couple of packets. Signed-off-by: David Mosberger-Tang --- .../net/wireless/microchip/wilc1000/wlan.c | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 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); ret = send_vmm_table(wilc, i, vmm_table); + if (ret <= 0) { + if (ret == 0) + /* No VMM space available in firmware. Inform + * caller to retry later. + */ + ret = WILC_VMM_ENTRY_FULL_RETRY; + goto out_release_bus; + } - release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); - - if (ret < 0) - goto out_unlock; + release_bus(wilc, WILC_BUS_RELEASE_ONLY); entries = ret; - if (entries == 0) { - /* No VMM space available in firmware. Inform caller - * to retry later. - */ - ret = WILC_VMM_ENTRY_FULL_RETRY; - goto out_unlock; - } - len = copy_packets(wilc, entries, vmm_table, vmm_entries_ac); if (len <= 0) goto out_unlock; - acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); + acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); ret = send_packets(wilc, len); +out_release_bus: release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); out_unlock: From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697813 X-Patchwork-Delegate: kvalo@adurom.com 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 D65AAC433F5 for ; Thu, 23 Dec 2021 01:14:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241991AbhLWBOV (ORCPT ); Wed, 22 Dec 2021 20:14:21 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18272 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345694AbhLWBON (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvBovVGGUqsKDfRdCLg1PJA3t8foKn9E0eDBioSfxjXTPS/qEtvMwuU7eykaxv403jcXR8Nu5mfoqIItxiNmkjMVxhl4hBfkqmC0XIYwOtnLhWYccdH5ZTNO9Sl4YHoQfF18jJkyZOYbbp6ce3kYK9woDOQpgAguuyh73F/ZA02ZoQ+ynW4/gUiNcP6K4eQZwlA== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This makes the code tighter and easier to understand. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 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] = {1, 1, 1, 1}; u8 *num_pkts_to_add; - bool max_size_over = 0, ac_exist = 0; + bool ac_exist = 0; int vmm_sz = 0; struct sk_buff *tqe_q[NQUEUES]; struct wilc_skb_tx_cb *tx_cb; @@ -648,20 +648,17 @@ static int fill_vmm_table(const struct wilc *wilc, i = 0; sum = 0; - max_size_over = 0; num_pkts_to_add = ac_desired_ratio; do { ac_exist = 0; - for (ac = 0; (ac < NQUEUES) && (!max_size_over); ac++) { + for (ac = 0; ac < NQUEUES; ac++) { if (!tqe_q[ac]) continue; ac_exist = 1; - for (k = 0; (k < num_pkts_to_add[ac]) && - (!max_size_over) && tqe_q[ac]; k++) { + for (k = 0; (k < num_pkts_to_add[ac]) && tqe_q[ac]; k++) { if (i >= (WILC_VMM_TBL_SIZE - 1)) { - max_size_over = 1; - break; + goto out; } tx_cb = WILC_SKB_TX_CB(tqe_q[ac]); @@ -676,8 +673,7 @@ static int fill_vmm_table(const struct wilc *wilc, vmm_sz = ALIGN(vmm_sz, 4); if ((sum + vmm_sz) > WILC_TX_BUFF_SIZE) { - max_size_over = 1; - break; + goto out; } vmm_table[i] = vmm_sz / 4; if (tx_cb->type == WILC_CFG_PKT) @@ -693,8 +689,8 @@ static int fill_vmm_table(const struct wilc *wilc, } } num_pkts_to_add = ac_preserve_ratio; - } while (!max_size_over && ac_exist); - + } while (ac_exist); +out: vmm_table[i] = 0x0; return i; } From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697817 X-Patchwork-Delegate: kvalo@adurom.com 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 6A78EC433EF for ; Thu, 23 Dec 2021 01:15:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345816AbhLWBO6 (ORCPT ); Wed, 22 Dec 2021 20:14:58 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18342 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345808AbhLWBOW (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvLZxHI1WTv+apMggTxpW6dVO07dWMAWJoY1Bu46DX+LwUkE7cVHmQvQrgtXMbB8mrMynCaXw8lkkNDKys91eMLBac9IddjmYlgTgbm9AsniqUhadcZVMYeMvQBwKO+v/v5u5Zau8MJlPTFNQhZ3v6qjLYNqrvlUcKDL2D0IMBn0b6WeXrcu64JXHOOt/pp7QUg== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Apart from being slightly more efficient, this makes the code easier to follow. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 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] = {1, 1, 1, 1}; - u8 *num_pkts_to_add; + static const u8 ac_preserve_ratio[NQUEUES] = {1, 1, 1, 1}; + const u8 *num_pkts_to_add; bool ac_exist = 0; int vmm_sz = 0; struct sk_buff *tqe_q[NQUEUES]; From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697811 X-Patchwork-Delegate: kvalo@adurom.com 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 E479DC4332F for ; Thu, 23 Dec 2021 01:14:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238630AbhLWBOP (ORCPT ); Wed, 22 Dec 2021 20:14:15 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18282 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345735AbhLWBON (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=+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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvJKfYCcYkBmI5xpqFoSD34tNpJNDAhFw+fPQk430jNmTlt1liYNUH15cCnQ/fa6zQty9oXEWTbqAz5//J0EIGQ7kCU+BoXKrUKcv9HUNgOfr/qSAPlmKvCRBtWpJk/kNYVGTvOsnqL0yShWIucOScGUAd7q3D+mD45sT/WgtFNArvN4Ja7nhdPsxRe0Jamfusg== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Remove extraneous parentheses and braces. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 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; ac_exist = 1; - for (k = 0; (k < num_pkts_to_add[ac]) && tqe_q[ac]; k++) { - if (i >= (WILC_VMM_TBL_SIZE - 1)) { + for (k = 0; k < num_pkts_to_add[ac] && tqe_q[ac]; k++) { + if (i >= WILC_VMM_TBL_SIZE - 1) goto out; - } tx_cb = WILC_SKB_TX_CB(tqe_q[ac]); if (tx_cb->type == WILC_CFG_PKT) @@ -672,9 +671,8 @@ static int fill_vmm_table(const struct wilc *wilc, vmm_sz += tqe_q[ac]->len; vmm_sz = ALIGN(vmm_sz, 4); - if ((sum + vmm_sz) > WILC_TX_BUFF_SIZE) { + if (sum + vmm_sz > WILC_TX_BUFF_SIZE) goto out; - } vmm_table[i] = vmm_sz / 4; if (tx_cb->type == WILC_CFG_PKT) vmm_table[i] |= BIT(10); @@ -741,10 +739,8 @@ static int send_vmm_table(struct wilc *wilc, int i, const u32 *vmm_table) timeout = 200; do { - ret = func->hif_block_tx(wilc, - WILC_VMM_TBL_RX_SHADOW_BASE, - (u8 *)vmm_table, - ((i + 1) * 4)); + ret = func->hif_block_tx(wilc, WILC_VMM_TBL_RX_SHADOW_BASE, + (u8 *)vmm_table, (i + 1) * 4); if (ret) break; From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697818 X-Patchwork-Delegate: kvalo@adurom.com 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 2E799C4332F for ; Thu, 23 Dec 2021 01:15:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345808AbhLWBPA (ORCPT ); Wed, 22 Dec 2021 20:15:00 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18330 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345798AbhLWBOV (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvJD+x2smqDgMhvITPdFZ8LpvZ4l0gufVGuiwD1p5mR9rphOFgG4bG/4z/+tkUCDTCYhl0x1an9kXtm6YdZV+BOb6o8iifpSNxZJnf3+Am7JkbiFBrnT/2emIhQL4npnC18rDBrYAkEZJRyZD5aAPyj/MOkFs7d9KxlPR8f1oDiaZ+2JHrJUEHZ7h+9y8iBIONw== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org I wish these registers were documented so I wouldn't have to guess at their meanings and make up my own names. Signed-off-by: David Mosberger-Tang --- drivers/net/wireless/microchip/wilc1000/wlan.c | 6 +++--- drivers/net/wireless/microchip/wilc1000/wlan.h | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 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] = vmm_sz / 4; if (tx_cb->type == WILC_CFG_PKT) - vmm_table[i] |= BIT(10); + vmm_table[i] |= WILC_VMM_CFG_PKT; cpu_to_le32s(&vmm_table[i]); vmm_entries_ac[i] = ac; @@ -721,7 +721,7 @@ static int send_vmm_table(struct wilc *wilc, int i, const u32 *vmm_table) if (ret) break; - if ((reg & 0x1) == 0) { + if ((reg & WILC_HOST_TX_CTRL_BUSY) == 0) { ac_update_fw_ac_pkt_info(wilc, reg); break; } @@ -769,7 +769,7 @@ static int send_vmm_table(struct wilc *wilc, int i, const u32 *vmm_table) ret = func->hif_read_reg(wilc, WILC_HOST_TX_CTRL, ®); if (ret) break; - reg &= ~BIT(0); + reg &= ~WILC_HOST_TX_CTRL_BUSY; ret = func->hif_write_reg(wilc, WILC_HOST_TX_CTRL, reg); } else { ret = entries; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/wireless/microchip/wilc1000/wlan.h index 10618327133ce..f5d32ec93fdb9 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.h +++ b/drivers/net/wireless/microchip/wilc1000/wlan.h @@ -224,6 +224,7 @@ #define BE_AC_ACM_STAT_FIELD BIT(8) #define BK_AC_COUNT_FIELD GENMASK(7, 3) #define BK_AC_ACM_STAT_FIELD BIT(1) +#define WILC_HOST_TX_CTRL_BUSY BIT(0) #define WILC_PKT_HDR_CONFIG_FIELD BIT(31) #define WILC_PKT_HDR_OFFSET_FIELD GENMASK(30, 22) @@ -233,6 +234,7 @@ #define WILC_INTERRUPT_DATA_SIZE GENMASK(14, 0) #define WILC_VMM_BUFFER_SIZE GENMASK(9, 0) +#define WILC_VMM_CFG_PKT BIT(10) #define WILC_VMM_HDR_TYPE BIT(31) #define WILC_VMM_HDR_MGMT_FIELD BIT(30) From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697852 X-Patchwork-Delegate: kvalo@adurom.com 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 AC9B1C433F5 for ; Thu, 23 Dec 2021 01:16:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346144AbhLWBQp (ORCPT ); Wed, 22 Dec 2021 20:16:45 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18388 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345777AbhLWBOS (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvGBcp4s2Az1AHv79ABU3BFGyn+E9LPexzA58AtugPyGPRXwwtc3DKSoOsBtpfgdGlcAixxwv/fgakudCQuG61w7CMYNU1ocUDXPTenKqkmi247to98LX2acMVrY4oQgc6NJRcmAqpM3IMI1p4rC6owYEnLuncxdz47JaQ9rjhUJ4M6i9zR3Eh2XG3rfVsKA7Xw== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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/net/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) spin_lock_init(&wl->txq_spinlock); mutex_init(&wl->txq_add_to_head_cs); + mutex_init(&wl->tx_q_limit_lock); 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); } 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]; + /* 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; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/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) static bool is_ac_q_limit(struct wilc *wl, u8 q_num) { - unsigned long flags; struct wilc_tx_queue_status *q = &wl->tx_q_limit; u8 end_index; u8 q_limit; bool ret = false; - spin_lock_irqsave(&wl->txq_spinlock, flags); + mutex_lock(&wl->tx_q_limit_lock); end_index = q->end_index; q->cnt[q->buffer[end_index]] -= 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]) <= q_limit) ret = true; - spin_unlock_irqrestore(&wl->txq_spinlock, flags); + mutex_unlock(&wl->tx_q_limit_lock); return ret; } From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697820 X-Patchwork-Delegate: kvalo@adurom.com 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 C6FDEC433EF for ; Thu, 23 Dec 2021 01:15:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242106AbhLWBPF (ORCPT ); Wed, 22 Dec 2021 20:15:05 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18364 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345768AbhLWBOR (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvLFGvaKITknzkke949/7j63eSgfYeyP9v+L3+fNZ9QLqBEqZkdjJa3QD7To2KHUS8OZft9cQsvjJ4hJp2PT8yyX1jXqwZvjZA0Ak/aPuNRgQtCmuhAoddoLrgmmLK5qV1qCMV0eEXEbfcw25oKVsSYt0vWrkpJPvJyjZBFBDKz9CxwDOECNCJGH/K/iHZR/x3A== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The 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/net/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); - spin_lock_init(&wl->txq_spinlock); mutex_init(&wl->txq_add_to_head_cs); mutex_init(&wl->tx_q_limit_lock); 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) srcu_idx = 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 = wl; vif->ndev = ndev; ndev->ml_priv = vif; + mutex_init(&vif->ack_filter_lock); ndev->netdev_ops = &wilc_netdev_ops; 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; - /* protect txq_entry_t transmit queue */ - spinlock_t txq_spinlock; - /* protect rxq_entry_t receiver queue */ struct mutex rxq_cs; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/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 = tqe->data; const struct ethhdr *eth_hdr_ptr = buffer; int i; - unsigned long flags; struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wilc = vif->wilc; struct tcp_ack_filter *f = &vif->ack_filter; const struct iphdr *ip_hdr_ptr; const struct tcphdr *tcp_hdr_ptr; u32 ihl, total_length, data_offset; - spin_lock_irqsave(&wilc->txq_spinlock, flags); + mutex_lock(&vif->ack_filter_lock); if (eth_hdr_ptr->h_proto != htons(ETH_P_IP)) goto out; @@ -168,7 +166,7 @@ static inline void tcp_process(struct net_device *dev, struct sk_buff *tqe) } out: - spin_unlock_irqrestore(&wilc->txq_spinlock, flags); + mutex_unlock(&vif->ack_filter_lock); } 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 = netdev_priv(dev); - struct wilc *wilc = vif->wilc; struct tcp_ack_filter *f = &vif->ack_filter; u32 i = 0; - unsigned long flags; - spin_lock_irqsave(&wilc->txq_spinlock, flags); + mutex_lock(&vif->ack_filter_lock); for (i = 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 = 0; - spin_unlock_irqrestore(&wilc->txq_spinlock, flags); + mutex_unlock(&vif->ack_filter_lock); } void wilc_enable_tcp_ack_filter(struct wilc_vif *vif, bool value) From patchwork Thu Dec 23 01:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697827 X-Patchwork-Delegate: kvalo@adurom.com 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 36174C43217 for ; Thu, 23 Dec 2021 01:15:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346285AbhLWBPQ (ORCPT ); Wed, 22 Dec 2021 20:15:16 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27186 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346212AbhLWBOj (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvGGquUt9ycIje3WqFlCafr+1TG2O9DDHkxjFYdcB99nE90QGpbToWeyant9YrHssVEPslyq/MdXIm7BTKB7tj7ax2jMM05SLIi0LcpA/Sxe1vAx+zbi8Eyes/zaGoUKc0SUoFluThxFZqYvSHKB7zUWXTBCOsTnba0bAg+4MhPYs82C88KBx8wO0SBtGd8K9Mg== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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/wireless/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; - mutex_lock(&vif->ack_filter_lock); - if (eth_hdr_ptr->h_proto != htons(ETH_P_IP)) - goto out; + return; ip_hdr_ptr = buffer + ETH_HLEN; if (ip_hdr_ptr->protocol != IPPROTO_TCP) - goto out; + return; ihl = ip_hdr_ptr->ihl << 2; tcp_hdr_ptr = buffer + ETH_HLEN + ihl; @@ -150,6 +148,9 @@ static inline void tcp_process(struct net_device *dev, struct sk_buff *tqe) seq_no = ntohl(tcp_hdr_ptr->seq); ack_no = ntohl(tcp_hdr_ptr->ack_seq); + + mutex_lock(&vif->ack_filter_lock); + for (i = 0; i < f->tcp_session; i++) { u32 j = f->ack_session_info[i].seq_num; @@ -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); add_tcp_pending_ack(vif, ack_no, i, tqe); - } -out: - mutex_unlock(&vif->ack_filter_lock); + mutex_unlock(&vif->ack_filter_lock); + } } static void wilc_wlan_tx_packet_done(struct sk_buff *tqe, int status) From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697853 X-Patchwork-Delegate: kvalo@adurom.com 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 EC988C433FE for ; Thu, 23 Dec 2021 01:16:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346934AbhLWBQs (ORCPT ); Wed, 22 Dec 2021 20:16:48 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18346 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345761AbhLWBOP (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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvFH5jXK85cQtbtZt7SL3jCjJD5yamKyyCopUd3NzO3D/huQ5uOd/defxRnh5BvGJtoyo9c8YpecROwyRILZQe2JFN/JR4IPqMVuKZM9SL/rQskbTbYfOK8iq7Y5p5St869NGsXmi0Q5ehFLNnYxynlaE0whcIQHHamwFuwU4uedrZrDudO7WOtEPBSdXogmfpg== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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/wireless/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, struct sk_buff *skb) return q_num; } -static inline int ac_balance(struct wilc *wl, u8 *ratio) +/** + * ac_balance() - balance queues by favoring ones with fewer packets pending + * @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 = 0; - if (!ratio) - return -EINVAL; - for (i = 0; i < NQUEUES; i++) if (wl->fw[i].count > max_count) max_count = wl->fw[i].count; for (i = 0; i < NQUEUES; i++) ratio[i] = max_count - wl->fw[i].count; - - return 0; } 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_count) if (wilc->quit) goto out_update_cnt; - if (ac_balance(wilc, ac_desired_ratio)) - return -EINVAL; + ac_balance(wilc, ac_desired_ratio); mutex_lock(&wilc->txq_add_to_head_cs); From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697832 X-Patchwork-Delegate: kvalo@adurom.com 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 0BA4BC433FE for ; Thu, 23 Dec 2021 01:15:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346429AbhLWBPW (ORCPT ); Wed, 22 Dec 2021 20:15:22 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27200 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346217AbhLWBOo (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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvH7VqQfef+8M9fWl+BgjYTNO1iE732BTkQPVhTFQ+A1qQ3TSiRj3VpHaEhNKjRi77SgeRSGIId18kL/iLTtApC6YIGYHrDqCwize2Abcs0LMjt+JU3X0tkPFgv+0SPbyNVd9PHfevK5/f20NZrTOYwsC71kf+k8GJ9ff7JqIi55ITXpVsRQ4+7NefnsnauziXw== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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/wireless/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 entries, u32 *vmm_table, } /** - * 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 = wilc->hif_func; int ret; - u8 *txb = wilc->tx_buffer; ret = func->hif_clear_int_ext(wilc, ENABLE_TX_VMM); if (ret) return ret; - return func->hif_block_tx_ext(wilc, 0, txb, len); + return func->hif_block_tx_ext(wilc, 0, wilc->tx_buffer, len); } int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697850 X-Patchwork-Delegate: kvalo@adurom.com 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 09025C433FE for ; Thu, 23 Dec 2021 01:16:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240022AbhLWBQl (ORCPT ); Wed, 22 Dec 2021 20:16:41 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18430 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345830AbhLWBOW (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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvM/6RLlPQwh+26vUzxaeDWE8+d/a7XnYxrlWl0eXZNjUWX3Z2JuNdED8I4ROcRQK/8Fck6bIRHcj+2h31fZd5shc45iBxYzMY7RRjeg8HDoHy8s3TUv2LDmqZzPOiZecGGsbdQ5dHFFVFE4NZMTbQR5a6Qt83h3pkkvMTXTL1hJcfbdMt/8bGk0HS+cGXBOSrA== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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/wireless/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); +/** + * 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; tx_cb = WILC_SKB_TX_CB(tqe_q[ac]); - if (tx_cb->type == WILC_CFG_PKT) - vmm_sz = ETH_CONFIG_PKT_HDR_OFFSET; - else if (tx_cb->type == WILC_NET_PKT) - vmm_sz = ETH_ETHERNET_HDR_OFFSET; - else - vmm_sz = HOST_HDR_OFFSET; - + vmm_sz = tx_hdr_len(tx_cb->type); vmm_sz += tqe_q[ac]->len; vmm_sz = ALIGN(vmm_sz, 4); @@ -834,17 +855,13 @@ static int copy_packets(struct wilc *wilc, int entries, u32 *vmm_table, cpu_to_le32s(&header); memcpy(&txb[offset], &header, 4); - if (tx_cb->type == WILC_CFG_PKT) { - buffer_offset = ETH_CONFIG_PKT_HDR_OFFSET; - } else if (tx_cb->type == WILC_NET_PKT) { + buffer_offset = tx_hdr_len(tx_cb->type); + if (tx_cb->type == WILC_NET_PKT) { int prio = tx_cb->q_num; bssid = vif->bssid; - buffer_offset = ETH_ETHERNET_HDR_OFFSET; memcpy(&txb[offset + 4], &prio, sizeof(prio)); memcpy(&txb[offset + 8], bssid, 6); - } else { - buffer_offset = HOST_HDR_OFFSET; } memcpy(&txb[offset + buffer_offset], tqe->data, tqe->len); From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697814 X-Patchwork-Delegate: kvalo@adurom.com 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 89CCBC433EF for ; Thu, 23 Dec 2021 01:14:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346104AbhLWBOb (ORCPT ); Wed, 22 Dec 2021 20:14:31 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18432 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345811AbhLWBOV (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvFxBP+gfd73CXFX+bN/zdCv1aaMpRvyqQ7QMMfTi3rjMRuYumSNBl00OAOZq92YF2soepP4nF+7m7Rwi9ECmoO6/sPoqcZl89IzVOjzCSW/EHiPM+K1YU9sVPiqwe7BPUaxdnq5DQPNRrZvRcZLeHoUnnvV80jNqNkIa06iiWku0usF5twDM3qLpzTjaeH/woA== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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/wireless/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, } /** - * 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, const u32 *vmm_table) timeout = 200; do { ret = func->hif_block_tx(wilc, WILC_VMM_TBL_RX_SHADOW_BASE, - (u8 *)vmm_table, (i + 1) * 4); + (u8 *)vmm_table, + (vmm_table_len + 1) * 4); if (ret) break; @@ -899,7 +900,7 @@ static int send_packets(struct wilc *wilc, int len) 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] = {0, 0, 0, 0}; u8 vmm_entries_ac[WILC_VMM_TBL_SIZE]; int ret = 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); - i = fill_vmm_table(wilc, ac_desired_ratio, vmm_table, vmm_entries_ac); - if (i == 0) + vmm_table_len = fill_vmm_table(wilc, ac_desired_ratio, vmm_table, vmm_entries_ac); + if (vmm_table_len == 0) goto out_unlock; acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); - ret = send_vmm_table(wilc, i, vmm_table); + ret = send_vmm_table(wilc, vmm_table_len, vmm_table); if (ret <= 0) { if (ret == 0) /* No VMM space available in firmware. Inform From patchwork Thu Dec 23 01:14:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697816 X-Patchwork-Delegate: kvalo@adurom.com 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 89E22C43217 for ; Thu, 23 Dec 2021 01:14:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346407AbhLWBOz (ORCPT ); Wed, 22 Dec 2021 20:14:55 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18436 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345827AbhLWBOX (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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvECsuSnE8f3tXIemhWexej/xxnh78Q8DU2R/ig/tGWIowexxuZl2DaJZeO3pMmOHOyq2EoHh1bofVI1hSEEeGEYNWeW2kyd6ZCZYvfEFbfjz80uBtB8wFfES9v+d5in0+5/5pHNQP5pZD+CXvMF8DyUDrXO0bbHDVqqEZ2MG+wpv980iCPZXe6iW35+VIiDX/A== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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/wireless/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; - ret = func->hif_write_reg(wilc, WILC_HOST_VMM_CTL, 0x2); + ret = func->hif_write_reg(wilc, WILC_HOST_VMM_CTL, + WILC_VMM_TABLE_UPDATED); if (ret) break; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/wireless/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 @@ #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. */ /*******************************************/ From patchwork Thu Dec 23 01:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697857 X-Patchwork-Delegate: kvalo@adurom.com 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 61B5FC433FE for ; Thu, 23 Dec 2021 01:16:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346123AbhLWBQy (ORCPT ); Wed, 22 Dec 2021 20:16:54 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27168 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346209AbhLWBOi (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvLgTn20zR8huEqDJ0MxRBKbzqZl9pgBv8ieFLgCozwXIMY+YaD2HCv+SnV6T96yvIyZ5Zej8MBI9aX5ZsbvXSxbM8ZRkjTgOhzpedG6J/biZiyjoHijOms6QMNVpeWVDOoOmdXY/GogB3NGIGcUU7NjjvBLvO9m3MAiqqk0RTcZxUyUfgFJ9FlmZH+2Ta6yKTw== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This 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/wireless/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) } } +static u32 vmm_table_entry(struct sk_buff *tqe, u32 vmm_sz) +{ + struct wilc_skb_tx_cb *tx_cb = WILC_SKB_TX_CB(tqe); + u32 entry; + + entry = vmm_sz / 4; + if (tx_cb->type == WILC_CFG_PKT) + entry |= 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, if (sum + vmm_sz > WILC_TX_BUFF_SIZE) goto out; - vmm_table[i] = vmm_sz / 4; - if (tx_cb->type == WILC_CFG_PKT) - vmm_table[i] |= WILC_VMM_CFG_PKT; - - cpu_to_le32s(&vmm_table[i]); + vmm_table[i] = vmm_table_entry(tqe_q[ac], vmm_sz); vmm_entries_ac[i] = ac; i++; From patchwork Thu Dec 23 01:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697844 X-Patchwork-Delegate: kvalo@adurom.com 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 3F8BFC4332F for ; Thu, 23 Dec 2021 01:16:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346767AbhLWBQQ (ORCPT ); Wed, 22 Dec 2021 20:16:16 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27260 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346222AbhLWBOq (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=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:07 +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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvO2CLe60Vy4lC9UTYRo5Pro2bUgGjRcBWEHwUu4+dWi6YKfFFjN5hIcGIpVl0qlV/IHf4fP0BO1pHkp5BWIRRkiT8lUTgPjmNZHnta4b4OHkq4N5OmKY7Jp+BTZjJqKwuyPWMsCSEWPS/NXR7Q1Ww6+68zzy6CQbyGP+JDOxRZho1CiJfoaLCFqxWEzBvHQkjg== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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/wireless/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 the - * respective queue. * @vmm_table: Pointer to the VMM table to fill. * @vmm_entries_ac: Pointer to the queue-number table to fill. * For each packet added to the VMM table, this will be filled in @@ -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] = {1, 1, 1, 1}; + u8 ac_desired_ratio[NQUEUES]; const u8 *num_pkts_to_add; bool ac_exist = 0; int vmm_sz = 0; @@ -683,6 +681,8 @@ static int fill_vmm_table(const struct wilc *wilc, i = 0; sum = 0; + + ac_balance(wilc, ac_desired_ratio); num_pkts_to_add = ac_desired_ratio; do { ac_exist = 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] = {0, 0, 0, 0}; u8 vmm_entries_ac[WILC_VMM_TBL_SIZE]; int ret = 0; u32 vmm_table[WILC_VMM_TBL_SIZE]; @@ -919,8 +918,6 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) if (wilc->quit) goto out_update_cnt; - ac_balance(wilc, ac_desired_ratio); - mutex_lock(&wilc->txq_add_to_head_cs); srcu_idx = srcu_read_lock(&wilc->srcu); @@ -928,7 +925,7 @@ 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); - vmm_table_len = fill_vmm_table(wilc, ac_desired_ratio, vmm_table, vmm_entries_ac); + vmm_table_len = fill_vmm_table(wilc, vmm_table, vmm_entries_ac); if (vmm_table_len == 0) goto out_unlock; From patchwork Thu Dec 23 01:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697826 X-Patchwork-Delegate: kvalo@adurom.com 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 E8234C433F5 for ; Thu, 23 Dec 2021 01:15:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346313AbhLWBPP (ORCPT ); Wed, 22 Dec 2021 20:15:15 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27138 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346204AbhLWBOh (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=/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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvPrUup0j1uxIpwHi0Qdt824iAYJZBYYzjLIm4TfOHHZ+R40nsdoqq+2gFdQlY5Su9zFVWJ0l69QnER98Ee0W5Awk9UqVX3U0fDlmKgeieJZYRO/sn8zFdtba5bzgSuJaUgD3G8Tc1LGc2TnRWsWYSaWyFzd3Pg/FeJbCl7dse0pcF2D+u6Ag4CRsnGelT1QuPA== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This 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/wireless/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) 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 = 0; u32 vmm_table[WILC_VMM_TBL_SIZE]; @@ -931,29 +931,24 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); - ret = send_vmm_table(wilc, vmm_table_len, vmm_table); - if (ret <= 0) { - if (ret == 0) - /* No VMM space available in firmware. Inform - * caller to retry later. - */ - ret = WILC_VMM_ENTRY_FULL_RETRY; - goto out_release_bus; - } - - release_bus(wilc, WILC_BUS_RELEASE_ONLY); - - entries = ret; - len = copy_packets(wilc, entries, vmm_table, vmm_entries_ac); - if (len <= 0) - goto out_unlock; - - acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); + entries = send_vmm_table(wilc, vmm_table_len, vmm_table); - ret = send_packets(wilc, len); + release_bus(wilc, (entries > 0 ? + WILC_BUS_RELEASE_ONLY : + WILC_BUS_RELEASE_ALLOW_SLEEP)); -out_release_bus: - release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); + if (entries <= 0) { + ret = entries; + } else { + ret = copy_packets(wilc, entries, vmm_table, vmm_entries_ac); + if (ret > 0) { + acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); + ret = send_packets(wilc, ret); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); + } + } + if (ret >= 0 && entries < vmm_table_len) + ret = WILC_VMM_ENTRY_FULL_RETRY; out_unlock: mutex_unlock(&wilc->txq_add_to_head_cs); From patchwork Thu Dec 23 01:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697828 X-Patchwork-Delegate: kvalo@adurom.com 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 C36EFC4332F for ; Thu, 23 Dec 2021 01:15:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346284AbhLWBPR (ORCPT ); Wed, 22 Dec 2021 20:15:17 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27248 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231618AbhLWBOj (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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvBiV+jvdVngOyqcOk0VU2J+4m/BmK9woiA/sth2gm5SOmvaIqU3Ea+Es/+ATfy2JI9lP0biBgmaDlwfMwwY0thaiIbAb/yQGQYwnFcA3l56fc/IjdfskOg2IBJkmj39KTKu4nURlS0ScqqOxIihMbeumzuRlmpzi6lWtpobbFZKlaf3KTcUnZHAxcnuWii6T+A== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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/wireless/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); } +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 = copy_packets(wilc, entries, vmm_table, vmm_entries_ac); + if (len <= 0) + return len; + + acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); + ret = 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_count) if (entries <= 0) { ret = entries; } else { - ret = copy_packets(wilc, entries, vmm_table, vmm_entries_ac); - if (ret > 0) { - acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); - ret = send_packets(wilc, ret); - release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); - } + ret = copy_and_send_packets(wilc, entries, vmm_table, vmm_entries_ac); } if (ret >= 0 && entries < vmm_table_len) ret = WILC_VMM_ENTRY_FULL_RETRY; From patchwork Thu Dec 23 01:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697838 X-Patchwork-Delegate: kvalo@adurom.com 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 97CBAC433F5 for ; Thu, 23 Dec 2021 01:15:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346203AbhLWBPx (ORCPT ); Wed, 22 Dec 2021 20:15:53 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27452 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346261AbhLWBOw (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvEhJic2zkDB1r+fbUc8nmpgeA7v6NrfJJORVx0hnOWe//ipO5kL0BYhAsRVAYQ+iZyXl2JaXGGqJdDuCTqpBdy+n6hvprucS0fMH/Zq7BVFBNN8NhFKZrgn3QOL82HIaBsuKjSL4aT6fDKHyPMqSX7cPKXXn4s0hTWnI1iT0olqHaBfZoPVI/WWCcxKgQt05Ww== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This 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/net/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 device *dev, int io_type, for (i = 0; i < NQUEUES; i++) skb_queue_head_init(&wl->txq[i]); + skb_queue_head_init(&wl->chipq); + wl->chipq_bytes = 0; + INIT_LIST_HEAD(&wl->rxq_head.list); INIT_LIST_HEAD(&wl->vif_list); 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; + /* 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; struct device *dev; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/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 = vif->wilc; wilc->quit = 1; + + while ((tqe = __skb_dequeue(&wilc->chipq))) + wilc_wlan_tx_packet_done(tqe, 0); + wilc->chipq_bytes = 0; + for (ac = 0; ac < NQUEUES; ac++) { while ((tqe = skb_dequeue(&wilc->txq[ac]))) wilc_wlan_tx_packet_done(tqe, 0); From patchwork Thu Dec 23 01:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697840 X-Patchwork-Delegate: kvalo@adurom.com 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 0BD91C433EF for ; Thu, 23 Dec 2021 01:16:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346696AbhLWBQB (ORCPT ); Wed, 22 Dec 2021 20:16:01 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27394 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346253AbhLWBOs (ORCPT ); Wed, 22 Dec 2021 20:14:48 -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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvN1V65Kxvy8FSt8TqvXxPJ4NYhhzW59EiQOJdXjEbKiDG1I/gLb8fMJLj1arpTJuPbRzYLx7qBu/kxTrwwnlEmsgaTlsibD9j0f9aJXflSf3kpIYsjyyj/V3mMbbxshzIFPjuFr7tGG6Rpldy2W8gu46v4qZJf/q/vuoo7Rfgd4qpa9Pfklnt4/ZEjvuGvB0Pg== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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/wireless/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 vmm_sz) return cpu_to_le32(entry); } +/** + * 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 = WILC_SKB_TX_CB(tqe); + u32 mgmt_pkt = 0, vmm_hdr, prio, data_len = tqe->len; + struct wilc_vif *vif; + + /* add the VMM header word: */ + if (tx_cb->type == WILC_MGMT_PKT) + mgmt_pkt = FIELD_PREP(WILC_VMM_HDR_MGMT_FIELD, 1); + vmm_hdr = 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 == WILC_NET_PKT) { + vif = netdev_priv(tqe->dev); + prio = 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] = {0, 0, 0, 0}; struct wilc_skb_tx_cb *tx_cb; u8 *txb = wilc->tx_buffer; - struct wilc_vif *vif; int i, vmm_sz; u32 offset; @@ -835,9 +865,7 @@ static int copy_packets(struct wilc *wilc, int entries, u32 *vmm_table, i = 0; do { struct sk_buff *tqe; - u32 header, buffer_offset; - char *bssid; - u8 mgmt_ptk = 0; + u32 buffer_offset; tqe = 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, atomic_dec(&wilc->txq_entries); ac_pkt_num_to_chip[vmm_entries_ac[i]]++; - vif = netdev_priv(tqe->dev); tx_cb = WILC_SKB_TX_CB(tqe); if (vmm_table[i] == 0) break; @@ -854,25 +881,8 @@ static int copy_packets(struct wilc *wilc, int entries, u32 *vmm_table, vmm_sz = FIELD_GET(WILC_VMM_BUFFER_SIZE, vmm_table[i]); vmm_sz *= 4; - if (tx_cb->type == WILC_MGMT_PKT) - mgmt_ptk = 1; - - header = (FIELD_PREP(WILC_VMM_HDR_TYPE, tx_cb->type) | - FIELD_PREP(WILC_VMM_HDR_MGMT_FIELD, mgmt_ptk) | - FIELD_PREP(WILC_VMM_HDR_PKT_SIZE, tqe->len) | - FIELD_PREP(WILC_VMM_HDR_BUFF_SIZE, vmm_sz)); - - cpu_to_le32s(&header); - memcpy(&txb[offset], &header, 4); buffer_offset = tx_hdr_len(tx_cb->type); - if (tx_cb->type == WILC_NET_PKT) { - int prio = tx_cb->q_num; - - bssid = 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 += vmm_sz; i++; From patchwork Thu Dec 23 01:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697830 X-Patchwork-Delegate: kvalo@adurom.com 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 83291C433F5 for ; Thu, 23 Dec 2021 01:15:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346381AbhLWBPV (ORCPT ); Wed, 22 Dec 2021 20:15:21 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27300 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346226AbhLWBOm (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvBgZ7zOwzn4laz2B2YR5jnghoHbnUyOMtWfZQXLA7QbOSeZLdzBFqeWmDqHT1dKa0NWNHzFW9Kvr0mgeYzAt0icBkY5E1cTW4Xy2zbjoFMvFse5fkre3CTLNVj93k+//k7662WjqvHVE1jKzaCFcqjpSbIC+FK33EiN4hbBjX3CFfgfNh8UKDDsl4oxEJ4PwIA== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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/wireless/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_buff *tqe, } /** - * 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] = {1, 1, 1, 1}; u8 ac_desired_ratio[NQUEUES]; const u8 *num_pkts_to_add; bool ac_exist = 0; int vmm_sz = 0; - struct sk_buff *tqe_q[NQUEUES]; + struct sk_buff *tqe; struct wilc_skb_tx_cb *tx_cb; - for (ac = 0; ac < NQUEUES; ac++) - tqe_q[ac] = skb_peek(&wilc->txq[ac]); - i = 0; - sum = 0; + + if (unlikely(wilc->chipq_bytes > 0)) { + /* fill in packets that are already on the chipq: */ + skb_queue_walk(&wilc->chipq, tqe) { + tx_cb = WILC_SKB_TX_CB(tqe); + vmm_sz = tx_hdr_len(tx_cb->type); + vmm_sz += tqe->len; + vmm_sz = ALIGN(vmm_sz, 4); + vmm_table[i++] = vmm_table_entry(tqe, vmm_sz); + } + } ac_balance(wilc, ac_desired_ratio); num_pkts_to_add = ac_desired_ratio; do { ac_exist = 0; for (ac = 0; ac < NQUEUES; ac++) { - if (!tqe_q[ac]) + if (skb_queue_len(&wilc->txq[ac]) < 1) continue; ac_exist = 1; - for (k = 0; k < num_pkts_to_add[ac] && tqe_q[ac]; k++) { + for (k = 0; k < num_pkts_to_add[ac]; k++) { if (i >= WILC_VMM_TBL_SIZE - 1) goto out; - tx_cb = WILC_SKB_TX_CB(tqe_q[ac]); + tqe = skb_dequeue(&wilc->txq[ac]); + if (!tqe) + continue; + + tx_cb = WILC_SKB_TX_CB(tqe); vmm_sz = tx_hdr_len(tx_cb->type); - vmm_sz += tqe_q[ac]->len; + vmm_sz += tqe->len; vmm_sz = ALIGN(vmm_sz, 4); - 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] = vmm_table_entry(tqe_q[ac], vmm_sz); - vmm_entries_ac[i] = ac; + } + atomic_dec(&wilc->txq_entries); + + __skb_queue_tail(&wilc->chipq, tqe); + wilc->chipq_bytes += tqe->len; + vmm_table[i] = vmm_table_entry(tqe, vmm_sz); i++; - sum += vmm_sz; - tqe_q[ac] = skb_peek_next(tqe_q[ac], - &wilc->txq[ac]); + } } num_pkts_to_add = ac_preserve_ratio; @@ -837,14 +842,11 @@ static int send_vmm_table(struct wilc *wilc, } /** - * 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] = {0, 0, 0, 0}; struct wilc_skb_tx_cb *tx_cb; @@ -867,21 +868,19 @@ static int copy_packets(struct wilc *wilc, int entries, u32 *vmm_table, struct sk_buff *tqe; u32 buffer_offset; - tqe = skb_dequeue(&wilc->txq[vmm_entries_ac[i]]); - if (!tqe) + tqe = __skb_dequeue(&wilc->chipq); + if (WARN_ON(!tqe)) break; + wilc->chipq_bytes -= tqe->len; - atomic_dec(&wilc->txq_entries); - ac_pkt_num_to_chip[vmm_entries_ac[i]]++; tx_cb = WILC_SKB_TX_CB(tqe); - if (vmm_table[i] == 0) - break; - - le32_to_cpus(&vmm_table[i]); - vmm_sz = FIELD_GET(WILC_VMM_BUFFER_SIZE, vmm_table[i]); - vmm_sz *= 4; + ac_pkt_num_to_chip[tx_cb->q_num]++; buffer_offset = tx_hdr_len(tx_cb->type); + vmm_sz = buffer_offset; + vmm_sz += tqe->len; + vmm_sz = ALIGN(vmm_sz, 4); + set_header(wilc, tqe, vmm_sz, txb + offset); memcpy(&txb[offset + buffer_offset], tqe->data, tqe->len); offset += 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); } -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; - len = copy_packets(wilc, entries, vmm_table, vmm_entries_ac); + len = copy_packets(wilc, entries); if (len <= 0) return len; @@ -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 = 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_count) wilc_wlan_txq_filter_dup_tcp_ack(vif->ndev); srcu_read_unlock(&wilc->srcu, srcu_idx); - vmm_table_len = fill_vmm_table(wilc, vmm_table, vmm_entries_ac); + vmm_table_len = fill_vmm_table(wilc, vmm_table); if (vmm_table_len == 0) goto out_unlock; @@ -966,7 +962,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) if (entries <= 0) { ret = entries; } else { - ret = copy_and_send_packets(wilc, entries, vmm_table, vmm_entries_ac); + ret = copy_and_send_packets(wilc, entries); } if (ret >= 0 && entries < vmm_table_len) ret = WILC_VMM_ENTRY_FULL_RETRY; From patchwork Thu Dec 23 01:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697841 X-Patchwork-Delegate: kvalo@adurom.com 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 951D3C43217 for ; Thu, 23 Dec 2021 01:16:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346704AbhLWBQC (ORCPT ); Wed, 22 Dec 2021 20:16:02 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27382 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346252AbhLWBOr (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvMTg55MYAqxjZd/NYMBupDVuLv7j/03Wcbcz16/VnnLJEBfaOIbI/U3ubx1XABWR3g1bZkHu+ef6gWQG5mjxORQb6Hfrq+sdCdyc5M95tHQdN50gsf9B0UqR2KGOQsP5ooW52H+OU+MMFjRvosNRMcNSN6DuCHof3YunBTk7B8qCOGI9fLSxQ6xq8eH/pRZKYg== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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/net/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); - mutex_init(&wl->txq_add_to_head_cs); mutex_init(&wl->tx_q_limit_lock); 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; - /* protect head of transmit queue */ - struct mutex txq_add_to_head_cs; - /* protect rxq_entry_t receiver queue */ struct mutex rxq_cs; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/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 *vif, u8 type, u8 q_num, init_txq_entry(tqe, type, q_num); - mutex_lock(&wilc->txq_add_to_head_cs); - skb_queue_head(&wilc->txq[q_num], tqe); atomic_inc(&wilc->txq_entries); - mutex_unlock(&wilc->txq_add_to_head_cs); wake_up_interruptible(&wilc->txq_event); } @@ -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_count) if (wilc->quit) goto out_update_cnt; - mutex_lock(&wilc->txq_add_to_head_cs); - srcu_idx = srcu_read_lock(&wilc->srcu); list_for_each_entry_rcu(vif, &wilc->vif_list, list) wilc_wlan_txq_filter_dup_tcp_ack(vif->ndev); @@ -949,7 +941,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) vmm_table_len = fill_vmm_table(wilc, vmm_table); if (vmm_table_len == 0) - goto out_unlock; + goto out_update_cnt; acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); @@ -967,9 +959,6 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) if (ret >= 0 && entries < vmm_table_len) ret = WILC_VMM_ENTRY_FULL_RETRY; -out_unlock: - mutex_unlock(&wilc->txq_add_to_head_cs); - out_update_cnt: *txq_count = atomic_read(&wilc->txq_entries); return ret; From patchwork Thu Dec 23 01:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697839 X-Patchwork-Delegate: kvalo@adurom.com 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 C5034C433F5 for ; Thu, 23 Dec 2021 01:16:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346364AbhLWBP7 (ORCPT ); Wed, 22 Dec 2021 20:15:59 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27420 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346258AbhLWBOs (ORCPT ); Wed, 22 Dec 2021 20:14:48 -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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvMOna4O64C+EU0IbF+d1EnOG7clc59szXsBOdaG1ztylnbJHADMhMEtQp2I/xpqLi9YzOWNpcnRckNLLmFj7jbDtV486Ew9E47mwa5rrI7Ym31WmQauQo5TSnW9duGEl0h+GfBeyHPfwjE7CgSJm3Bkvs3XFkkp5AivgDIu/PKDLdp2gc24D1yeZjDtnrNKkCQ== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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/wireless/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_buff *tqe, } /** - * 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] = {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; - i = 0; - - if (unlikely(wilc->chipq_bytes > 0)) { - /* fill in packets that are already on the chipq: */ - skb_queue_walk(&wilc->chipq, tqe) { - tx_cb = WILC_SKB_TX_CB(tqe); - vmm_sz = tx_hdr_len(tx_cb->type); - vmm_sz += tqe->len; - vmm_sz = ALIGN(vmm_sz, 4); - vmm_table[i++] = vmm_table_entry(tqe, vmm_sz); - } - } - ac_balance(wilc, ac_desired_ratio); num_pkts_to_add = ac_desired_ratio; do { @@ -718,7 +703,7 @@ static int fill_vmm_table(struct wilc *wilc, ac_exist = 1; for (k = 0; k < num_pkts_to_add[ac]; k++) { if (i >= WILC_VMM_TBL_SIZE - 1) - goto out; + return i; tqe = 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); @@ -746,8 +731,45 @@ static int fill_vmm_table(struct wilc *wilc, } num_pkts_to_add = ac_preserve_ratio; } while (ac_exist); -out: - vmm_table[i] = 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_SIZE]) +{ + int i; + int vmm_sz = 0; + struct sk_buff *tqe; + struct wilc_skb_tx_cb *tx_cb; + + i = 0; + + if (unlikely(wilc->chipq_bytes > 0)) { + /* fill in packets that are already on the chipq: */ + skb_queue_walk(&wilc->chipq, tqe) { + tx_cb = WILC_SKB_TX_CB(tqe); + vmm_sz = tx_hdr_len(tx_cb->type); + vmm_sz += tqe->len; + vmm_sz = ALIGN(vmm_sz, 4); + vmm_table[i++] = vmm_table_entry(tqe, vmm_sz); + } + } + + i = schedule_packets(wilc, i, vmm_table); + if (i > 0) { + WARN_ON(i >= WILC_VMM_TBL_SIZE); + vmm_table[i] = 0x0; + } return i; } From patchwork Thu Dec 23 01:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697845 X-Patchwork-Delegate: kvalo@adurom.com 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 E9F6CC433F5 for ; Thu, 23 Dec 2021 01:16:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346786AbhLWBQT (ORCPT ); Wed, 22 Dec 2021 20:16:19 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27352 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346240AbhLWBOp (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvPuMcF/BHm6zz5zzmpsOhjqu7S67FdJWIs8jvoN5AmbDIi6dQ8lNtN54xxhDmyuQ276OPAzpKlpaoXNFiJAEfxr9wPtcrvfGZixzr32KlEK7Bse2M3yDlPofPOXCtgL4a5I2o7o0OFuq4T9T05KfXjLYZYc903u9NP0HGpJpzXh5DqXVIUN9B0p5YrBimE/XDw== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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/wireless/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_buff *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] = {1, 1, 1, 1}; @@ -702,8 +702,8 @@ static int schedule_packets(struct wilc *wilc, ac_exist = 1; for (k = 0; k < num_pkts_to_add[ac]; k++) { - if (i >= WILC_VMM_TBL_SIZE - 1) - return i; + if (vmm_table_len >= WILC_VMM_TBL_SIZE - 1) + return vmm_table_len; tqe = 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); __skb_queue_tail(&wilc->chipq, tqe); wilc->chipq_bytes += tqe->len; - vmm_table[i] = vmm_table_entry(tqe, vmm_sz); - i++; + vmm_table[vmm_table_len] = vmm_table_entry(tqe, vmm_sz); + vmm_table_len++; } } num_pkts_to_add = ac_preserve_ratio; } while (ac_exist); - return i; + return vmm_table_len; } /** @@ -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_SIZE]) { - int i; - int vmm_sz = 0; + int vmm_table_len = 0, vmm_sz = 0; struct sk_buff *tqe; struct wilc_skb_tx_cb *tx_cb; - i = 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 = tx_hdr_len(tx_cb->type); vmm_sz += tqe->len; vmm_sz = ALIGN(vmm_sz, 4); - vmm_table[i++] = vmm_table_entry(tqe, vmm_sz); + vmm_table[vmm_table_len++] = vmm_table_entry(tqe, vmm_sz); } } - i = schedule_packets(wilc, i, vmm_table); - if (i > 0) { - WARN_ON(i >= WILC_VMM_TBL_SIZE); - vmm_table[i] = 0x0; + vmm_table_len = schedule_packets(wilc, vmm_table_len, vmm_table); + if (vmm_table_len > 0) { + WARN_ON(vmm_table_len >= WILC_VMM_TBL_SIZE); + vmm_table[vmm_table_len] = 0x0; } - return i; + return vmm_table_len; } /** From patchwork Thu Dec 23 01:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697843 X-Patchwork-Delegate: kvalo@adurom.com 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 7CEC7C43217 for ; Thu, 23 Dec 2021 01:16:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346327AbhLWBQR (ORCPT ); Wed, 22 Dec 2021 20:16:17 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27338 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346241AbhLWBOq (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvJwCYg8sr53xntpFMRamCYBsHW6iylotlCCb9egN/BBDuQ1z/xYKvh6cntcV6X5h9Sln5AMVFLh/TmorjPALjoSh4bEL1Ftn4KzEHNHaBFqzHshHzhj+1jVHdMspyWAt7YlB5zkA+Fujc6MPDP4jusopUbYzo3up2+iUzyrM6O9bz7WBMB6ivQDB4nhy9s14rg== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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); + ndev->needed_headroom = ETH_CONFIG_PKT_HDR_OFFSET; + /* we may need up to 3 bytes of padding: */ + ndev->needed_tailroom = 3; + vif = netdev_priv(ndev); ndev->ieee80211_ptr = &vif->priv.wdev; strcpy(ndev->name, name); diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/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) } } -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 = WILC_SKB_TX_CB(tqe); u32 entry; - entry = vmm_sz / 4; + entry = tqe->len / 4; if (tx_cb->type == WILC_CFG_PKT) entry |= WILC_VMM_CFG_PKT; return cpu_to_le32(entry); } /** - * 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 = WILC_SKB_TX_CB(tqe); u32 mgmt_pkt = 0, vmm_hdr, prio, data_len = tqe->len; struct wilc_vif *vif; + void *hdr; + + /* grow skb with header and pad bytes, all initialized to 0: */ + hdr = skb_push(tqe, hdr_len); + if (vmm_sz > tqe->len) + skb_put(tqe, vmm_sz - tqe->len); /* add the VMM header word: */ if (tx_cb->type == WILC_MGMT_PKT) @@ -687,8 +696,8 @@ static int schedule_packets(struct wilc *wilc, static const u8 ac_preserve_ratio[NQUEUES] = {1, 1, 1, 1}; u8 ac_desired_ratio[NQUEUES]; const u8 *num_pkts_to_add; + u32 vmm_sz, hdr_len; bool ac_exist = 0; - int vmm_sz = 0; struct sk_buff *tqe; struct wilc_skb_tx_cb *tx_cb; @@ -710,8 +719,8 @@ static int schedule_packets(struct wilc *wilc, continue; tx_cb = WILC_SKB_TX_CB(tqe); - vmm_sz = tx_hdr_len(tx_cb->type); - vmm_sz += tqe->len; + hdr_len = tx_hdr_len(tx_cb->type); + vmm_sz = hdr_len + tqe->len; vmm_sz = ALIGN(vmm_sz, 4); 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); + add_hdr_and_pad(wilc, tqe, hdr_len, vmm_sz); + __skb_queue_tail(&wilc->chipq, tqe); wilc->chipq_bytes += tqe->len; - vmm_table[vmm_table_len] = vmm_table_entry(tqe, vmm_sz); + vmm_table[vmm_table_len] = vmm_table_entry(tqe); vmm_table_len++; - } } num_pkts_to_add = 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_SIZE]) { - int vmm_table_len = 0, vmm_sz = 0; + int vmm_table_len = 0; struct sk_buff *tqe; - struct wilc_skb_tx_cb *tx_cb; - 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 = WILC_SKB_TX_CB(tqe); - vmm_sz = tx_hdr_len(tx_cb->type); - vmm_sz += tqe->len; - vmm_sz = ALIGN(vmm_sz, 4); - vmm_table[vmm_table_len++] = vmm_table_entry(tqe, vmm_sz); - } - } + skb_queue_walk(&wilc->chipq, tqe) + vmm_table[vmm_table_len++] = vmm_table_entry(tqe); vmm_table_len = 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 entries) u8 ac_pkt_num_to_chip[NQUEUES] = {0, 0, 0, 0}; struct wilc_skb_tx_cb *tx_cb; u8 *txb = wilc->tx_buffer; - int i, vmm_sz; + int i; + struct sk_buff *tqe; u32 offset; offset = 0; - i = 0; do { - struct sk_buff *tqe; - u32 buffer_offset; - tqe = __skb_dequeue(&wilc->chipq); if (WARN_ON(!tqe)) break; @@ -889,15 +889,8 @@ static int copy_packets(struct wilc *wilc, int entries) tx_cb = WILC_SKB_TX_CB(tqe); ac_pkt_num_to_chip[tx_cb->q_num]++; - buffer_offset = tx_hdr_len(tx_cb->type); - vmm_sz = buffer_offset; - vmm_sz += tqe->len; - vmm_sz = ALIGN(vmm_sz, 4); - - set_header(wilc, tqe, vmm_sz, txb + offset); - memcpy(&txb[offset + buffer_offset], tqe->data, tqe->len); - offset += vmm_sz; - i++; + memcpy(&txb[offset], tqe->data, tqe->len); + offset += tqe->len; wilc_wlan_tx_packet_done(tqe, 1); } while (--entries); for (i = 0; i < NQUEUES; i++) From patchwork Thu Dec 23 01:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697829 X-Patchwork-Delegate: kvalo@adurom.com 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 D5780C433F5 for ; Thu, 23 Dec 2021 01:15:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242188AbhLWBPT (ORCPT ); Wed, 22 Dec 2021 20:15:19 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27308 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346230AbhLWBOm (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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvCpc2ftgM2qu67NNBuHZcfjZzUnbiHUNZbafQh3Mqs3rJrxKIhGH79qo89Du1mpWVV3Bd5CTB5MIKKbipe9JjI/zK3/l4NbHghbcmPkBseDHeZARrYfMRwCrz5cQwICK031Q4PnuLnRe9QY5X5acKT63TsvYOIKk7H+jfDPp344plJ1Z9VKWgk0lD3WmvF5B1w== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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/wireless/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, int entries) return ret; } +/** + * 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 = wilc->hif_func; + struct wilc_skb_tx_cb *tx_cb; + struct sk_buff *tqe; + int ret, i = 0; + + acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); + + ret = func->hif_clear_int_ext(wilc, ENABLE_TX_VMM); + if (ret == 0) + ret = func->hif_sk_buffs_tx(wilc, 0, entries, &wilc->chipq); + + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); + + for (i = 0; i < entries; ++i) { + tqe = __skb_dequeue(&wilc->chipq); + tx_cb = WILC_SKB_TX_CB(tqe); + wilc->fw[tx_cb->q_num].count++; + wilc->chipq_bytes -= tqe->len; + wilc_wlan_tx_packet_done(tqe, ret == 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 <= 0) { ret = entries; } else { - ret = copy_and_send_packets(wilc, entries); + if (wilc->hif_func->hif_sk_buffs_tx) + ret = zero_copy_send_packets(wilc, entries); + else + ret = copy_and_send_packets(wilc, entries); } if (ret >= 0 && entries < vmm_table_len) ret = WILC_VMM_ENTRY_FULL_RETRY; diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/wireless/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); From patchwork Thu Dec 23 01:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697831 X-Patchwork-Delegate: kvalo@adurom.com 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 F17D5C433EF for ; Thu, 23 Dec 2021 01:15:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346296AbhLWBPS (ORCPT ); Wed, 22 Dec 2021 20:15:18 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27298 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346225AbhLWBOm (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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvCku2d01bUPHXOooMP+/Uf3qjDaNo4LbXVJ1cRCS8pJYe4aPxCLVg3LPM7wKTY3qogKRr+YpQH0519OH2M8hpB4NZjZKunaHEkmPPwism+S4DYZvqP2+CJrhK5vtcQLwAUmryUrxiEJsHMQ7VBwIoJ6o4EAWmLYChlo/lzTRj+pfIDF8IVBjo48BvdnDRQOwaQ== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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/wireless/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) init_q_limits(wilc); - if (!wilc->tx_buffer) + if (!wilc->hif_func->hif_sk_buffs_tx && !wilc->tx_buffer) { wilc->tx_buffer = kmalloc(WILC_TX_BUFF_SIZE, GFP_KERNEL); - - if (!wilc->tx_buffer) { - ret = -ENOBUFS; - goto fail; + if (!wilc->tx_buffer) { + ret = -ENOBUFS; + goto fail; + } } if (!wilc->rx_buffer) From patchwork Thu Dec 23 01:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697833 X-Patchwork-Delegate: kvalo@adurom.com 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 60F21C433EF for ; Thu, 23 Dec 2021 01:15:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346460AbhLWBPY (ORCPT ); Wed, 22 Dec 2021 20:15:24 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27374 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346246AbhLWBOp (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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvH9Cvv/5ehKJw44677quhFIAFUnbiUWmbmmTg6+hqXGuYJ3ieEzuxpbm7Je+yt+BbiVHKqzw5OrYGLhvWgBHh5inoafnrrpEK2yRyGTt4dr+D3eA/RVVzGhrnebnHKHHnIn3Ov3VO0iiNdKKUz1jxWdRA+H1AbU8ylwJAHEoXqPxTmaYro4siN6gYujA+J0kpg== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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/wireless/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 -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; 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) +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 { From patchwork Thu Dec 23 01:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697834 X-Patchwork-Delegate: kvalo@adurom.com 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 BFB6CC433EF for ; Thu, 23 Dec 2021 01:15:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345935AbhLWBPj (ORCPT ); Wed, 22 Dec 2021 20:15:39 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27522 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346278AbhLWBOz (ORCPT ); Wed, 22 Dec 2021 20:14:55 -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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvCNKwj+DYMFZnlIhPR3K1iY1ejP/1ZZy1gRWB3YD8/XZCKVGtzkSucLwWRtW7fomsuWltgqRjiEBKbxvD+9e/p3SVxfMklNvxmp5HYNKcSfaHCVGYdDwC5PyAQ4OxlyPw5qSPDKq2fDOn07kQOK5eo2M3g9WgUc4R6bC+VPaYPKgGGGujWFBIHi6A2pTvhh5Cw== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Factor 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/wireless/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, u32 adr, u8 *b, u32 sz) u8 wb[32], rb[32]; int cmd_len, resp_len; int retry, ix = 0; - u8 crc[2]; + u8 crc[2], *crc7; struct wilc_spi_cmd *c; struct wilc_spi_rsp_data *r; @@ -673,8 +673,6 @@ static int wilc_spi_dma_rw(struct wilc *wilc, u8 cmd, u32 adr, u8 *b, u32 sz) c->u.dma_cmd.size[0] = sz >> 8; c->u.dma_cmd.size[1] = sz; cmd_len = offsetof(struct wilc_spi_cmd, u.dma_cmd.crc); - if (spi_priv->crc7_enabled) - c->u.dma_cmd.crc[0] = wilc_get_crc7(wb, cmd_len); } else if (cmd == CMD_DMA_EXT_WRITE || cmd == CMD_DMA_EXT_READ) { c->u.dma_cmd_ext.addr[0] = adr >> 16; c->u.dma_cmd_ext.addr[1] = 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] = sz >> 8; c->u.dma_cmd_ext.size[2] = sz; cmd_len = offsetof(struct wilc_spi_cmd, u.dma_cmd_ext.crc); - if (spi_priv->crc7_enabled) - c->u.dma_cmd_ext.crc[0] = 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 = wb + cmd_len; + *crc7 = wilc_get_crc7(wb, cmd_len); cmd_len += 1; + } resp_len = sizeof(*r); From patchwork Thu Dec 23 01:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697836 X-Patchwork-Delegate: kvalo@adurom.com 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 A005CC4332F for ; Thu, 23 Dec 2021 01:15:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346623AbhLWBPo (ORCPT ); Wed, 22 Dec 2021 20:15:44 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27476 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346271AbhLWBOy (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvANxWyaBzmrT8i6kBIwcOApodCCbwNMcx6CCkJweUuGfzFJsSRyTzgz3Qq5GQeAeySg3GXqJwB66FAOqWelVjAjBnKZ+u4KzlAW2T5A5im3WD+xBUlH5RQuG8zgX7WiE7mT87kfJwlJa6F7wI+r3qNdPCAohl5raYMAlrb2D1Ci7MDJYf2euPJ/CB5V0ZdcZtw== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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/wireless/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 cmd, u32 adr, u32 data, return 0; } -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 = to_spi_device(wilc->dev); struct wilc_spi *spi_priv = wilc->bus_data; - u16 crc_recv, crc_calc; - u8 wb[32], rb[32]; - int cmd_len, resp_len; - int retry, ix = 0; - u8 crc[2], *crc7; - struct wilc_spi_cmd *c; - struct wilc_spi_rsp_data *r; + int cmd_len; + u8 *crc7; - memset(wb, 0x0, sizeof(wb)); - memset(rb, 0x0, sizeof(rb)); - c = (struct wilc_spi_cmd *)wb; c->cmd_type = cmd; if (cmd == CMD_DMA_WRITE || cmd == CMD_DMA_READ) { c->u.dma_cmd.addr[0] = 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 = wb + cmd_len; - *crc7 = wilc_get_crc7(wb, cmd_len); + crc7 = (u8 *)c + cmd_len; + *crc7 = wilc_get_crc7((u8 *)c, cmd_len); cmd_len += 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 = to_spi_device(wilc->dev); + struct wilc_spi *spi_priv = wilc->bus_data; + u16 crc_recv, crc_calc; + u8 wb[32], rb[32]; + int cmd_len, resp_len; + int retry, ix = 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 = (struct wilc_spi_cmd *)wb; + + cmd_len = wilc_spi_dma_init_cmd(wilc, c, cmd, adr, sz); + if (cmd_len < 0) + return -EINVAL; resp_len = sizeof(*r); From patchwork Thu Dec 23 01:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697842 X-Patchwork-Delegate: kvalo@adurom.com 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 AC875C433F5 for ; Thu, 23 Dec 2021 01:16:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346340AbhLWBQE (ORCPT ); Wed, 22 Dec 2021 20:16:04 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27404 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346250AbhLWBOr (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvHaV6O7GMUw/W4PJdG4gRHrkryCd/53ygKA8OXI7MLM8aSLx7D5aeIlNEdbxks55dlrMYbZ9kHO1bo7vRbn7Y8dAaz2cOZhD9OyZy5m8eROGxtYDgI0cKrXn6LrfUyCnKFIbeYQBiBEgOVMxU7DMKo3WAAZQO890dAJHsBYiWMfci8BrWfbBZBD72C71jK0n2Q== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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/wireless/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) +/* 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; } -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 = 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 = wilc_spi_rx(wilc, rsp, sizeof(rsp)); - if (result) { - dev_err(&spi->dev, "Failed bus error...\n"); - return result; - } + int i; - for (i = sizeof(rsp) - 2; i >= 0; --i) + for (i = WILC_SPI_DATA_RSP_BYTES - 2; i >= 0; --i) if (FIELD_GET(RSP_START_FIELD, rsp[i]) == RSP_START_TAG) break; @@ -996,6 +990,20 @@ static int spi_data_rsp(struct wilc *wilc, u8 cmd) return 0; } +static int spi_data_rsp(struct wilc *wilc, u8 cmd) +{ + struct spi_device *spi = to_spi_device(wilc->dev); + u8 rsp[WILC_SPI_DATA_RSP_BYTES]; + int result; + + result = 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 = to_spi_device(wilc->dev); From patchwork Thu Dec 23 01:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697835 X-Patchwork-Delegate: kvalo@adurom.com 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 67A8AC433F5 for ; Thu, 23 Dec 2021 01:15:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346618AbhLWBPl (ORCPT ); Wed, 22 Dec 2021 20:15:41 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:27505 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346273AbhLWBOy (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvIXjviVKntPmow2PsUz0li20mrVt8rN+SLyzZEQOCNzWH1oSVsNrpOx1b+zybfU/kDGwNSPAcuq2hGsZfhMBjwSt6MI2EM+mSNbzlKY3z3Y6L2RPeHRdgOFsskVAf2oKQAMlAjkUu2wsWOHTHPfZ9sMcxfhQ63lkxe1MDH0utZB+HgMISG453ChzSYdeH2710g== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org This 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/wireless/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; 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); /******************************************** * @@ -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) +#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) +/* 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]; }; struct wilc_spi_cmd { @@ -1037,6 +1068,136 @@ static int wilc_spi_write(struct wilc *wilc, u32 addr, u8 *buf, u32 size) return spi_data_rsp(wilc, CMD_DMA_EXT_WRITE); } +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 = *xferp; + + xfer->tx_buf = tx_buf; + xfer->rx_buf = rx_buf; + xfer->len = len; + spi_message_add_tail(xfer, msg); + *xferp = 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 = DATA_START_TAG | DATA_ORDER_FIRST; + static const u8 data_hdr_inner = DATA_START_TAG | DATA_ORDER_INNER; + static const u8 data_hdr_last = DATA_START_TAG | DATA_ORDER_LAST; + size_t num_data_packets = 0, total_bytes = 0, num_sent, n, space; + struct spi_device *spi = to_spi_device(wilc->dev); + struct wilc_spi *spi_priv = 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 = spi; + + skb = skb_peek(skbs); + for (i = 0; i < num_skbs; ++i) { + n = skb->len; + total_bytes += n; + skb = skb_peek_next(skb, skbs); + } + + num_data_packets = DIV_ROUND_UP(total_bytes, DATA_PKT_SZ); + skb = skb_peek(skbs); + num_sent = 0; + xfer = spi_priv->xfer; + crc = spi_priv->crc; + + cmd_len = 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 = 0; i < num_data_packets; ++i) { + space = DATA_PKT_SZ; + crc_calc = 0xffff; + + /* write data packet's start header: */ + if (i == num_data_packets - 1) + data_hdr = &data_hdr_last; + else if (i == 0) + data_hdr = &data_hdr_first; + else + data_hdr = &data_hdr_inner; + wilc_spi_add_xfer(&msg, &xfer, 1, data_hdr, NULL); + + /* write packet data: */ + do { + n = skb->len - num_sent; + if (n > space) + n = space; + wilc_spi_add_xfer(&msg, &xfer, n, + skb->data + num_sent, NULL); + if (spi_priv->crc16_enabled) + crc_calc = crc_itu_t(crc_calc, + skb->data + num_sent, n); + num_sent += n; + space -= n; + + if (num_sent >= skb->len) { + skb = skb_peek_next(skb, skbs); + --num_skbs; + num_sent = 0; + } + } while (space > 0 && num_skbs > 0); + + /* write optional CRC16 checksum: */ + if (spi_priv->crc16_enabled) { + crc[0] = crc_calc >> 8; + crc[1] = crc_calc; + wilc_spi_add_xfer(&msg, &xfer, 2, crc, NULL); + crc += 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 = spi_sync(spi, &msg); + if (ret < 0) { + dev_err(&spi->dev, "spi_sync() failed: ret=%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 = { .hif_read_size = wilc_spi_read_size, .hif_block_tx_ext = wilc_spi_write, .hif_block_rx_ext = wilc_spi_read, + .hif_sk_buffs_tx = wilc_spi_write_sk_buffs, .hif_sync_ext = wilc_spi_sync_ext, .hif_reset = wilc_spi_reset, }; From patchwork Thu Dec 23 01:14:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Mosberger-Tang X-Patchwork-Id: 12697848 X-Patchwork-Delegate: kvalo@adurom.com 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 439B7C433EF for ; Thu, 23 Dec 2021 01:16:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346014AbhLWBQi (ORCPT ); Wed, 22 Dec 2021 20:16:38 -0500 Received: from o1.ptr2625.egauge.net ([167.89.112.53]:18696 "EHLO o1.ptr2625.egauge.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345838AbhLWBOX (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=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: +kMxBqj35EdRUKoy8diX1j4AXmPtd302oan+iXZuF8m2Nw4HRW2irNspffT/khET6RJF6+Prbl0h/EtF1rRLvNU/AiSwPXGwNeF4R8pktv6qIQV9/vaYSYgd73qzUc+WcF+3KTLAn0DzBHXeSqbDC7G4R7ZfYu1EAHyy3Sq2tG4eerFoLwPWgQBlB4hho+sXfAoa07rJ+kJnUztYPjGRmA0wp/JGqfOozcJ7djVy2VWuSHpeE4jDG+RBqGPUIpD5o+1b5h5OMzvrxVFltrvutA== To: Ajay Singh Cc: Claudiu Beznea , Kalle Valo , "David S. Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, David Mosberger-Tang X-Entity-ID: Xg4JGAcGrJFIz2kDG9eoaQ== Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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/wireless/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."); +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 -static const struct wilc_hif_func wilc_hif_spi; +static struct wilc_hif_func wilc_hif_spi; 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; + if (!disable_zero_copy_tx) + wilc_hif_spi.hif_sk_buffs_tx = wilc_spi_write_sk_buffs; + ret = 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 nint) } /* Global spi HIF function table */ -static const struct wilc_hif_func wilc_hif_spi = { +static struct wilc_hif_func wilc_hif_spi = { .hif_init = wilc_spi_init, .hif_deinit = wilc_spi_deinit, .hif_read_reg = wilc_spi_read_reg, @@ -1436,7 +1444,6 @@ static const struct wilc_hif_func wilc_hif_spi = { .hif_read_size = wilc_spi_read_size, .hif_block_tx_ext = wilc_spi_write, .hif_block_rx_ext = wilc_spi_read, - .hif_sk_buffs_tx = wilc_spi_write_sk_buffs, .hif_sync_ext = wilc_spi_sync_ext, .hif_reset = wilc_spi_reset, };