]> asedeno.scripts.mit.edu Git - linux.git/blob - drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
Merge tag 'selinux-pr-20190726' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux.git] / drivers / net / wireless / mediatek / mt76 / mt7615 / mt7615.h
1 /* SPDX-License-Identifier: ISC */
2 /* Copyright (C) 2019 MediaTek Inc. */
3
4 #ifndef __MT7615_H
5 #define __MT7615_H
6
7 #include <linux/interrupt.h>
8 #include <linux/ktime.h>
9 #include "../mt76.h"
10 #include "regs.h"
11
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)
17
18 #define MT7615_WATCHDOG_TIME            100 /* ms */
19 #define MT7615_RATE_RETRY               2
20
21 #define MT7615_TX_RING_SIZE             1024
22 #define MT7615_TX_MCU_RING_SIZE         128
23 #define MT7615_TX_FWDL_RING_SIZE        128
24
25 #define MT7615_RX_RING_SIZE             1024
26 #define MT7615_RX_MCU_RING_SIZE         512
27
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"
31
32 #define MT7615_EEPROM_SIZE              1024
33 #define MT7615_TOKEN_SIZE               4096
34
35 struct mt7615_vif;
36 struct mt7615_sta;
37
38 enum mt7615_hw_txq_id {
39         MT7615_TXQ_MAIN,
40         MT7615_TXQ_EXT,
41         MT7615_TXQ_MCU,
42         MT7615_TXQ_FWDL,
43 };
44
45 struct mt7615_sta {
46         struct mt76_wcid wcid; /* must be first */
47
48         struct mt7615_vif *vif;
49
50         struct ieee80211_tx_rate rates[8];
51         u8 rate_count;
52         u8 n_rates;
53
54         u8 rate_probe;
55 };
56
57 struct mt7615_vif {
58         u8 idx;
59         u8 omac_idx;
60         u8 band_idx;
61         u8 wmm_idx;
62
63         struct mt7615_sta sta;
64 };
65
66 struct mt7615_dev {
67         struct mt76_dev mt76; /* must be first */
68         u32 vif_mask;
69         u32 omac_mask;
70
71         spinlock_t token_lock;
72         struct idr token;
73 };
74
75 enum {
76         HW_BSSID_0 = 0x0,
77         HW_BSSID_1,
78         HW_BSSID_2,
79         HW_BSSID_3,
80         HW_BSSID_MAX,
81         EXT_BSSID_START = 0x10,
82         EXT_BSSID_1,
83         EXT_BSSID_2,
84         EXT_BSSID_3,
85         EXT_BSSID_4,
86         EXT_BSSID_5,
87         EXT_BSSID_6,
88         EXT_BSSID_7,
89         EXT_BSSID_8,
90         EXT_BSSID_9,
91         EXT_BSSID_10,
92         EXT_BSSID_11,
93         EXT_BSSID_12,
94         EXT_BSSID_13,
95         EXT_BSSID_14,
96         EXT_BSSID_15,
97         EXT_BSSID_END
98 };
99
100 extern const struct ieee80211_ops mt7615_ops;
101 extern struct pci_driver mt7615_pci_driver;
102
103 u32 mt7615_reg_map(struct mt7615_dev *dev, u32 addr);
104
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,
110                                   u8 chain_idx);
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,
117                             int en);
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,
125                         bool enable);
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,
135                        int en);
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,
141                          bool add);
142 int mt7615_mcu_set_rx_ba(struct mt7615_dev *dev,
143                          struct ieee80211_ampdu_params *params,
144                          bool add);
145 int mt7615_mcu_set_ht_cap(struct mt7615_dev *dev, struct ieee80211_vif *vif,
146                           struct ieee80211_sta *sta);
147
148 static inline void mt7615_irq_enable(struct mt7615_dev *dev, u32 mask)
149 {
150         mt76_set_irq_mask(&dev->mt76, MT_INT_MASK_CSR, 0, mask);
151 }
152
153 static inline void mt7615_irq_disable(struct mt7615_dev *dev, u32 mask)
154 {
155         mt76_set_irq_mask(&dev->mt76, MT_INT_MASK_CSR, mask, 0);
156 }
157
158 u16 mt7615_mac_tx_rate_val(struct mt7615_dev *dev,
159                            const struct ieee80211_tx_rate *rate,
160                            bool stbc, u8 *bw);
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);
168
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);
175
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);
180
181 void mt7615_tx_complete_skb(struct mt76_dev *mdev, enum mt76_txq_id qid,
182                             struct mt76_queue_entry *e);
183
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);
196
197 #endif