]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mt76: move chainmask in mt76_phy
authorLorenzo Bianconi <lorenzo@kernel.org>
Mon, 4 Jan 2021 18:00:06 +0000 (02:00 +0800)
committerFelix Fietkau <nbd@nbd.name>
Tue, 26 Jan 2021 19:07:48 +0000 (20:07 +0100)
Move chainmask from driver phy to mt76_phy since it is used by all
drivers. This is a preliminary patch to create a common mcu library used
by mt7615 and mt7921 drivers

Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
21 files changed:
drivers/net/wireless/mediatek/mt76/mt76.h
drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c
drivers/net/wireless/mediatek/mt76/mt7615/init.c
drivers/net/wireless/mediatek/mt76/mt7615/mac.c
drivers/net/wireless/mediatek/mt76/mt7615/main.c
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
drivers/net/wireless/mediatek/mt76/mt7615/testmode.c
drivers/net/wireless/mediatek/mt76/mt76x02.h
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c
drivers/net/wireless/mediatek/mt76/mt76x02_phy.c
drivers/net/wireless/mediatek/mt76/mt76x02_util.c
drivers/net/wireless/mediatek/mt76/mt76x2/mcu.c
drivers/net/wireless/mediatek/mt76/mt76x2/pci_main.c
drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c
drivers/net/wireless/mediatek/mt76/mt7915/init.c
drivers/net/wireless/mediatek/mt76/mt7915/mac.c
drivers/net/wireless/mediatek/mt76/mt7915/main.c
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
drivers/net/wireless/mediatek/mt76/mt7915/testmode.c

index 52228936f79295a1e5cc6d4257e197cc4fd13082..1925e7fbc1b16467c5ff38ccdb6f981c81920901 100644 (file)
@@ -579,6 +579,7 @@ struct mt76_phy {
 
        int txpower_cur;
        u8 antenna_mask;
+       u16 chainmask;
 
 #ifdef CONFIG_NL80211_TESTMODE
        struct mt76_testmode_data test;
index 3232ebd5eda69113a204ea6619fa30e150ff416a..2eab23898c77850795bedb72d6a6bcac52193175 100644 (file)
@@ -161,7 +161,7 @@ static void mt7615_eeprom_parse_hw_cap(struct mt7615_dev *dev)
 
        dev->chainmask = BIT(tx_mask) - 1;
        dev->mphy.antenna_mask = dev->chainmask;
-       dev->phy.chainmask = dev->chainmask;
+       dev->mphy.chainmask = dev->chainmask;
 }
 
 static int mt7663_eeprom_get_target_power_index(struct mt7615_dev *dev,
index d89b607cce68a8496101089eee66e57eeaab363e..8151c1d6072850ec1176a3ff3d38569e76c59818 100644 (file)
@@ -362,9 +362,9 @@ mt7615_cap_dbdc_enable(struct mt7615_dev *dev)
                dev->mphy.antenna_mask = dev->chainmask >> 2;
        else
                dev->mphy.antenna_mask = dev->chainmask >> 1;
-       dev->phy.chainmask = dev->mphy.antenna_mask;
-       dev->mphy.hw->wiphy->available_antennas_rx = dev->phy.chainmask;
-       dev->mphy.hw->wiphy->available_antennas_tx = dev->phy.chainmask;
+       dev->mphy.chainmask = dev->mphy.antenna_mask;
+       dev->mphy.hw->wiphy->available_antennas_rx = dev->mphy.chainmask;
+       dev->mphy.hw->wiphy->available_antennas_tx = dev->mphy.chainmask;
        mt76_set_stream_caps(&dev->mphy, true);
 }
 
@@ -375,7 +375,7 @@ mt7615_cap_dbdc_disable(struct mt7615_dev *dev)
                        IEEE80211_VHT_CAP_SHORT_GI_160 |
                        IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
        dev->mphy.antenna_mask = dev->chainmask;
-       dev->phy.chainmask = dev->chainmask;
+       dev->mphy.chainmask = dev->chainmask;
        dev->mphy.hw->wiphy->available_antennas_rx = dev->chainmask;
        dev->mphy.hw->wiphy->available_antennas_tx = dev->chainmask;
        mt76_set_stream_caps(&dev->mphy, true);
