Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

wifi: cfg80211: split control freq check from chandef check

In order to introduce NPCA later, split the control frequency
check out of cfg80211_chandef_valid().

Link: https://patch.msgid.link/20260303152641.11b31e4878a7.I534669506008e12ffcd6c115161777e528fdc838@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

+54 -44
+54 -44
net/wireless/chan.c
··· 6 6 * 7 7 * Copyright 2009 Johannes Berg <johannes@sipsolutions.net> 8 8 * Copyright 2013-2014 Intel Mobile Communications GmbH 9 - * Copyright 2018-2025 Intel Corporation 9 + * Copyright 2018-2026 Intel Corporation 10 10 */ 11 11 12 12 #include <linux/export.h> ··· 339 339 return (center - bw / 2 - 5945) % step == 0; 340 340 } 341 341 342 + static bool 343 + cfg80211_chandef_valid_control_freq(const struct cfg80211_chan_def *chandef, 344 + u32 control_freq) 345 + { 346 + switch (chandef->width) { 347 + case NL80211_CHAN_WIDTH_5: 348 + case NL80211_CHAN_WIDTH_10: 349 + case NL80211_CHAN_WIDTH_20: 350 + case NL80211_CHAN_WIDTH_20_NOHT: 351 + case NL80211_CHAN_WIDTH_1: 352 + case NL80211_CHAN_WIDTH_2: 353 + case NL80211_CHAN_WIDTH_4: 354 + case NL80211_CHAN_WIDTH_8: 355 + case NL80211_CHAN_WIDTH_16: 356 + /* checked separately */ 357 + break; 358 + case NL80211_CHAN_WIDTH_320: 359 + if (chandef->center_freq1 == control_freq + 150 || 360 + chandef->center_freq1 == control_freq + 130 || 361 + chandef->center_freq1 == control_freq + 110 || 362 + chandef->center_freq1 == control_freq + 90 || 363 + chandef->center_freq1 == control_freq - 90 || 364 + chandef->center_freq1 == control_freq - 110 || 365 + chandef->center_freq1 == control_freq - 130 || 366 + chandef->center_freq1 == control_freq - 150) 367 + break; 368 + fallthrough; 369 + case NL80211_CHAN_WIDTH_160: 370 + if (chandef->center_freq1 == control_freq + 70 || 371 + chandef->center_freq1 == control_freq + 50 || 372 + chandef->center_freq1 == control_freq - 50 || 373 + chandef->center_freq1 == control_freq - 70) 374 + break; 375 + fallthrough; 376 + case NL80211_CHAN_WIDTH_80P80: 377 + case NL80211_CHAN_WIDTH_80: 378 + if (chandef->center_freq1 == control_freq + 30 || 379 + chandef->center_freq1 == control_freq - 30) 380 + break; 381 + fallthrough; 382 + case NL80211_CHAN_WIDTH_40: 383 + if (chandef->center_freq1 == control_freq + 10 || 384 + chandef->center_freq1 == control_freq - 10) 385 + break; 386 + fallthrough; 387 + default: 388 + return false; 389 + } 390 + 391 + return true; 392 + } 393 + 342 394 bool cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef) 343 395 { 344 396 u32 control_freq, control_freq_khz, start_khz, end_khz; ··· 445 393 break; 446 394 } 447 395 448 - switch (chandef->width) { 449 - case NL80211_CHAN_WIDTH_5: 450 - case NL80211_CHAN_WIDTH_10: 451 - case NL80211_CHAN_WIDTH_20: 452 - case NL80211_CHAN_WIDTH_20_NOHT: 453 - case NL80211_CHAN_WIDTH_1: 454 - case NL80211_CHAN_WIDTH_2: 455 - case NL80211_CHAN_WIDTH_4: 456 - case NL80211_CHAN_WIDTH_8: 457 - case NL80211_CHAN_WIDTH_16: 458 - /* all checked above */ 459 - break; 460 - case NL80211_CHAN_WIDTH_320: 461 - if (chandef->center_freq1 == control_freq + 150 || 462 - chandef->center_freq1 == control_freq + 130 || 463 - chandef->center_freq1 == control_freq + 110 || 464 - chandef->center_freq1 == control_freq + 90 || 465 - chandef->center_freq1 == control_freq - 90 || 466 - chandef->center_freq1 == control_freq - 110 || 467 - chandef->center_freq1 == control_freq - 130 || 468 - chandef->center_freq1 == control_freq - 150) 469 - break; 470 - fallthrough; 471 - case NL80211_CHAN_WIDTH_160: 472 - if (chandef->center_freq1 == control_freq + 70 || 473 - chandef->center_freq1 == control_freq + 50 || 474 - chandef->center_freq1 == control_freq - 50 || 475 - chandef->center_freq1 == control_freq - 70) 476 - break; 477 - fallthrough; 478 - case NL80211_CHAN_WIDTH_80P80: 479 - case NL80211_CHAN_WIDTH_80: 480 - if (chandef->center_freq1 == control_freq + 30 || 481 - chandef->center_freq1 == control_freq - 30) 482 - break; 483 - fallthrough; 484 - case NL80211_CHAN_WIDTH_40: 485 - if (chandef->center_freq1 == control_freq + 10 || 486 - chandef->center_freq1 == control_freq - 10) 487 - break; 488 - fallthrough; 489 - default: 396 + if (!cfg80211_chandef_valid_control_freq(chandef, control_freq)) 490 397 return false; 491 - } 492 398 493 399 if (!cfg80211_valid_center_freq(chandef->center_freq1, chandef->width)) 494 400 return false;