diff options
author | Lorenzo Bianconi <lorenzo.bianconi@redhat.com> | 2018-10-04 17:53:04 -0400 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2018-10-05 14:05:45 -0400 |
commit | 56e8d4dd5ce24cf534114c67de33861e86501981 (patch) | |
tree | 1a45d9a96984caba49cd5c0f820d9c7405a0ba79 /drivers/net/wireless | |
parent | 50b9e8d55a345a0742811e8135ecbcdde2727d44 (diff) |
mt76: move mt76x02_rx_get_sta and mt76x02_rx_get_sta_wcid in mt76x02_util.h
Move mt76x02_rx_get_sta and mt76x02_rx_get_sta_wcid utility routines in
mt76x02-lib module since it will be used by mt76x0 driver in order to
unify rxwi parsing
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt76x02_util.h | 29 | ||||
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt76x2/mac.c | 32 |
2 files changed, 31 insertions, 30 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.h b/drivers/net/wireless/mediatek/mt76/mt76x02_util.h index 54cec0cbf645..f78526fcf423 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.h | |||
@@ -18,6 +18,8 @@ | |||
18 | #ifndef __MT76X02_UTIL_H | 18 | #ifndef __MT76X02_UTIL_H |
19 | #define __MT76X02_UTIL_H | 19 | #define __MT76X02_UTIL_H |
20 | 20 | ||
21 | #include "mt76x02_mac.h" | ||
22 | |||
21 | extern struct ieee80211_rate mt76x02_rates[12]; | 23 | extern struct ieee80211_rate mt76x02_rates[12]; |
22 | 24 | ||
23 | void mt76x02_configure_filter(struct ieee80211_hw *hw, | 25 | void mt76x02_configure_filter(struct ieee80211_hw *hw, |
@@ -77,4 +79,31 @@ mt76x02_wait_for_txrx_idle(struct mt76_dev *dev) | |||
77 | 0, 100); | 79 | 0, 100); |
78 | } | 80 | } |
79 | 81 | ||
82 | static inline struct mt76x02_sta * | ||
83 | mt76x02_rx_get_sta(struct mt76_dev *dev, u8 idx) | ||
84 | { | ||
85 | struct mt76_wcid *wcid; | ||
86 | |||
87 | if (idx >= ARRAY_SIZE(dev->wcid)) | ||
88 | return NULL; | ||
89 | |||
90 | wcid = rcu_dereference(dev->wcid[idx]); | ||
91 | if (!wcid) | ||
92 | return NULL; | ||
93 | |||
94 | return container_of(wcid, struct mt76x02_sta, wcid); | ||
95 | } | ||
96 | |||
97 | static inline struct mt76_wcid * | ||
98 | mt76x02_rx_get_sta_wcid(struct mt76x02_sta *sta, bool unicast) | ||
99 | { | ||
100 | if (!sta) | ||
101 | return NULL; | ||
102 | |||
103 | if (unicast) | ||
104 | return &sta->wcid; | ||
105 | else | ||
106 | return &sta->vif->group_wcid; | ||
107 | } | ||
108 | |||
80 | #endif | 109 | #endif |
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2/mac.c b/drivers/net/wireless/mediatek/mt76/mt76x2/mac.c index c98ce1582aec..93bf8a9404b1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2/mac.c | |||
@@ -64,34 +64,6 @@ int mt76x2_mac_get_rssi(struct mt76x2_dev *dev, s8 rssi, int chain) | |||
64 | return rssi; | 64 | return rssi; |
65 | } | 65 | } |
66 | 66 | ||
67 | static struct mt76x02_sta * | ||
68 | mt76x2_rx_get_sta(struct mt76x2_dev *dev, u8 idx) | ||
69 | { | ||
70 | struct mt76_wcid *wcid; | ||
71 | |||
72 | if (idx >= ARRAY_SIZE(dev->mt76.wcid)) | ||
73 | return NULL; | ||
74 | |||
75 | wcid = rcu_dereference(dev->mt76.wcid[idx]); | ||
76 | if (!wcid) | ||
77 | return NULL; | ||
78 | |||
79 | return container_of(wcid, struct mt76x02_sta, wcid); | ||
80 | } | ||
81 | |||
82 | static struct mt76_wcid * | ||
83 | mt76x2_rx_get_sta_wcid(struct mt76x2_dev *dev, struct mt76x02_sta *sta, | ||
84 | bool unicast) | ||
85 | { | ||
86 | if (!sta) | ||
87 | return NULL; | ||
88 | |||
89 | if (unicast) | ||
90 | return &sta->wcid; | ||
91 | else | ||
92 | return &sta->vif->group_wcid; | ||
93 | } | ||
94 | |||
95 | int mt76x2_mac_process_rx(struct mt76x2_dev *dev, struct sk_buff *skb, | 67 | int mt76x2_mac_process_rx(struct mt76x2_dev *dev, struct sk_buff *skb, |
96 | void *rxi) | 68 | void *rxi) |
97 | { | 69 | { |
@@ -122,8 +94,8 @@ int mt76x2_mac_process_rx(struct mt76x2_dev *dev, struct sk_buff *skb, | |||
122 | } | 94 | } |
123 | 95 | ||
124 | wcid = FIELD_GET(MT_RXWI_CTL_WCID, ctl); | 96 | wcid = FIELD_GET(MT_RXWI_CTL_WCID, ctl); |
125 | sta = mt76x2_rx_get_sta(dev, wcid); | 97 | sta = mt76x02_rx_get_sta(&dev->mt76, wcid); |
126 | status->wcid = mt76x2_rx_get_sta_wcid(dev, sta, unicast); | 98 | status->wcid = mt76x02_rx_get_sta_wcid(sta, unicast); |
127 | 99 | ||
128 | len = FIELD_GET(MT_RXWI_CTL_MPDU_LEN, ctl); | 100 | len = FIELD_GET(MT_RXWI_CTL_MPDU_LEN, ctl); |
129 | pn_len = FIELD_GET(MT_RXINFO_PN_LEN, rxinfo); | 101 | pn_len = FIELD_GET(MT_RXINFO_PN_LEN, rxinfo); |