@@ -404,8 +404,8 @@ int mt7615_register_ext_phy(struct mt7615_dev *dev)
        phy = mphy->priv;
        phy->dev = dev;
        phy->mt76 = mphy;
-       phy->chainmask = dev->chainmask & ~dev->phy.chainmask;
-       mphy->antenna_mask = BIT(hweight8(phy->chainmask)) - 1;
+       mphy->chainmask = dev->chainmask & ~dev->mphy.chainmask;
+       mphy->antenna_mask = BIT(hweight8(mphy->chainmask)) - 1;
        mt7615_init_wiphy(mphy->hw);
 
        INIT_DELAYED_WORK(&mphy->mac_work, mt7615_mac_work);
index 2cc329019edcf9c4e5782d9f0fef8a8227c147c7..26909fdbb0a5a68745d9f1fb28484749297c3a3a 100644 (file)
@@ -326,7 +326,7 @@ static int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb)
                 * that PHY.
                 */
                if (phy_idx < 0) {
-                       int first_chain = ffs(phy2->chainmask) - 1;
+                       int first_chain = ffs(phy2->mt76->chainmask) - 1;
 
                        phy_idx = ((rxdg5 >> (first_chain * 8)) & 0xff) == 0;
                }
index a7155509f95ac74d8a844694f241ee58382a17cd..5134d051dc2f7a093656c8aa51e54fcd44de926d 100644 (file)
@@ -911,7 +911,7 @@ mt7615_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
                else
                        tx_ant <<= 1;
        }
-       phy->chainmask = tx_ant;
+       phy->mt76->chainmask = tx_ant;
 
        mt76_set_stream_caps(phy->mt76, true);
 
index f192eb95e7d6237efff6da508a68772df4eb1c17..c1cd7d5b354b65e8b7db46971334122ed7130bf7 100644 (file)
@@ -1662,7 +1662,7 @@ mt7615_mcu_uni_add_bss(struct mt7615_phy *phy, struct ieee80211_vif *vif,
                        .center_chan = ieee80211_frequency_to_channel(freq1),
                        .center_chan2 = ieee80211_frequency_to_channel(freq2),
                        .tx_streams = hweight8(phy->mt76->antenna_mask),
-                       .rx_streams = phy->chainmask,
+                       .rx_streams = phy->mt76->chainmask,
                        .short_st = true,
                },
        };
@@ -2880,7 +2880,7 @@ int mt7615_mcu_set_chan_info(struct mt7615_phy *phy, int cmd)
                .control_chan = chandef->chan->hw_value,
                .center_chan = ieee80211_frequency_to_channel(freq1),
                .tx_streams = hweight8(phy->mt76->antenna_mask),
-               .rx_streams_mask = phy->chainmask,
+               .rx_streams_mask = phy->mt76->chainmask,
                .center_chan2 = ieee80211_frequency_to_channel(freq2),
        };
 
