mt76: connac: move mt76_connac_mcu_set_pm in connac module
authorLorenzo Bianconi <lorenzo@kernel.org>
Fri, 24 Dec 2021 10:58:03 +0000 (11:58 +0100)
committerFelix Fietkau <nbd@nbd.name>
Thu, 3 Feb 2022 12:57:58 +0000 (13:57 +0100)
Move mt76_connac_mcu_set_pm utility routine in connac module since it is
shared between mt7615 and mt7915 drivers.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
drivers/net/wireless/mediatek/mt76/mt7915/main.c
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h

index 31f40e5..3b94e4f 100644 (file)
@@ -756,32 +756,7 @@ out:
 static int
 mt7615_mcu_ctrl_pm_state(struct mt7615_dev *dev, int band, int state)
 {
-#define ENTER_PM_STATE 1
-#define EXIT_PM_STATE  2
-       struct {
-               u8 pm_number;
-               u8 pm_state;
-               u8 bssid[ETH_ALEN];
-               u8 dtim_period;
-               u8 wlan_idx;
-               __le16 bcn_interval;
-               __le32 aid;
-               __le32 rx_filter;
-               u8 band_idx;
-               u8 rsv[3];
-               __le32 feature;
-               u8 omac_idx;
-               u8 wmm_idx;
-               u8 bcn_loss_cnt;
-               u8 bcn_sp_duration;
-       } __packed req = {
-               .pm_number = 5,
-               .pm_state = state ? ENTER_PM_STATE : EXIT_PM_STATE,
-               .band_idx = band,
-       };
-
-       return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(PM_STATE_CTRL),
-                                &req, sizeof(req), true);
+       return mt76_connac_mcu_set_pm(&dev->mt76, band, state);
 }
 
 static int
index 1420174..6b71492 100644 (file)
@@ -2718,5 +2718,37 @@ int mt76_connac_mcu_bss_basic_tlv(struct sk_buff *skb,
 }
 EXPORT_SYMBOL_GPL(mt76_connac_mcu_bss_basic_tlv);
 
+#define ENTER_PM_STATE         1
+#define EXIT_PM_STATE          2
+int mt76_connac_mcu_set_pm(struct mt76_dev *dev, int band, int enter)
+{
+       struct {
+               u8 pm_number;
+               u8 pm_state;
+               u8 bssid[ETH_ALEN];
+               u8 dtim_period;
+               u8 wlan_idx_lo;
+               __le16 bcn_interval;
+               __le32 aid;
+               __le32 rx_filter;
+               u8 band_idx;
+               u8 wlan_idx_hi;
+               u8 rsv[2];
+               __le32 feature;
+               u8 omac_idx;
+               u8 wmm_idx;
+               u8 bcn_loss_cnt;
+               u8 bcn_sp_duration;
+       } __packed req = {
+               .pm_number = 5,
+               .pm_state = enter ? ENTER_PM_STATE : EXIT_PM_STATE,
+               .band_idx = band,
+       };
+
+       return mt76_mcu_send_msg(dev, MCU_EXT_CMD(PM_STATE_CTRL), &req,
+                                sizeof(req), true);
+}
+EXPORT_SYMBOL_GPL(mt76_connac_mcu_set_pm);
+
 MODULE_AUTHOR("Lorenzo Bianconi <lorenzo@kernel.org>");
 MODULE_LICENSE("Dual BSD/GPL");
