From patchwork Fri Apr 10 22:51:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryder Lee X-Patchwork-Id: 11483755 X-Patchwork-Delegate: nbd@nbd.name Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 15FEA1871 for ; Fri, 10 Apr 2020 22:52:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EC5F32084D for ; Fri, 10 Apr 2020 22:52:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="g8UFH0lS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726761AbgDJWwA (ORCPT ); Fri, 10 Apr 2020 18:52:00 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:6727 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726725AbgDJWwA (ORCPT ); Fri, 10 Apr 2020 18:52:00 -0400 X-UUID: 7d87ebb404484069a41fa6220a1fd00e-20200411 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=ufvewpS7ceVAwF6OMVoL1ERRAtr7P1iR2Z4WpCjrR7k=; b=g8UFH0lSDgmam/OqMMVl0GVSRaukms7MmJzGZykkEwyA9AJ8ujm+jMW8ITWoP76PZKJLanp9w2hjBuBeMZFIhoqQWW1dDdluV6+WMM5KGDXwfyoTEjJBY+1tj9NWEK4HkrzxDMLhoHqNI4v3fFiopjtpcJC8vAnt/t2qrv4BCA4=; X-UUID: 7d87ebb404484069a41fa6220a1fd00e-20200411 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0809 with TLS) with ESMTP id 473693947; Sat, 11 Apr 2020 06:51:52 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 11 Apr 2020 06:51:46 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 11 Apr 2020 06:51:46 +0800 From: Ryder Lee To: Felix Fietkau , Lorenzo Bianconi CC: Shayne Chen , YF Luo , Yiwei Chung , Chih-Min Chen , Evelyn Tsai , Sean Wang , , , Ryder Lee Subject: [PATCH v1 08/16] mt76: mt7915: add offloading Tx AMSDU support Date: Sat, 11 Apr 2020 06:51:23 +0800 Message-ID: <668c94040bd2e7ec0fb166b6b2ad548da21b7bd1.1586558901.git.ryder.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: MIME-Version: 1.0 X-TM-SNTS-SMTP: 7FBEB1D4E1DD72381369EE894C11405AD255479EFB6238CFD93947A7A70F9C1D2000:8 X-MTK: N Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Add module parameter to enable hw_tx_amsdu. Signed-off-by: Ryder Lee Signed-off-by: Shayne Chen Tested-by: Chih-Min Chen Tested-by: Evelyn Tsai Suggested-by: Yiwei Chung Suggested-by: YF Luo --- .../net/wireless/mediatek/mt76/mt7915/init.c | 5 ++- .../net/wireless/mediatek/mt76/mt7915/mac.c | 4 ++- .../net/wireless/mediatek/mt76/mt7915/mcu.c | 34 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7915/mcu.h | 20 +++++++++++ .../wireless/mediatek/mt76/mt7915/mt7915.h | 1 + .../net/wireless/mediatek/mt76/mt7915/pci.c | 8 +++++ 6 files changed, 70 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c index 2e10064cccc1..649ba9d55d99 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c @@ -236,7 +236,10 @@ mt7915_init_wiphy(struct ieee80211_hw *hw) ieee80211_hw_set(hw, HAS_RATE_CONTROL); - hw->max_tx_fragments = 4; + if (phy->dev->hw_tx_amsdu) + hw->max_tx_fragments = 1; + else + hw->max_tx_fragments = 4; } static void diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 511a6d2e8dd1..a9efee42dce2 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -525,7 +525,9 @@ void mt7915_mac_write_txwi(struct mt7915_dev *dev, __le32 *txwi, txwi[7] = cpu_to_le32(val); val = FIELD_PREP(MT_TXD3_REM_TX_COUNT, tx_count); - if (ieee80211_is_data_qos(fc)) { + if (dev->hw_tx_amsdu && ieee80211_is_data_qos(fc)) { + txwi[7] |= MT_TXD7_HW_AMSDU; + } else if (ieee80211_is_data_qos(fc)) { seqno = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl)); val |= MT_TXD3_SN_VALID; } else if (ieee80211_is_back_req(fc)) { diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c index 59cd50db2ecf..a6b9d1a95f04 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c @@ -85,6 +85,8 @@ struct mt7915_fw_region { #define to_wcid_lo(id) FIELD_GET(GENMASK(7, 0), (u16)id) #define to_wcid_hi(id) FIELD_GET(GENMASK(9, 8), (u16)id) +#define HW_TX_AMSDU_MAX_NUM 8 + static enum mt7915_cipher_type mt7915_mcu_get_cipher(int cipher) { @@ -786,6 +788,23 @@ mt7915_mcu_bss_ra_tlv(struct sk_buff *skb, struct ieee80211_vif *vif, ra->fast_interval = cpu_to_le32(100); } +static void +mt7915_mcu_bss_hw_amsdu_tlv(struct sk_buff *skb) +{ +#define TXD_CMP_MAP1 GENMASK(15, 0) +#define TXD_CMP_MAP2 (GENMASK(31, 0) & ~BIT(23)) + struct bss_info_hw_amsdu *amsdu; + struct tlv *tlv; + + tlv = mt7915_mcu_add_tlv(skb, BSS_INFO_HW_AMSDU, sizeof(*amsdu)); + + amsdu = (struct bss_info_hw_amsdu *)tlv; + amsdu->cmp_bitmap_0 = cpu_to_le32(TXD_CMP_MAP1); + amsdu->cmp_bitmap_1 = cpu_to_le32(TXD_CMP_MAP2); + amsdu->trig_thres = cpu_to_le16(2); + amsdu->enable = true; +} + static void mt7915_mcu_bss_ext_tlv(struct sk_buff *skb, struct mt7915_vif *mvif) { @@ -861,6 +880,9 @@ int mt7915_mcu_add_bss_info(struct mt7915_phy *phy, mt7915_mcu_bss_bmc_tlv(skb, phy); mt7915_mcu_bss_ra_tlv(skb, vif, phy); + if (phy->dev->hw_tx_amsdu) + mt7915_mcu_bss_hw_amsdu_tlv(skb); + if (mvif->omac_idx > HW_BSSID_MAX) mt7915_mcu_bss_ext_tlv(skb, mvif); else @@ -1145,6 +1167,18 @@ mt7915_mcu_sta_tlv(struct mt7915_dev *dev, struct sk_buff *skb, tlv = mt7915_mcu_add_tlv(skb, STA_REC_HT, sizeof(*ht)); ht = (struct sta_rec_ht *)tlv; ht->ht_cap = cpu_to_le16(sta->ht_cap.cap); + + /* starec hw amsdu */ + if (dev->hw_tx_amsdu) { + struct sta_rec_amsdu *amsdu; + + tlv = mt7915_mcu_add_tlv(skb, STA_REC_HW_AMSDU, + sizeof(*amsdu)); + amsdu = (struct sta_rec_amsdu *)tlv; + amsdu->max_amsdu_num = HW_TX_AMSDU_MAX_NUM; + amsdu->amsdu_en = true; + amsdu->max_mpdu_size = sta->max_amsdu_len; + } } /* starec vht */ diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h index d9c9aab7e6dc..867cab7cf145 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.h @@ -396,6 +396,16 @@ struct bss_info_ra { __le32 fast_interval; } __packed; +struct bss_info_hw_amsdu { + __le16 tag; + __le16 len; + __le32 cmp_bitmap_0; + __le32 cmp_bitmap_1; + __le16 trig_thres; + u8 enable; + u8 rsv; +} __packed; + struct bss_info_bcn { __le16 tag; __le16 len; @@ -659,6 +669,15 @@ struct sta_rec_ba { __le16 winsize; } __packed; +struct sta_rec_amsdu { + __le16 tag; + __le16 len; + u8 max_amsdu_num; + u8 max_mpdu_size; + u8 amsdu_en; + u8 rsv; +} __packed; + struct sec_key { u8 cipher_id; u8 cipher_len; @@ -796,6 +815,7 @@ enum { sizeof(struct sta_rec_ba) + \ sizeof(struct sta_rec_vht) + \ sizeof(struct tlv) + \ + sizeof(struct sta_rec_amsdu) + \ sizeof(struct sta_rec_sec) + \ sizeof(struct sta_rec_ra) + \ MT7915_WTBL_UPDATE_MAX_SIZE) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index b502bcc985ec..7f569a7a0c9b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -167,6 +167,7 @@ struct mt7915_dev { u8 mac_work_count; bool fw_debug; + bool hw_tx_amsdu; }; enum { diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/pci.c b/drivers/net/wireless/mediatek/mt76/mt7915/pci.c index e1bf71b15810..a98e91163971 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/pci.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/pci.c @@ -12,6 +12,10 @@ #include "mac.h" #include "../trace.h" +static bool hw_tx_amsdu; +module_param_named(enable_hw_tx_amsdu, hw_tx_amsdu, bool, 0644); +MODULE_PARM_DESC(enable_hw_tx_amsdu, "enable Hardware Tx AMSDU"); + static const struct pci_device_id mt7915_pci_device_table[] = { { PCI_DEVICE(0x14c3, 0x7915) }, { }, @@ -150,6 +154,10 @@ static int mt7915_pci_probe(struct pci_dev *pdev, (mt7915_l1_rr(dev, MT_HW_REV) & 0xff); dev_dbg(mdev->dev, "ASIC revision: %04x\n", mdev->rev); + /* TODO: more hw capabilities */ + if (hw_tx_amsdu) + dev->hw_tx_amsdu = true; + /* master switch of PCIe tnterrupt enable */ mt7915_l1_wr(dev, MT_PCIE_MAC_INT_ENABLE, 0xff);