1 /* SPDX-License-Identifier: ISC */
2 /* Copyright (C) 2019 MediaTek Inc. */
7 #include <linux/interrupt.h>
8 #include <linux/ktime.h>
12 #define MT7615_MAX_INTERFACES 4
13 #define MT7615_WTBL_SIZE 128
14 #define MT7615_WTBL_RESERVED (MT7615_WTBL_SIZE - 1)
15 #define MT7615_WTBL_STA (MT7615_WTBL_RESERVED - \
16 MT7615_MAX_INTERFACES)
18 #define MT7615_WATCHDOG_TIME 100 /* ms */
19 #define MT7615_RATE_RETRY 2
21 #define MT7615_TX_RING_SIZE 1024
22 #define MT7615_TX_MCU_RING_SIZE 128
23 #define MT7615_TX_FWDL_RING_SIZE 128
25 #define MT7615_RX_RING_SIZE 1024
26 #define MT7615_RX_MCU_RING_SIZE 512
28 #define MT7615_FIRMWARE_CR4 "mt7615_cr4.bin"
29 #define MT7615_FIRMWARE_N9 "mt7615_n9.bin"
30 #define MT7615_ROM_PATCH "mt7615_rom_patch.bin"
32 #define MT7615_EEPROM_SIZE 1024
33 #define MT7615_TOKEN_SIZE 4096
38 enum mt7615_hw_txq_id {
46 struct mt76_wcid wcid; /* must be first */
48 struct mt7615_vif *vif;
50 struct ieee80211_tx_rate rates[8];
63 struct mt7615_sta sta;
67 struct mt76_dev mt76; /* must be first */
71 spinlock_t token_lock;
81 EXT_BSSID_START = 0x10,
100 extern const struct ieee80211_ops mt7615_ops;
101 extern struct pci_driver mt7615_pci_driver;
103 u32 mt7615_reg_map(struct mt7615_dev *dev, u32 addr);
105 int mt7615_register_device(struct mt7615_dev *dev);
106 void mt7615_unregister_device(struct mt7615_dev *dev);
107 int mt7615_eeprom_init(struct mt7615_dev *dev);
108 int mt7615_eeprom_get_power_index(struct mt7615_dev *dev,
109 struct ieee80211_channel *chan,
111 int mt7615_dma_init(struct mt7615_dev *dev);
112 void mt7615_dma_cleanup(struct mt7615_dev *dev);
113 int mt7615_mcu_init(struct mt7615_dev *dev);
114 int mt7615_mcu_set_dev_info(struct mt7615_dev *dev,
115 struct ieee80211_vif *vif, bool enable);
116 int mt7615_mcu_set_bss_info(struct mt7615_dev *dev, struct ieee80211_vif *vif,
118 int mt7615_mcu_set_wtbl_key(struct mt7615_dev *dev, int wcid,
119 struct ieee80211_key_conf *key,
120 enum set_key_cmd cmd);
121 void mt7615_mcu_set_rates(struct mt7615_dev *dev, struct mt7615_sta *sta,
122 struct ieee80211_tx_rate *probe_rate,
123 struct ieee80211_tx_rate *rates);
124 int mt7615_mcu_wtbl_bmc(struct mt7615_dev *dev, struct ieee80211_vif *vif,
126 int mt7615_mcu_add_wtbl(struct mt7615_dev *dev, struct ieee80211_vif *vif,
127 struct ieee80211_sta *sta);
128 int mt7615_mcu_del_wtbl(struct mt7615_dev *dev, struct ieee80211_sta *sta);
129 int mt7615_mcu_del_wtbl_all(struct mt7615_dev *dev);
130 int mt7615_mcu_set_sta_rec_bmc(struct mt7615_dev *dev,
131 struct ieee80211_vif *vif, bool en);
132 int mt7615_mcu_set_sta_rec(struct mt7615_dev *dev, struct ieee80211_vif *vif,
133 struct ieee80211_sta *sta, bool en);
134 int mt7615_mcu_set_bcn(struct mt7615_dev *dev, struct ieee80211_vif *vif,
136 int mt7615_mcu_set_channel(struct mt7615_dev *dev);
137 int mt7615_mcu_set_wmm(struct mt7615_dev *dev, u8 queue,
138 const struct ieee80211_tx_queue_params *params);
139 int mt7615_mcu_set_tx_ba(struct mt7615_dev *dev,
140 struct ieee80211_ampdu_params *params,
142 int mt7615_mcu_set_rx_ba(struct mt7615_dev *dev,
143 struct ieee80211_ampdu_params *params,
145 int mt7615_mcu_set_ht_cap(struct mt7615_dev *dev, struct ieee80211_vif *vif,
146 struct ieee80211_sta *sta);
148 static inline void mt7615_irq_enable(struct mt7615_dev *dev, u32 mask)
150 mt76_set_irq_mask(&dev->mt76, MT_INT_MASK_CSR, 0, mask);
153 static inline void mt7615_irq_disable(struct mt7615_dev *dev, u32 mask)
155 mt76_set_irq_mask(&dev->mt76, MT_INT_MASK_CSR, mask, 0);
158 u16 mt7615_mac_tx_rate_val(struct mt7615_dev *dev,
159 const struct ieee80211_tx_rate *rate,
161 int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi,
162 struct sk_buff *skb, struct mt76_wcid *wcid,
163 struct ieee80211_sta *sta, int pid,
164 struct ieee80211_key_conf *key);
165 int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb);
166 void mt7615_mac_add_txs(struct mt7615_dev *dev, void *data);
167 void mt7615_mac_tx_free(struct mt7615_dev *dev, struct sk_buff *skb);
169 int mt7615_mcu_set_eeprom(struct mt7615_dev *dev);
170 int mt7615_mcu_init_mac(struct mt7615_dev *dev);
171 int mt7615_mcu_set_rts_thresh(struct mt7615_dev *dev, u32 val);
172 int mt7615_mcu_ctrl_pm_state(struct mt7615_dev *dev, int enter);
173 int mt7615_mcu_set_tx_power(struct mt7615_dev *dev);
174 void mt7615_mcu_exit(struct mt7615_dev *dev);
176 int mt7615_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
177 enum mt76_txq_id qid, struct mt76_wcid *wcid,
178 struct ieee80211_sta *sta,
179 struct mt76_tx_info *tx_info);
181 void mt7615_tx_complete_skb(struct mt76_dev *mdev, enum mt76_txq_id qid,
182 struct mt76_queue_entry *e);
184 void mt7615_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
185 struct sk_buff *skb);
186 void mt7615_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps);
187 int mt7615_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
188 struct ieee80211_sta *sta);
189 void mt7615_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif,
190 struct ieee80211_sta *sta);
191 void mt7615_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif,
192 struct ieee80211_sta *sta);
193 void mt7615_mac_work(struct work_struct *work);
194 void mt7615_txp_skb_unmap(struct mt76_dev *dev,
195 struct mt76_txwi_cache *txwi);