index 0908d30..285c652 100644 (file)
@@ -1609,4 +1609,5 @@ void mt76_connac_mcu_sta_uapsd(struct sk_buff *skb, struct ieee80211_vif *vif,
 void mt76_connac_mcu_wtbl_smps_tlv(struct sk_buff *skb,
                                   struct ieee80211_sta *sta,
                                   void *sta_wtbl, void *wtbl_tlv);
+int mt76_connac_mcu_set_pm(struct mt76_dev *dev, int band, int enter);
 #endif /* __MT76_CONNAC_MCU_H */
index a6553a8..228bbc6 100644 (file)
@@ -34,7 +34,7 @@ static int mt7915_start(struct ieee80211_hw *hw)
        running = mt7915_dev_running(dev);
 
        if (!running) {
-               ret = mt7915_mcu_set_pm(dev, 0, 0);
+               ret = mt76_connac_mcu_set_pm(&dev->mt76, 0, 0);
                if (ret)
                        goto out;
 
@@ -50,7 +50,7 @@ static int mt7915_start(struct ieee80211_hw *hw)
        }
 
        if (phy != &dev->phy) {
-               ret = mt7915_mcu_set_pm(dev, 1, 0);
+               ret = mt76_connac_mcu_set_pm(&dev->mt76, 1, 0);
                if (ret)
                        goto out;
 
@@ -106,12 +106,12 @@ static void mt7915_stop(struct ieee80211_hw *hw)
        clear_bit(MT76_STATE_RUNNING, &phy->mt76->state);
 
        if (phy != &dev->phy) {
-               mt7915_mcu_set_pm(dev, 1, 1);
+               mt76_connac_mcu_set_pm(&dev->mt76, 1, 1);
                mt7915_mcu_set_mac(dev, 1, false, false);
        }
 
        if (!mt7915_dev_running(dev)) {
-               mt7915_mcu_set_pm(dev, 0, 1);
+               mt76_connac_mcu_set_pm(&dev->mt76, 0, 1);
                mt7915_mcu_set_mac(dev, 0, false, false);
        }
 
index 0645838..b864042 100644 (file)
@@ -2651,37 +2651,6 @@ int mt7915_mcu_set_tx(struct mt7915_dev *dev, struct ieee80211_vif *vif)
        return mt7915_mcu_update_edca(dev, &req);
 }
 
-int mt7915_mcu_set_pm(struct mt7915_dev *dev, int band, int enter)
-{
-#define ENTER_PM_STATE         1
-#define EXIT_PM_STATE          2
-       struct {
-               u8 pm_number;
-               u8 pm_state;
-               u8 bssid[ETH_ALEN];
-               u8 dtim_period;
-               u8 wlan_idx_lo;
-               __le16 bcn_interval;
-               __le32 aid;
-               __le32 rx_filter;
-               u8 band_idx;
-               u8 wlan_idx_hi;
-               u8 rsv[2];
-               __le32 feature;
-               u8 omac_idx;
-               u8 wmm_idx;
-               u8 bcn_loss_cnt;
-               u8 bcn_sp_duration;
-       } __packed req = {
-               .pm_number = 5,
-               .pm_state = (enter) ? ENTER_PM_STATE : EXIT_PM_STATE,
-               .band_idx = band,
-       };
-
-       return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(PM_STATE_CTRL), &req,
-                                sizeof(req), true);
-}
-
 int mt7915_mcu_rdd_cmd(struct mt7915_dev *dev,
                       enum mt7915_rdd_cmd cmd, u8 index,
                       u8 rx_sel, u8 val)
index 3be14a6..9fb2810 100644 (file)
@@ -441,7 +441,6 @@ int mt7915_mcu_set_test_param(struct mt7915_dev *dev, u8 param, bool test_mode,
 int mt7915_mcu_set_scs(struct mt7915_dev *dev, u8 band, bool enable);
 int mt7915_mcu_set_ser(struct mt7915_dev *dev, u8 action, u8 set, u8 band);
 int mt7915_mcu_set_rts_thresh(struct mt7915_phy *phy, u32 val);
-int mt7915_mcu_set_pm(struct mt7915_dev *dev, int band, int enter);
 int mt7915_mcu_set_sku_en(struct mt7915_phy *phy, bool enable);
 int mt7915_mcu_set_txpower_sku(struct mt7915_phy *phy);
 int mt7915_mcu_get_txpower_sku(struct mt7915_phy *phy, s8 *txpower, int len);