index 99365807142e39ef778bc33316f1ce5d131af605..a773ea4d5b120419730e7d464f8a1cc02cacb338 100644 (file)
@@ -171,8 +171,6 @@ struct mt7615_phy {
        s8 ofdm_sensitivity;
        s8 cck_sensitivity;
 
-       u16 chainmask;
-
        s16 coverage_class;
        u8 slottime;
 
index b82915445d0db89eaa1ccbe5e483000723d7ee0a..a0542a309e27d89f013f528f8393e59cccbb161b 100644 (file)
@@ -178,7 +178,7 @@ mt7615_tm_set_tx_antenna(struct mt7615_phy *phy, bool en)
                return;
 
        if (!en)
-               mask = phy->chainmask;
+               mask = phy->mt76->chainmask;
 
        for (i = 0; i < 4; i++) {
                mt76_rmw_field(dev, MT_WF_PHY_RFINTF3_0(i),
@@ -306,7 +306,7 @@ mt7615_tm_set_params(struct mt76_phy *mphy, struct nlattr **tb,
            td->state == MT76_TM_STATE_OFF)
                return 0;
 
-       if (td->tx_antenna_mask & ~phy->chainmask)
+       if (td->tx_antenna_mask & ~mphy->chainmask)
                return -EINVAL;
 
        for (i = 0; i < ARRAY_SIZE(tm_change_map); i++) {
index d626817a21038ba299f7d5f44e6eb2ee9f1959e0..4d58c2c1c0ac122e4cdd89eb03262b84dee4a33a 100644 (file)
@@ -82,8 +82,6 @@ struct mt76x02_dev {
 
        struct mutex phy_mutex;
 
-       u16 chainmask;
-
        u8 txdone_seq;
        DECLARE_KFIFO_PTR(txstatus_fifo, struct mt76x02_tx_status);
        spinlock_t txstatus_fifo_lock;
index e0c4e1981e5bf294a3cc87a4251a13bc9ec3ec7a..771bad60e1bc74248138ec1df3be56fe12c80664 100644 (file)
@@ -345,7 +345,7 @@ void mt76x02_mac_write_txwi(struct mt76x02_dev *dev, struct mt76x02_txwi *txwi,
        u16 txwi_flags = 0;
        u8 nss;
        s8 txpwr_adj, max_txpwr_adj;
-       u8 ccmp_pn[8], nstreams = dev->chainmask & 0xf;
+       u8 ccmp_pn[8], nstreams = dev->mphy.chainmask & 0xf;
 
        memset(txwi, 0, sizeof(*txwi));
 
@@ -685,7 +685,7 @@ mt76x02_mac_process_rate(struct mt76x02_dev *dev,
                status->rate_idx = idx;
                break;
        case MT_PHY_TYPE_VHT: {
-               u8 n_rxstream = dev->chainmask & 0xf;
+               u8 n_rxstream = dev->mphy.chainmask & 0xf;
 
                status->encoding = RX_ENC_VHT;
                status->rate_idx = FIELD_GET(MT_RATE_INDEX_VHT_IDX, idx);
@@ -777,7 +777,7 @@ int mt76x02_mac_process_rx(struct mt76x02_dev *dev, struct sk_buff *skb,
        u16 rate = le16_to_cpu(rxwi->rate);
        u16 tid_sn = le16_to_cpu(rxwi->tid_sn);
        bool unicast = rxwi->rxinfo & cpu_to_le32(MT_RXINFO_UNICAST);
-       int pad_len = 0, nstreams = dev->chainmask & 0xf;
+       int pad_len = 0, nstreams = dev->mphy.chainmask & 0xf;
        s8 signal;
        u8 pn_len;
        u8 wcid;
index aaadc15ea83cc38a2880a4851cca8b7b6c60b3ea..2e53b0c1afdd983308b288dface89bdfa4b18421 100644 (file)
@@ -16,7 +16,7 @@ void mt76x02_phy_set_rxpath(struct mt76x02_dev *dev)
        val = mt76_rr(dev, MT_BBP(AGC, 0));
        val &= ~BIT(4);
 
-       switch (dev->chainmask & 0xf) {
+       switch (dev->mphy.chainmask & 0xf) {
        case 2:
                val |= BIT(3);
                break;
@@ -35,7 +35,7 @@ void mt76x02_phy_set_txdac(struct mt76x02_dev *dev)
 {
        int txpath;
 
-       txpath = (dev->chainmask >> 8) & 0xf;
+       txpath = (dev->mphy.chainmask >> 8) & 0xf;
        switch (txpath) {
        case 2:
                mt76_set(dev, MT_BBP(TXBE, 5), 0x3);
index db7bd35d425ce69c13ad328ba786a5b6e862dee6..1852b6c9add6b3c23d2a2cf929d4d5716eb46cae 100644 (file)
@@ -197,10 +197,10 @@ void mt76x02_init_device(struct mt76x02_dev *dev)
                                IEEE80211_HT_CAP_LDPC_CODING;
                dev->mphy.sband_5g.sband.ht_cap.cap |=
                                IEEE80211_HT_CAP_LDPC_CODING;
-               dev->chainmask = 0x202;
+               dev->mphy.chainmask = 0x202;
                dev->mphy.antenna_mask = 3;
        } else {
-               dev->chainmask = 0x101;
+               dev->mphy.chainmask = 0x101;
                dev->mphy.antenna_mask = 1;
        }
 }
index 3c2738903d7db535c6494c7f5a8c806f2e21018a..ac83ce5f3e8b6c7e06c8ba2b8611bea226f4b550 100644 (file)
@@ -29,7 +29,7 @@ int mt76x2_mcu_set_channel(struct mt76x02_dev *dev, u8 channel, u8 bw,
                .idx = channel,
                .scan = scan,
                .bw = bw,
-               .chainmask = cpu_to_le16(dev->chainmask),
+               .chainmask = cpu_to_le16(dev->mphy.chainmask),
        };
 
        /* first set the channel without the extension channel info */
index 93fa3f644bb8785cfe01be41f1afe786485c4599..933125b07ea34bebea2e3f76dcc47be38280c04e 100644 (file)
@@ -116,7 +116,7 @@ static int mt76x2_set_antenna(struct ieee80211_hw *hw, u32 tx_ant,
 
        mutex_lock(&dev->mt76.mutex);
 
-       dev->chainmask = (tx_ant == 3) ? 0x202 : 0x101;
+       dev->mphy.chainmask = (tx_ant == 3) ? 0x202 : 0x101;
        dev->mphy.antenna_mask = tx_ant;
 
        mt76_set_stream_caps(&dev->mphy, true);
index 0a3ac07bab4a88358f088f76c1a12d5af7b983f0..7807b9165e01d91c74bc07a082005d0427f32a72 100644 (file)
@@ -89,7 +89,7 @@ static void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev)
 
        dev->chainmask = BIT(nss) - 1;
        dev->mphy.antenna_mask = BIT(tx_mask[0]) - 1;
-       dev->phy.chainmask = dev->mphy.antenna_mask;
+       dev->mphy.chainmask = dev->mphy.antenna_mask;
 }
 
 int mt7915_eeprom_init(struct mt7915_dev *dev)
index 8aa26be936e6bece23e1e8e3d92d4895433b09fd..eed35443e69ce0e28be9a9e20b2015df40d00f25 100644 (file)
@@ -235,8 +235,8 @@ static int mt7915_register_ext_phy(struct mt7915_dev *dev)
        phy = mphy->priv;
        phy->dev = dev;
        phy->mt76 = mphy;
-       phy->chainmask = dev->chainmask & ~dev->phy.chainmask;
-       mphy->antenna_mask = BIT(hweight8(phy->chainmask)) - 1;
+       mphy->chainmask = dev->chainmask & ~dev->mphy.chainmask;
+       mphy->antenna_mask = BIT(hweight8(mphy->chainmask)) - 1;
        mt7915_init_wiphy(mphy->hw);
 
        INIT_LIST_HEAD(&phy->stats_list);
@@ -329,7 +329,7 @@ static int mt7915_init_hardware(struct mt7915_dev *dev)
 
 void mt7915_set_stream_vht_txbf_caps(struct mt7915_phy *phy)
 {
-       int nss = hweight8(phy->chainmask);
+       int nss = hweight8(phy->mt76->chainmask);
        u32 *cap = &phy->mt76->sband_5g.sband.vht_cap.cap;
 
        *cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE |
@@ -440,8 +440,7 @@ static int
 mt7915_init_he_caps(struct mt7915_phy *phy, enum nl80211_band band,
                    struct ieee80211_sband_iftype_data *data)
 {
-       int i, idx = 0;
-       int nss = hweight8(phy->chainmask);
+       int i, idx = 0, nss = hweight8(phy->mt76->chainmask);
        u16 mcs_map = 0;
 
        for (i = 0; i < 8; i++) {
@@ -648,8 +647,8 @@ int mt7915_register_device(struct mt7915_dev *dev)
                dev->mphy.sband_5g.sband.vht_cap.cap |=
                        IEEE80211_VHT_CAP_SHORT_GI_160 |
                        IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
-       dev->mphy.hw->wiphy->available_antennas_rx = dev->phy.chainmask;
-       dev->mphy.hw->wiphy->available_antennas_tx = dev->phy.chainmask;
+       dev->mphy.hw->wiphy->available_antennas_rx = dev->mphy.chainmask;
+       dev->mphy.hw->wiphy->available_antennas_tx = dev->mphy.chainmask;
 
        mt76_set_stream_caps(&dev->mphy, true);
        mt7915_set_stream_vht_txbf_caps(&dev->phy);
index cdc4b3ed5259056444ebf8c7a61bf13e9812770d..261bb1890a4c8a620ed4b9caffede479bef28136 100644 (file)
@@ -1362,7 +1362,7 @@ mt7915_phy_get_nf(struct mt7915_phy *phy, int idx)
        u32 val, sum = 0, n = 0;
        int nss, i;
 
-       for (nss = 0; nss < hweight8(phy->chainmask); nss++) {
+       for (nss = 0; nss < hweight8(phy->mt76->chainmask); nss++) {
                u32 reg = MT_WF_IRPI(nss + (idx << dev->dbdc_support));
 
                for (i = 0; i < ARRAY_SIZE(nf_power); i++, reg += 4) {
index 60a0fc9ec3c7b74a7940b61cd38d3c2db8fda963..24d912cb112d8c2c1c6c416f47209e5dfa177c2b 100644 (file)
@@ -812,7 +812,7 @@ mt7915_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
                else
                        tx_ant <<= 1;
        }
-       phy->chainmask = tx_ant;
+       phy->mt76->chainmask = tx_ant;
 
        mt76_set_stream_caps(phy->mt76, true);
        mt7915_set_stream_vht_txbf_caps(phy);
index 636873cb991e660771d0594b338c56585714d7bf..f4cb46cf4ed4527ff8a420e5669567a7f1cb768a 100644 (file)
@@ -834,9 +834,9 @@ static void
 mt7915_mcu_bss_ra_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
                      struct mt7915_phy *phy)
 {
+       int max_nss = hweight8(phy->mt76->chainmask);
        struct bss_info_ra *ra;
        struct tlv *tlv;
-       int max_nss = hweight8(phy->chainmask);
 
        tlv = mt7915_mcu_add_tlv(skb, BSS_INFO_RA, sizeof(*ra));
 
@@ -1771,7 +1771,7 @@ mt7915_mcu_sta_bfer_vht(struct ieee80211_sta *sta, struct mt7915_phy *phy,
 {
        struct ieee80211_sta_vht_cap *pc = &sta->vht_cap;
        struct ieee80211_sta_vht_cap *vc = &phy->mt76->sband_5g.sband.vht_cap;
-       u8 bfee_nr, bfer_nr, n, tx_ant = hweight8(phy->chainmask) - 1;
+       u8 bfee_nr, bfer_nr, n, tx_ant = hweight8(phy->mt76->chainmask) - 1;
        u16 mcs_map;
 
        bf->tx_mode = MT_PHY_TYPE_VHT;
@@ -1868,9 +1868,9 @@ mt7915_mcu_sta_bfer_tlv(struct sk_buff *skb, struct ieee80211_sta *sta,
                        struct ieee80211_vif *vif, struct mt7915_phy *phy,
                        bool enable)
 {
+       int tx_ant = hweight8(phy->mt76->chainmask) - 1;
        struct sta_rec_bf *bf;
        struct tlv *tlv;
-       int tx_ant = hweight8(phy->chainmask) - 1;
        const u8 matrix[4][4] = {
                {0, 0, 0, 0},
                {1, 1, 0, 0},   /* 2x1, 2x2, 2x3, 2x4 */
@@ -1923,9 +1923,9 @@ static void
 mt7915_mcu_sta_bfee_tlv(struct sk_buff *skb, struct ieee80211_sta *sta,
                        struct mt7915_phy *phy)
 {
+       int tx_ant = hweight8(phy->mt76->chainmask) - 1;
        struct sta_rec_bfee *bfee;
        struct tlv *tlv;
-       int tx_ant = hweight8(phy->chainmask) - 1;
        u8 nr = 0;
 
        tlv = mt7915_mcu_add_tlv(skb, STA_REC_BFEE, sizeof(*bfee));
index a3cdaecef4cef7ca01242cbde40597a292d4ef53..970c397734bd1fe997cc91bc9fcb2b1b09a9235a 100644 (file)
@@ -126,7 +126,6 @@ struct mt7915_phy {
        u64 omac_mask;
 
        u16 noise;
-       u16 chainmask;
 
        s16 coverage_class;
        u8 slottime;
index b58c91ea3fa5f722917a3c57edb71d72f99af377..06353de2e7621440e10f557cfdd93d1100c50559 100644 (file)
@@ -316,7 +316,7 @@ mt7915_tm_set_params(struct mt76_phy *mphy, struct nlattr **tb,
            td->state == MT76_TM_STATE_OFF)
                return 0;
 
-       if (td->tx_antenna_mask & ~phy->chainmask)
+       if (td->tx_antenna_mask & ~mphy->chainmask)
                return -EINVAL;
 
        for (i = 0; i < ARRAY_SIZE(tm_change_map); i++) {