summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmer Efrat <omer.efrat@tandemg.com>2018-06-17 06:06:25 -0400
committerJohannes Berg <johannes.berg@intel.com>2018-06-29 03:53:09 -0400
commita4217750586975dee7d6dd8829a1be24a7678b3d (patch)
tree3708ac9a536391930f4f27975bff60ccb8919444
parent397c657a0644e7607c6aebea84d2b0f08ab59dfc (diff)
mac80211: use BIT_ULL for NL80211_STA_INFO_* attribute types
The BIT macro uses unsigned long which some architectures handle as 32 bit and therefore might cause macro's shift to overflow when used on a value equals or larger than 32 (NL80211_STA_INFO_RX_DURATION and afterwards). Since 'filled' member in station_info changed to u64, BIT_ULL macro should be used with all NL80211_STA_INFO_* attribute types instead of BIT to prevent future possible bugs when one will use BIT macro for higher attributes by mistake. This commit cleans up all usages of BIT macro with the above field in mac80211 by changing it to BIT_ULL instead. Signed-off-by: Omer Efrat <omer.efrat@tandemg.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r--net/mac80211/ethtool.c6
-rw-r--r--net/mac80211/sta_info.c84
2 files changed, 45 insertions, 45 deletions
diff --git a/net/mac80211/ethtool.c b/net/mac80211/ethtool.c
index 690c142a7a44..5ac743816b59 100644
--- a/net/mac80211/ethtool.c
+++ b/net/mac80211/ethtool.c
@@ -116,16 +116,16 @@ static void ieee80211_get_stats(struct net_device *dev,
116 data[i++] = sta->sta_state; 116 data[i++] = sta->sta_state;
117 117
118 118
119 if (sinfo.filled & BIT(NL80211_STA_INFO_TX_BITRATE)) 119 if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE))
120 data[i] = 100000ULL * 120 data[i] = 100000ULL *
121 cfg80211_calculate_bitrate(&sinfo.txrate); 121 cfg80211_calculate_bitrate(&sinfo.txrate);
122 i++; 122 i++;
123 if (sinfo.filled & BIT(NL80211_STA_INFO_RX_BITRATE)) 123 if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_RX_BITRATE))
124 data[i] = 100000ULL * 124 data[i] = 100000ULL *
125 cfg80211_calculate_bitrate(&sinfo.rxrate); 125 cfg80211_calculate_bitrate(&sinfo.rxrate);
126 i++; 126 i++;
127 127
128 if (sinfo.filled & BIT(NL80211_STA_INFO_SIGNAL_AVG)) 128 if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG))
129 data[i] = (u8)sinfo.signal_avg; 129 data[i] = (u8)sinfo.signal_avg;
130 i++; 130 i++;
131 } else { 131 } else {
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index aa8fe771a8db..f34202242d24 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -2114,38 +2114,38 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
2114 2114
2115 drv_sta_statistics(local, sdata, &sta->sta, sinfo); 2115 drv_sta_statistics(local, sdata, &sta->sta, sinfo);
2116 2116
2117 sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME) | 2117 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_INACTIVE_TIME) |
2118 BIT(NL80211_STA_INFO_STA_FLAGS) | 2118 BIT_ULL(NL80211_STA_INFO_STA_FLAGS) |
2119 BIT(NL80211_STA_INFO_BSS_PARAM) | 2119 BIT_ULL(NL80211_STA_INFO_BSS_PARAM) |
2120 BIT(NL80211_STA_INFO_CONNECTED_TIME) | 2120 BIT_ULL(NL80211_STA_INFO_CONNECTED_TIME) |
2121 BIT(NL80211_STA_INFO_RX_DROP_MISC); 2121 BIT_ULL(NL80211_STA_INFO_RX_DROP_MISC);
2122 2122
2123 if (sdata->vif.type == NL80211_IFTYPE_STATION) { 2123 if (sdata->vif.type == NL80211_IFTYPE_STATION) {
2124 sinfo->beacon_loss_count = sdata->u.mgd.beacon_loss_count; 2124 sinfo->beacon_loss_count = sdata->u.mgd.beacon_loss_count;
2125 sinfo->filled |= BIT(NL80211_STA_INFO_BEACON_LOSS); 2125 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BEACON_LOSS);
2126 } 2126 }
2127 2127
2128 sinfo->connected_time = ktime_get_seconds() - sta->last_connected; 2128 sinfo->connected_time = ktime_get_seconds() - sta->last_connected;
2129 sinfo->inactive_time = 2129 sinfo->inactive_time =
2130 jiffies_to_msecs(jiffies - ieee80211_sta_last_active(sta)); 2130 jiffies_to_msecs(jiffies - ieee80211_sta_last_active(sta));
2131 2131
2132 if (!(sinfo->filled & (BIT(NL80211_STA_INFO_TX_BYTES64) | 2132 if (!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_TX_BYTES64) |
2133 BIT(NL80211_STA_INFO_TX_BYTES)))) { 2133 BIT_ULL(NL80211_STA_INFO_TX_BYTES)))) {
2134 sinfo->tx_bytes = 0; 2134 sinfo->tx_bytes = 0;
2135 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) 2135 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
2136 sinfo->tx_bytes += sta->tx_stats.bytes[ac]; 2136 sinfo->tx_bytes += sta->tx_stats.bytes[ac];
2137 sinfo->filled |= BIT(NL80211_STA_INFO_TX_BYTES64); 2137 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BYTES64);
2138 } 2138 }
2139 2139
2140 if (!(sinfo->filled & BIT(NL80211_STA_INFO_TX_PACKETS))) { 2140 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_PACKETS))) {
2141 sinfo->tx_packets = 0; 2141 sinfo->tx_packets = 0;
2142 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) 2142 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
2143 sinfo->tx_packets += sta->tx_stats.packets[ac]; 2143 sinfo->tx_packets += sta->tx_stats.packets[ac];
2144 sinfo->filled |= BIT(NL80211_STA_INFO_TX_PACKETS); 2144 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_PACKETS);
2145 } 2145 }
2146 2146
2147 if (!(sinfo->filled & (BIT(NL80211_STA_INFO_RX_BYTES64) | 2147 if (!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_RX_BYTES64) |
2148 BIT(NL80211_STA_INFO_RX_BYTES)))) { 2148 BIT_ULL(NL80211_STA_INFO_RX_BYTES)))) {
2149 sinfo->rx_bytes += sta_get_stats_bytes(&sta->rx_stats); 2149 sinfo->rx_bytes += sta_get_stats_bytes(&sta->rx_stats);
2150 2150
2151 if (sta->pcpu_rx_stats) { 2151 if (sta->pcpu_rx_stats) {
@@ -2157,10 +2157,10 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
2157 } 2157 }
2158 } 2158 }
2159 2159
2160 sinfo->filled |= BIT(NL80211_STA_INFO_RX_BYTES64); 2160 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES64);
2161 } 2161 }
2162 2162
2163 if (!(sinfo->filled & BIT(NL80211_STA_INFO_RX_PACKETS))) { 2163 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_PACKETS))) {
2164 sinfo->rx_packets = sta->rx_stats.packets; 2164 sinfo->rx_packets = sta->rx_stats.packets;
2165 if (sta->pcpu_rx_stats) { 2165 if (sta->pcpu_rx_stats) {
2166 for_each_possible_cpu(cpu) { 2166 for_each_possible_cpu(cpu) {
@@ -2170,17 +2170,17 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
2170 sinfo->rx_packets += cpurxs->packets; 2170 sinfo->rx_packets += cpurxs->packets;
2171 } 2171 }
2172 } 2172 }
2173 sinfo->filled |= BIT(NL80211_STA_INFO_RX_PACKETS); 2173 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_PACKETS);
2174 } 2174 }
2175 2175
2176 if (!(sinfo->filled & BIT(NL80211_STA_INFO_TX_RETRIES))) { 2176 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_RETRIES))) {
2177 sinfo->tx_retries = sta->status_stats.retry_count; 2177 sinfo->tx_retries = sta->status_stats.retry_count;
2178 sinfo->filled |= BIT(NL80211_STA_INFO_TX_RETRIES); 2178 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES);
2179 } 2179 }
2180 2180
2181 if (!(sinfo->filled & BIT(NL80211_STA_INFO_TX_FAILED))) { 2181 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_FAILED))) {
2182 sinfo->tx_failed = sta->status_stats.retry_failed; 2182 sinfo->tx_failed = sta->status_stats.retry_failed;
2183 sinfo->filled |= BIT(NL80211_STA_INFO_TX_FAILED); 2183 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED);
2184 } 2184 }
2185 2185
2186 sinfo->rx_dropped_misc = sta->rx_stats.dropped; 2186 sinfo->rx_dropped_misc = sta->rx_stats.dropped;
@@ -2195,23 +2195,23 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
2195 2195
2196 if (sdata->vif.type == NL80211_IFTYPE_STATION && 2196 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
2197 !(sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)) { 2197 !(sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)) {
2198 sinfo->filled |= BIT(NL80211_STA_INFO_BEACON_RX) | 2198 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BEACON_RX) |
2199 BIT(NL80211_STA_INFO_BEACON_SIGNAL_AVG); 2199 BIT_ULL(NL80211_STA_INFO_BEACON_SIGNAL_AVG);
2200 sinfo->rx_beacon_signal_avg = ieee80211_ave_rssi(&sdata->vif); 2200 sinfo->rx_beacon_signal_avg = ieee80211_ave_rssi(&sdata->vif);
2201 } 2201 }
2202 2202
2203 if (ieee80211_hw_check(&sta->local->hw, SIGNAL_DBM) || 2203 if (ieee80211_hw_check(&sta->local->hw, SIGNAL_DBM) ||
2204 ieee80211_hw_check(&sta->local->hw, SIGNAL_UNSPEC)) { 2204 ieee80211_hw_check(&sta->local->hw, SIGNAL_UNSPEC)) {
2205 if (!(sinfo->filled & BIT(NL80211_STA_INFO_SIGNAL))) { 2205 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_SIGNAL))) {
2206 sinfo->signal = (s8)last_rxstats->last_signal; 2206 sinfo->signal = (s8)last_rxstats->last_signal;
2207 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL); 2207 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL);
2208 } 2208 }
2209 2209
2210 if (!sta->pcpu_rx_stats && 2210 if (!sta->pcpu_rx_stats &&
2211 !(sinfo->filled & BIT(NL80211_STA_INFO_SIGNAL_AVG))) { 2211 !(sinfo->filled & BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG))) {
2212 sinfo->signal_avg = 2212 sinfo->signal_avg =
2213 -ewma_signal_read(&sta->rx_stats_avg.signal); 2213 -ewma_signal_read(&sta->rx_stats_avg.signal);
2214 sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL_AVG); 2214 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG);
2215 } 2215 }
2216 } 2216 }
2217 2217
@@ -2220,11 +2220,11 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
2220 * pcpu statistics 2220 * pcpu statistics
2221 */ 2221 */
2222 if (last_rxstats->chains && 2222 if (last_rxstats->chains &&
2223 !(sinfo->filled & (BIT(NL80211_STA_INFO_CHAIN_SIGNAL) | 2223 !(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL) |
2224 BIT(NL80211_STA_INFO_CHAIN_SIGNAL_AVG)))) { 2224 BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL_AVG)))) {
2225 sinfo->filled |= BIT(NL80211_STA_INFO_CHAIN_SIGNAL); 2225 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL);
2226 if (!sta->pcpu_rx_stats) 2226 if (!sta->pcpu_rx_stats)
2227 sinfo->filled |= BIT(NL80211_STA_INFO_CHAIN_SIGNAL_AVG); 2227 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL_AVG);
2228 2228
2229 sinfo->chains = last_rxstats->chains; 2229 sinfo->chains = last_rxstats->chains;
2230 2230
@@ -2236,15 +2236,15 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
2236 } 2236 }
2237 } 2237 }
2238 2238
2239 if (!(sinfo->filled & BIT(NL80211_STA_INFO_TX_BITRATE))) { 2239 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE))) {
2240 sta_set_rate_info_tx(sta, &sta->tx_stats.last_rate, 2240 sta_set_rate_info_tx(sta, &sta->tx_stats.last_rate,
2241 &sinfo->txrate); 2241 &sinfo->txrate);
2242 sinfo->filled |= BIT(NL80211_STA_INFO_TX_BITRATE); 2242 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE);
2243 } 2243 }
2244 2244
2245 if (!(sinfo->filled & BIT(NL80211_STA_INFO_RX_BITRATE))) { 2245 if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_BITRATE))) {
2246 if (sta_set_rate_info_rx(sta, &sinfo->rxrate) == 0) 2246 if (sta_set_rate_info_rx(sta, &sinfo->rxrate) == 0)
2247 sinfo->filled |= BIT(NL80211_STA_INFO_RX_BITRATE); 2247 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BITRATE);
2248 } 2248 }
2249 2249
2250 if (tidstats && !cfg80211_sinfo_alloc_tid_stats(sinfo, GFP_KERNEL)) { 2250 if (tidstats && !cfg80211_sinfo_alloc_tid_stats(sinfo, GFP_KERNEL)) {
@@ -2257,18 +2257,18 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
2257 2257
2258 if (ieee80211_vif_is_mesh(&sdata->vif)) { 2258 if (ieee80211_vif_is_mesh(&sdata->vif)) {
2259#ifdef CONFIG_MAC80211_MESH 2259#ifdef CONFIG_MAC80211_MESH
2260 sinfo->filled |= BIT(NL80211_STA_INFO_LLID) | 2260 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_LLID) |
2261 BIT(NL80211_STA_INFO_PLID) | 2261 BIT_ULL(NL80211_STA_INFO_PLID) |
2262 BIT(NL80211_STA_INFO_PLINK_STATE) | 2262 BIT_ULL(NL80211_STA_INFO_PLINK_STATE) |
2263 BIT(NL80211_STA_INFO_LOCAL_PM) | 2263 BIT_ULL(NL80211_STA_INFO_LOCAL_PM) |
2264 BIT(NL80211_STA_INFO_PEER_PM) | 2264 BIT_ULL(NL80211_STA_INFO_PEER_PM) |
2265 BIT(NL80211_STA_INFO_NONPEER_PM); 2265 BIT_ULL(NL80211_STA_INFO_NONPEER_PM);
2266 2266
2267 sinfo->llid = sta->mesh->llid; 2267 sinfo->llid = sta->mesh->llid;
2268 sinfo->plid = sta->mesh->plid; 2268 sinfo->plid = sta->mesh->plid;
2269 sinfo->plink_state = sta->mesh->plink_state; 2269 sinfo->plink_state = sta->mesh->plink_state;
2270 if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) { 2270 if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) {
2271 sinfo->filled |= BIT(NL80211_STA_INFO_T_OFFSET); 2271 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_T_OFFSET);
2272 sinfo->t_offset = sta->mesh->t_offset; 2272 sinfo->t_offset = sta->mesh->t_offset;
2273 } 2273 }
2274 sinfo->local_pm = sta->mesh->local_pm; 2274 sinfo->local_pm = sta->mesh->local_pm;
@@ -2313,7 +2313,7 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
2313 thr = sta_get_expected_throughput(sta); 2313 thr = sta_get_expected_throughput(sta);
2314 2314
2315 if (thr != 0) { 2315 if (thr != 0) {
2316 sinfo->filled |= BIT(NL80211_STA_INFO_EXPECTED_THROUGHPUT); 2316 sinfo->filled |= BIT_ULL(NL80211_STA_INFO_EXPECTED_THROUGHPUT);
2317 sinfo->expected_throughput = thr; 2317 sinfo->expected_throughput = thr;
2318 } 2318 }
2319 2319