sta_info.c (2a5ccbeec0f226c3a1099aac74069d89ea119e01) | sta_info.c (246b39e4a1ba5ad77edfb2f28d147abc5e2bb0a7) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright 2002-2005, Instant802 Networks, Inc. 4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> 5 * Copyright 2013-2014 Intel Mobile Communications GmbH 6 * Copyright (C) 2015 - 2017 Intel Deutschland GmbH 7 * Copyright (C) 2018-2021 Intel Corporation 8 */ --- 231 unchanged lines hidden (view full) --- 240 continue; 241 } 242 return sta; 243 } 244 245 return NULL; 246} 247 | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright 2002-2005, Instant802 Networks, Inc. 4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> 5 * Copyright 2013-2014 Intel Mobile Communications GmbH 6 * Copyright (C) 2015 - 2017 Intel Deutschland GmbH 7 * Copyright (C) 2018-2021 Intel Corporation 8 */ --- 231 unchanged lines hidden (view full) --- 240 continue; 241 } 242 return sta; 243 } 244 245 return NULL; 246} 247 |
248static void sta_info_free_links(struct sta_info *sta) 249{ 250 unsigned int link_id; 251 252 for (link_id = 0; link_id < ARRAY_SIZE(sta->link); link_id++) { 253 if (!sta->link[link_id]) 254 continue; 255 free_percpu(sta->link[link_id]->pcpu_rx_stats); 256 257 if (sta->link[link_id] != &sta->deflink) 258 kfree(sta->link[link_id]); 259 } 260} 261 |
|
248/** 249 * sta_info_free - free STA 250 * 251 * @local: pointer to the global information 252 * @sta: STA info to free 253 * 254 * This function must undo everything done by sta_info_alloc() 255 * that may happen before sta_info_insert(). It may only be --- 26 unchanged lines hidden (view full) --- 282 sta_dbg(sta->sdata, "Destroyed STA %pM\n", sta->sta.addr); 283 284 if (sta->sta.txq[0]) 285 kfree(to_txq_info(sta->sta.txq[0])); 286 kfree(rcu_dereference_raw(sta->sta.rates)); 287#ifdef CONFIG_MAC80211_MESH 288 kfree(sta->mesh); 289#endif | 262/** 263 * sta_info_free - free STA 264 * 265 * @local: pointer to the global information 266 * @sta: STA info to free 267 * 268 * This function must undo everything done by sta_info_alloc() 269 * that may happen before sta_info_insert(). It may only be --- 26 unchanged lines hidden (view full) --- 296 sta_dbg(sta->sdata, "Destroyed STA %pM\n", sta->sta.addr); 297 298 if (sta->sta.txq[0]) 299 kfree(to_txq_info(sta->sta.txq[0])); 300 kfree(rcu_dereference_raw(sta->sta.rates)); 301#ifdef CONFIG_MAC80211_MESH 302 kfree(sta->mesh); 303#endif |
290 free_percpu(sta->deflink.pcpu_rx_stats); | 304 305 sta_info_free_links(sta); |
291 kfree(sta); 292} 293 294/* Caller must hold local->sta_mtx */ 295static int sta_info_hash_add(struct ieee80211_local *local, 296 struct sta_info *sta) 297{ 298 return rhltable_insert(&local->sta_hash, &sta->hash_node, --- 29 unchanged lines hidden (view full) --- 328 sta->rate_ctrl_priv = rate_control_alloc_sta(sta->rate_ctrl, 329 sta, gfp); 330 if (!sta->rate_ctrl_priv) 331 return -ENOMEM; 332 333 return 0; 334} 335 | 306 kfree(sta); 307} 308 309/* Caller must hold local->sta_mtx */ 310static int sta_info_hash_add(struct ieee80211_local *local, 311 struct sta_info *sta) 312{ 313 return rhltable_insert(&local->sta_hash, &sta->hash_node, --- 29 unchanged lines hidden (view full) --- 343 sta->rate_ctrl_priv = rate_control_alloc_sta(sta->rate_ctrl, 344 sta, gfp); 345 if (!sta->rate_ctrl_priv) 346 return -ENOMEM; 347 348 return 0; 349} 350 |
351static int sta_info_init_link(struct sta_info *sta, 352 unsigned int link_id, 353 struct link_sta_info *link_info, 354 struct ieee80211_link_sta *link_sta, 355 gfp_t gfp) 356{ 357 struct ieee80211_local *local = sta->local; 358 struct ieee80211_hw *hw = &local->hw; 359 int i; 360 361 link_info->sta = sta; 362 link_info->link_id = link_id; 363 364 if (ieee80211_hw_check(hw, USES_RSS)) { 365 link_info->pcpu_rx_stats = 366 alloc_percpu_gfp(struct ieee80211_sta_rx_stats, gfp); 367 if (!link_info->pcpu_rx_stats) 368 return -ENOMEM; 369 } 370 371 sta->link[link_id] = link_info; 372 sta->sta.link[link_id] = link_sta; 373 374 link_info->rx_stats.last_rx = jiffies; 375 u64_stats_init(&link_info->rx_stats.syncp); 376 377 ewma_signal_init(&link_info->rx_stats_avg.signal); 378 ewma_avg_signal_init(&link_info->status_stats.avg_ack_signal); 379 for (i = 0; i < ARRAY_SIZE(link_info->rx_stats_avg.chain_signal); i++) 380 ewma_signal_init(&link_info->rx_stats_avg.chain_signal[i]); 381 382 return 0; 383} 384 |
|
336struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata, 337 const u8 *addr, gfp_t gfp) 338{ 339 struct ieee80211_local *local = sdata->local; 340 struct ieee80211_hw *hw = &local->hw; 341 struct sta_info *sta; 342 int i; 343 344 sta = kzalloc(sizeof(*sta) + hw->sta_data_size, gfp); 345 if (!sta) 346 return NULL; 347 | 385struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata, 386 const u8 *addr, gfp_t gfp) 387{ 388 struct ieee80211_local *local = sdata->local; 389 struct ieee80211_hw *hw = &local->hw; 390 struct sta_info *sta; 391 int i; 392 393 sta = kzalloc(sizeof(*sta) + hw->sta_data_size, gfp); 394 if (!sta) 395 return NULL; 396 |
348 if (ieee80211_hw_check(hw, USES_RSS)) { 349 sta->deflink.pcpu_rx_stats = 350 alloc_percpu_gfp(struct ieee80211_sta_rx_stats, gfp); 351 if (!sta->deflink.pcpu_rx_stats) 352 goto free; 353 } | 397 sta->local = local; 398 sta->sdata = sdata; |
354 | 399 |
400 if (sta_info_init_link(sta, 0, &sta->deflink, &sta->sta.deflink, gfp)) 401 return NULL; 402 |
|
355 spin_lock_init(&sta->lock); 356 spin_lock_init(&sta->ps_lock); 357 INIT_WORK(&sta->drv_deliver_wk, sta_deliver_ps_frames); 358 INIT_WORK(&sta->ampdu_mlme.work, ieee80211_ba_session_work); 359 mutex_init(&sta->ampdu_mlme.mtx); 360#ifdef CONFIG_MAC80211_MESH 361 if (ieee80211_vif_is_mesh(&sdata->vif)) { 362 sta->mesh = kzalloc(sizeof(*sta->mesh), gfp); --- 10 unchanged lines hidden (view full) --- 373 374 memcpy(sta->addr, addr, ETH_ALEN); 375 memcpy(sta->sta.addr, addr, ETH_ALEN); 376 sta->sta.max_rx_aggregation_subframes = 377 local->hw.max_rx_aggregation_subframes; 378 379 /* TODO link specific alloc and assignments for MLO Link STA */ 380 | 403 spin_lock_init(&sta->lock); 404 spin_lock_init(&sta->ps_lock); 405 INIT_WORK(&sta->drv_deliver_wk, sta_deliver_ps_frames); 406 INIT_WORK(&sta->ampdu_mlme.work, ieee80211_ba_session_work); 407 mutex_init(&sta->ampdu_mlme.mtx); 408#ifdef CONFIG_MAC80211_MESH 409 if (ieee80211_vif_is_mesh(&sdata->vif)) { 410 sta->mesh = kzalloc(sizeof(*sta->mesh), gfp); --- 10 unchanged lines hidden (view full) --- 421 422 memcpy(sta->addr, addr, ETH_ALEN); 423 memcpy(sta->sta.addr, addr, ETH_ALEN); 424 sta->sta.max_rx_aggregation_subframes = 425 local->hw.max_rx_aggregation_subframes; 426 427 /* TODO link specific alloc and assignments for MLO Link STA */ 428 |
381 /* For non MLO STA, link info can be accessed either via deflink 382 * or link[0] 383 */ 384 sta->link[0] = &sta->deflink; 385 sta->sta.link[0] = &sta->sta.deflink; 386 | |
387 /* Extended Key ID needs to install keys for keyid 0 and 1 Rx-only. 388 * The Tx path starts to use a key as soon as the key slot ptk_idx 389 * references to is not NULL. To not use the initial Rx-only key 390 * prematurely for Tx initialize ptk_idx to an impossible PTK keyid 391 * which always will refer to a NULL key. 392 */ 393 BUILD_BUG_ON(ARRAY_SIZE(sta->ptk) <= INVALID_PTK_KEYIDX); 394 sta->ptk_idx = INVALID_PTK_KEYIDX; 395 | 429 /* Extended Key ID needs to install keys for keyid 0 and 1 Rx-only. 430 * The Tx path starts to use a key as soon as the key slot ptk_idx 431 * references to is not NULL. To not use the initial Rx-only key 432 * prematurely for Tx initialize ptk_idx to an impossible PTK keyid 433 * which always will refer to a NULL key. 434 */ 435 BUILD_BUG_ON(ARRAY_SIZE(sta->ptk) <= INVALID_PTK_KEYIDX); 436 sta->ptk_idx = INVALID_PTK_KEYIDX; 437 |
396 sta->local = local; 397 sta->sdata = sdata; 398 sta->deflink.rx_stats.last_rx = jiffies; | |
399 | 438 |
400 u64_stats_init(&sta->deflink.rx_stats.syncp); 401 | |
402 ieee80211_init_frag_cache(&sta->frags); 403 404 sta->sta_state = IEEE80211_STA_NONE; 405 406 /* Mark TID as unreserved */ 407 sta->reserved_tid = IEEE80211_TID_UNRESERVED; 408 409 sta->last_connected = ktime_get_seconds(); | 439 ieee80211_init_frag_cache(&sta->frags); 440 441 sta->sta_state = IEEE80211_STA_NONE; 442 443 /* Mark TID as unreserved */ 444 sta->reserved_tid = IEEE80211_TID_UNRESERVED; 445 446 sta->last_connected = ktime_get_seconds(); |
410 ewma_signal_init(&sta->deflink.rx_stats_avg.signal); 411 ewma_avg_signal_init(&sta->deflink.status_stats.avg_ack_signal); 412 for (i = 0; i < ARRAY_SIZE(sta->deflink.rx_stats_avg.chain_signal); i++) 413 ewma_signal_init(&sta->deflink.rx_stats_avg.chain_signal[i]); | |
414 415 if (local->ops->wake_tx_queue) { 416 void *txq_data; 417 int size = sizeof(struct txq_info) + 418 ALIGN(hw->txq_data_size, sizeof(void *)); 419 420 txq_data = kcalloc(ARRAY_SIZE(sta->sta.txq), size, gfp); 421 if (!txq_data) --- 105 unchanged lines hidden (view full) --- 527 sta_dbg(sdata, "Allocated STA %pM\n", sta->sta.addr); 528 529 return sta; 530 531free_txq: 532 if (sta->sta.txq[0]) 533 kfree(to_txq_info(sta->sta.txq[0])); 534free: | 447 448 if (local->ops->wake_tx_queue) { 449 void *txq_data; 450 int size = sizeof(struct txq_info) + 451 ALIGN(hw->txq_data_size, sizeof(void *)); 452 453 txq_data = kcalloc(ARRAY_SIZE(sta->sta.txq), size, gfp); 454 if (!txq_data) --- 105 unchanged lines hidden (view full) --- 560 sta_dbg(sdata, "Allocated STA %pM\n", sta->sta.addr); 561 562 return sta; 563 564free_txq: 565 if (sta->sta.txq[0]) 566 kfree(to_txq_info(sta->sta.txq[0])); 567free: |
535 free_percpu(sta->deflink.pcpu_rx_stats); | 568 sta_info_free_links(sta); |
536#ifdef CONFIG_MAC80211_MESH 537 kfree(sta->mesh); 538#endif 539 kfree(sta); 540 return NULL; 541} 542 543static int sta_info_insert_check(struct sta_info *sta) --- 2039 unchanged lines hidden --- | 569#ifdef CONFIG_MAC80211_MESH 570 kfree(sta->mesh); 571#endif 572 kfree(sta); 573 return NULL; 574} 575 576static int sta_info_insert_check(struct sta_info *sta) --- 2039 unchanged lines hidden --- |