Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp138085rwp; Wed, 12 Jul 2023 10:50:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlGOdvZXAs+2dSVaYHzHGXsArAaTXJopZBGm5zhS7vZ3Txm3L3ZVlNvklyOlXue8JM/JnECz X-Received: by 2002:a05:6402:60a:b0:51e:5322:a642 with SMTP id n10-20020a056402060a00b0051e5322a642mr12039815edv.27.1689184258214; Wed, 12 Jul 2023 10:50:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689184258; cv=none; d=google.com; s=arc-20160816; b=OToGkoKdqAcnft6ftqIdk68XQra6qNhxMDcUnUsCXU5GMdhHBeD2IXZrY1SVgTBrIC DC8XfhVquejcVoY70KSjdYn6g16lxxG/YwpT+JKgXLjSBFTa7TsddZpSFUZtEW8QRaS5 aFWNv3keKJg5PGSaG5dVT6mLnbqm3SQwcVA97aZukaiXtWP37113El2ySRjvp3/sMlZf bvbvvSeqXE+JoBq+WKc6o8dOOnQVNyUWvTTssf/1AMQq4rYJ34apnTsz+sv/73/hh5UN C6dirJXwcn/OHEgUWptmZoLIN+Tofk/VRf3oeQQT8Jl3nJkSraFr+sZ/3DZMr0pa5r5R 81yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=tBsgEXpUkztgcgzQwVfDv2AkIa/Y9BOYFdQVk3U07Ug=; fh=IsCFyr0xgtW7AtiqLYMYZX9xSI8rk/57JzX28HtMV50=; b=ohnWJgkK3GVuNmlUkt4natjdse0SUNbJq2UdBWX9K6SRCFb7nN2cnrQUfOZ84cmYSZ W51DXQ59aXKiR4Cc8wa7QYISXzfzXr3xID9XVi2isqP/JbctJmej+Nl3arPEvGdtgQ9e dBGLtYs0/BxfgeJ3reBarHqsYehu97H4mIru6aiT39Kj4/Z4z5INqIMXBmQrUP4GmANZ sR3OBmtvoLxQ8IKP/ZF7b8X24hVHgrHhB5dBnJMUHKDR9PCMvhSgMwzNdmZpumvmX209 GfghC4Wwi3sHmiop3iEUersCEK5+lbI4Na8n0Egum5Za1i+VYn/cTZVao/tG2n7ZsMQE kaCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=VrWuPwEs; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a14-20020a50ff0e000000b0051dece5afcesi4917742edu.225.2023.07.12.10.50.37; Wed, 12 Jul 2023 10:50:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=VrWuPwEs; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231970AbjGLRfZ (ORCPT + 60 others); Wed, 12 Jul 2023 13:35:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231602AbjGLRfY (ORCPT ); Wed, 12 Jul 2023 13:35:24 -0400 Received: from forward101b.mail.yandex.net (forward101b.mail.yandex.net [178.154.239.148]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9D231FEC for ; Wed, 12 Jul 2023 10:35:15 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-17.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-17.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:ab03:0:640:a6db:0]) by forward101b.mail.yandex.net (Yandex) with ESMTP id 6218560033; Wed, 12 Jul 2023 20:35:13 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-17.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id CZeZZ13BUa60-9aSvUNIL; Wed, 12 Jul 2023 20:35:12 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1689183312; bh=tBsgEXpUkztgcgzQwVfDv2AkIa/Y9BOYFdQVk3U07Ug=; h=Message-ID:Date:Cc:Subject:To:From; b=VrWuPwEslADvFL6IAeYjJJHhfgF/VKXvY5smsQpmi4ITU1r4Xjcb5K0/McEZzVF8f d/mLknX57vdpNaowsB2G/HMkVmSJXdtQGsKIv4RM9W8cSnXLxWYmAe6DresABALUhk 8K0xTG53lfkwrRvtAbdNsB5OIZ5nMc9a+9UGzn4o= Authentication-Results: mail-nwsmtp-smtp-production-main-17.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Felix Fietkau Cc: Kalle Valo , linux-wireless@vger.kernel.org, Dmitry Antipov Subject: [PATCH] wifi: mt76: use native timestamps for RX reordering Date: Wed, 12 Jul 2023 20:34:26 +0300 Message-ID: <20230712173437.162921-1-dmantipov@yandex.ru> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Prefer native (i.e. unsigned long) timestamps for RX reordering. Since 'struct mt76_rx_status' with native timestamp becomes too large to fit into 48-byte 'cb' area of 'struct sk_buff', use separate timestamps in reorder array of 'struct mt76_rx_tid' instead. Signed-off-by: Dmitry Antipov --- drivers/net/wireless/mediatek/mt76/agg-rx.c | 30 ++++++++++++--------- drivers/net/wireless/mediatek/mt76/mt76.h | 7 ++--- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/agg-rx.c b/drivers/net/wireless/mediatek/mt76/agg-rx.c index 10cbd9e560e7..3b9eeb38e118 100644 --- a/drivers/net/wireless/mediatek/mt76/agg-rx.c +++ b/drivers/net/wireless/mediatek/mt76/agg-rx.c @@ -19,11 +19,13 @@ mt76_aggr_release(struct mt76_rx_tid *tid, struct sk_buff_head *frames, int idx) tid->head = ieee80211_sn_inc(tid->head); - skb = tid->reorder_buf[idx]; + skb = tid->reorder[idx].skb; if (!skb) return; - tid->reorder_buf[idx] = NULL; + tid->reorder[idx].skb = NULL; + tid->reorder[idx].timestamp = 0; + tid->nframes--; __skb_queue_tail(frames, skb); } @@ -46,7 +48,7 @@ mt76_rx_aggr_release_head(struct mt76_rx_tid *tid, struct sk_buff_head *frames) { int idx = tid->head % tid->size; - while (tid->reorder_buf[idx]) { + while (tid->reorder[idx].skb) { mt76_aggr_release(tid, frames, idx); idx = tid->head % tid->size; } @@ -70,15 +72,15 @@ mt76_rx_aggr_check_release(struct mt76_rx_tid *tid, struct sk_buff_head *frames) for (idx = (tid->head + 1) % tid->size; idx != start && nframes; idx = (idx + 1) % tid->size) { - skb = tid->reorder_buf[idx]; + skb = tid->reorder[idx].skb; if (!skb) continue; nframes--; status = (struct mt76_rx_status *)skb->cb; - if (!time_after32(jiffies, - status->reorder_time + - mt76_aggr_tid_to_timeo(tid->num))) + if (!time_after(jiffies, + tid->reorder[idx].timestamp + + mt76_aggr_tid_to_timeo(tid->num))) continue; mt76_rx_aggr_release_frames(tid, frames, status->seqno); @@ -222,13 +224,13 @@ void mt76_rx_aggr_reorder(struct sk_buff *skb, struct sk_buff_head *frames) idx = seqno % size; /* Discard if the current slot is already in use */ - if (tid->reorder_buf[idx]) { + if (tid->reorder[idx].skb) { dev_kfree_skb(skb); goto out; } - status->reorder_time = jiffies; - tid->reorder_buf[idx] = skb; + tid->reorder[idx].timestamp = jiffies; + tid->reorder[idx].skb = skb; tid->nframes++; mt76_rx_aggr_release_head(tid, frames); @@ -246,7 +248,7 @@ int mt76_rx_aggr_start(struct mt76_dev *dev, struct mt76_wcid *wcid, u8 tidno, mt76_rx_aggr_stop(dev, wcid, tidno); - tid = kzalloc(struct_size(tid, reorder_buf, size), GFP_KERNEL); + tid = kzalloc(struct_size(tid, reorder, size), GFP_KERNEL); if (!tid) return -ENOMEM; @@ -272,12 +274,14 @@ static void mt76_rx_aggr_shutdown(struct mt76_dev *dev, struct mt76_rx_tid *tid) tid->stopped = true; for (i = 0; tid->nframes && i < size; i++) { - struct sk_buff *skb = tid->reorder_buf[i]; + struct sk_buff *skb = tid->reorder[i].skb; if (!skb) continue; - tid->reorder_buf[i] = NULL; + tid->reorder[i].skb = NULL; + tid->reorder[i].timestamp = 0; + tid->nframes--; dev_kfree_skb(skb); } diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 6b07b8fafec2..f38da680dc54 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -372,7 +372,10 @@ struct mt76_rx_tid { u8 started:1, stopped:1, timer_pending:1; - struct sk_buff *reorder_buf[]; + struct { + struct sk_buff *skb; + unsigned long timestamp; + } reorder[]; }; #define MT_TX_CB_DMA_DONE BIT(0) @@ -606,8 +609,6 @@ struct mt76_rx_status { u16 wcid_idx; }; - u32 reorder_time; - u32 ampdu_ref; u32 timestamp; -- 2.41.0