]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/net/wireless/mediatek/mt76/mt76x02_util.h
mt76: move mt76x02_rx_get_sta and mt76x02_rx_get_sta_wcid in mt76x02_util.h
[linux.git] / drivers / net / wireless / mediatek / mt76 / mt76x02_util.h
index 54cec0cbf6454d45f76d0eebda8fc515d0525e9d..f78526fcf423266f20309e005af94c7fe40bc5a3 100644 (file)
@@ -18,6 +18,8 @@
 #ifndef __MT76X02_UTIL_H
 #define __MT76X02_UTIL_H
 
+#include "mt76x02_mac.h"
+
 extern struct ieee80211_rate mt76x02_rates[12];
 
 void mt76x02_configure_filter(struct ieee80211_hw *hw,
@@ -77,4 +79,31 @@ mt76x02_wait_for_txrx_idle(struct mt76_dev *dev)
                                0, 100);
 }
 
+static inline struct mt76x02_sta *
+mt76x02_rx_get_sta(struct mt76_dev *dev, u8 idx)
+{
+       struct mt76_wcid *wcid;
+
+       if (idx >= ARRAY_SIZE(dev->wcid))
+               return NULL;
+
+       wcid = rcu_dereference(dev->wcid[idx]);
+       if (!wcid)
+               return NULL;
+
+       return container_of(wcid, struct mt76x02_sta, wcid);
+}
+
+static inline struct mt76_wcid *
+mt76x02_rx_get_sta_wcid(struct mt76x02_sta *sta, bool unicast)
+{
+       if (!sta)
+               return NULL;
+
+       if (unicast)
+               return &sta->wcid;
+       else
+               return &sta->vif->group_wcid;
+}
+
 #endif