Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2480629ybt; Tue, 16 Jun 2020 07:14:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuVAPQ6iJ1xFS61uARET6pCy7QPNtocPNvyEpwvDA5KTl71Hd682C9V+SDW0V6qQSb7iFe X-Received: by 2002:a05:6402:148f:: with SMTP id e15mr2868102edv.368.1592316856547; Tue, 16 Jun 2020 07:14:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592316856; cv=none; d=google.com; s=arc-20160816; b=JGoHyWBFqypb7fEHRXV8U5jAFPBlaylV2x9HrpEMdNCg2NfwPdTF0I0RKdPIJlpN4y ybjiuDi5g3U3oCobDkk21A4Pnj+xK1OOAmwfo1CdMKj5Jb54N2M93vAVZZDH5dbzgUdD Maw6oa55BmPIhYWZIjnLUdDnOYFby40cHfGYFdS2v/VV36CNp5+0v7Um22924QGsG3Z7 QCTS1RT8MRK2k2c4kZLHVFl8yxh4l4BwoJ1xYK35xxfITpEHWYGqy+4jOGcNQzdDvoPC wkQXD7AQpst0rwExdWGnXa/OD8Xu+pvkJJwjAI75cxqxLvEha/yJ1ySzRAzStEWID+Cm Wx+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:to:from; bh=W+UiuLOGmSCJWMFRcL0z7eGsFUzLEsxK7SUHqabL/1M=; b=pbOiKOEM3nnWO/rhMgnFs6whG8W4y55fXt5oGA6H4JJk8G3SY3gWsa2jK4c7vIxbQG NGH0504+YEl0R4MCjxTxYtPjr3vY7URPOCV49mZF81IyoJfWyPK1X9L7M15fnxygTFiT FMIxdK7h08Od2Nk+T7Iz6W7x2IvyvsOkVlg/3UjY5SdpQ4lghUHNZfdiZvD+uacnwaop D+BOxOWREWXIlBeA9pdfwq/k2DAhcK09QALPHAjSGfWik7lID9TF5K0uldfnjvnB2W3u 2bI/qGIcn8id7mo/UZj5pzGHXLu+3uhDMeNc7GgGHaoJWDLROXKogum6nicXBjEwY1Xz ibTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gf16si10878485ejb.490.2020.06.16.07.13.49; Tue, 16 Jun 2020 07:14:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729648AbgFPOK6 (ORCPT + 99 others); Tue, 16 Jun 2020 10:10:58 -0400 Received: from p54ae948c.dip0.t-ipconnect.de ([84.174.148.140]:49551 "EHLO maeck.local" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729003AbgFPOK5 (ORCPT ); Tue, 16 Jun 2020 10:10:57 -0400 X-Greylist: delayed 1021 seconds by postgrey-1.27 at vger.kernel.org; Tue, 16 Jun 2020 10:10:57 EDT Received: by maeck.local (Postfix, from userid 501) id 433CD8E33D0B; Tue, 16 Jun 2020 11:40:55 +0200 (CEST) From: Felix Fietkau To: linux-wireless@vger.kernel.org Subject: [PATCH v2] mt76: mt7615: re-enable offloading of sequence number assignment Date: Tue, 16 Jun 2020 11:40:55 +0200 Message-Id: <20200616094055.4070-1-nbd@nbd.name> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Preparation for supporting more offload features Signed-off-by: Felix Fietkau --- v2: fix WTBL address offset .../net/wireless/mediatek/mt76/mt7615/mac.c | 44 +++++++++++++++---- .../net/wireless/mediatek/mt76/mt7615/main.c | 5 +++ .../wireless/mediatek/mt76/mt7615/mt7615.h | 1 + 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c index d97315ec7265..d150fac50c00 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c @@ -617,16 +617,19 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi, } val = FIELD_PREP(MT_TXD3_REM_TX_COUNT, tx_count); - if (ieee80211_is_data_qos(hdr->frame_control)) { - seqno = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)); - val |= MT_TXD3_SN_VALID; - } else if (ieee80211_is_back_req(hdr->frame_control)) { - struct ieee80211_bar *bar = (struct ieee80211_bar *)skb->data; - - seqno = IEEE80211_SEQ_TO_SN(le16_to_cpu(bar->start_seq_num)); - val |= MT_TXD3_SN_VALID; + if (info->flags & IEEE80211_TX_CTL_INJECTED) { + seqno = le16_to_cpu(hdr->seq_ctrl); + + if (ieee80211_is_back_req(hdr->frame_control)) { + struct ieee80211_bar *bar; + + bar = (struct ieee80211_bar *)skb->data; + seqno = le16_to_cpu(bar->start_seq_num); + } + + val |= MT_TXD3_SN_VALID | + FIELD_PREP(MT_TXD3_SEQ, IEEE80211_SEQ_TO_SN(seqno)); } - val |= FIELD_PREP(MT_TXD3_SEQ, seqno); txwi[3] |= cpu_to_le32(val); @@ -893,6 +896,29 @@ mt7615_mac_queue_rate_update(struct mt7615_phy *phy, struct mt7615_sta *sta, return 0; } +u32 mt7615_mac_get_sta_tid_sn(struct mt7615_dev *dev, int wcid, u8 tid) +{ + u32 addr, val, val2; + u8 offset; + + addr = mt7615_mac_wtbl_addr(dev, wcid) + 11 * 4; + + offset = tid * 12; + addr += 4 * (offset / 32); + offset %= 32; + + val = mt76_rr(dev, addr); + val >>= (tid % 32); + + if (offset > 20) { + addr += 4; + val2 = mt76_rr(dev, addr); + val |= val2 << (32 - offset); + } + + return val & GENMASK(11, 0); +} + void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta, struct ieee80211_tx_rate *probe_rate, struct ieee80211_tx_rate *rates) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/main.c b/drivers/net/wireless/mediatek/mt76/mt7615/main.c index beaca8127680..dfebf86b86d6 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/main.c @@ -660,6 +660,9 @@ mt7615_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, mtxq->aggr = true; mtxq->send_bar = false; mt7615_mcu_add_tx_ba(dev, params, true); + ssn = mt7615_mac_get_sta_tid_sn(dev, msta->wcid.idx, tid); + ieee80211_send_bar(vif, sta->addr, tid, + IEEE80211_SN_TO_SEQ(ssn)); break; case IEEE80211_AMPDU_TX_STOP_FLUSH: case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: @@ -667,6 +670,8 @@ mt7615_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, mt7615_mcu_add_tx_ba(dev, params, false); break; case IEEE80211_AMPDU_TX_START: + ssn = mt7615_mac_get_sta_tid_sn(dev, msta->wcid.idx, tid); + params->ssn = ssn; mtxq->agg_ssn = IEEE80211_SN_TO_SEQ(ssn); ret = IEEE80211_AMPDU_TX_START_IMMEDIATE; break; diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h index 3e7d51bf42a4..640ff8b9b266 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h @@ -516,6 +516,7 @@ int mt7615_mac_wtbl_update_key(struct mt7615_dev *dev, enum mt7615_cipher_type cipher, enum set_key_cmd cmd); void mt7615_mac_reset_work(struct work_struct *work); +u32 mt7615_mac_get_sta_tid_sn(struct mt7615_dev *dev, int wcid, u8 tid); int mt7615_mcu_wait_response(struct mt7615_dev *dev, int cmd, int seq); int mt7615_mcu_msg_send(struct mt76_dev *mdev, int cmd, const void *data, -- 2.24.0