1 /* SPDX-License-Identifier: ISC */ 2 /* Copyright (C) 2023 MediaTek Inc. */ 3 4 #ifndef __MT792X_H 5 #define __MT792X_H 6 7 #include <linux/interrupt.h> 8 #include <linux/ktime.h> 9 10 #include "mt76_connac_mcu.h" 11 12 struct mt792x_vif; 13 struct mt792x_sta; 14 15 enum { 16 MT792x_CLC_POWER, 17 MT792x_CLC_CHAN, 18 MT792x_CLC_MAX_NUM, 19 }; 20 21 DECLARE_EWMA(avg_signal, 10, 8) 22 23 struct mt792x_sta { 24 struct mt76_wcid wcid; /* must be first */ 25 26 struct mt792x_vif *vif; 27 28 u32 airtime_ac[8]; 29 30 int ack_signal; 31 struct ewma_avg_signal avg_ack_signal; 32 33 unsigned long last_txs; 34 35 struct mt76_connac_sta_key_conf bip; 36 }; 37 38 DECLARE_EWMA(rssi, 10, 8); 39 40 struct mt792x_vif { 41 struct mt76_vif mt76; /* must be first */ 42 43 struct mt792x_sta sta; 44 struct mt792x_sta *wep_sta; 45 46 struct mt792x_phy *phy; 47 48 struct ewma_rssi rssi; 49 50 struct ieee80211_tx_queue_params queue_params[IEEE80211_NUM_ACS]; 51 struct ieee80211_chanctx_conf *ctx; 52 }; 53 54 struct mt792x_phy { 55 struct mt76_phy *mt76; 56 struct mt792x_dev *dev; 57 58 struct ieee80211_sband_iftype_data iftype[NUM_NL80211_BANDS][NUM_NL80211_IFTYPES]; 59 60 u64 omac_mask; 61 62 u16 noise; 63 64 s16 coverage_class; 65 u8 slottime; 66 67 u32 rx_ampdu_ts; 68 u32 ampdu_ref; 69 70 struct mt76_mib_stats mib; 71 72 u8 sta_work_count; 73 74 struct sk_buff_head scan_event_list; 75 struct delayed_work scan_work; 76 #ifdef CONFIG_ACPI 77 void *acpisar; 78 #endif 79 void *clc[MT792x_CLC_MAX_NUM]; 80 81 struct work_struct roc_work; 82 struct timer_list roc_timer; 83 wait_queue_head_t roc_wait; 84 u8 roc_token_id; 85 bool roc_grant; 86 }; 87 88 struct mt792x_hif_ops { 89 int (*init_reset)(struct mt792x_dev *dev); 90 int (*reset)(struct mt792x_dev *dev); 91 int (*mcu_init)(struct mt792x_dev *dev); 92 int (*drv_own)(struct mt792x_dev *dev); 93 int (*fw_own)(struct mt792x_dev *dev); 94 }; 95 96 struct mt792x_dev { 97 union { /* must be first */ 98 struct mt76_dev mt76; 99 struct mt76_phy mphy; 100 }; 101 102 const struct mt76_bus_ops *bus_ops; 103 struct mt792x_phy phy; 104 105 struct work_struct reset_work; 106 bool hw_full_reset:1; 107 bool hw_init_done:1; 108 bool fw_assert:1; 109 bool has_eht:1; 110 111 struct work_struct init_work; 112 113 u8 fw_debug; 114 u8 fw_features; 115 116 struct mt76_connac_pm pm; 117 struct mt76_connac_coredump coredump; 118 const struct mt792x_hif_ops *hif_ops; 119 120 struct work_struct ipv6_ns_work; 121 /* IPv6 addresses for WoWLAN */ 122 struct sk_buff_head ipv6_ns_list; 123 124 enum environment_cap country_ie_env; 125 u32 backup_l1; 126 u32 backup_l2; 127 }; 128 129 static inline struct mt792x_dev * 130 mt792x_hw_dev(struct ieee80211_hw *hw) 131 { 132 struct mt76_phy *phy = hw->priv; 133 134 return container_of(phy->dev, struct mt792x_dev, mt76); 135 } 136 137 #define mt792x_mutex_acquire(dev) \ 138 mt76_connac_mutex_acquire(&(dev)->mt76, &(dev)->pm) 139 #define mt792x_mutex_release(dev) \ 140 mt76_connac_mutex_release(&(dev)->mt76, &(dev)->pm) 141 142 #endif /* __MT7925_H */ 143