drivers/net/wireless/intel/iwlwifi/mld/tests/utils.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/intel/iwlwifi/mld/tests/utils.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/intel/iwlwifi/mld/tests/utils.c- Extension
.c- Size
- 15059 bytes
- Lines
- 562
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
kunit/test.hkunit/test-bug.hutils.hlinux/device.hfw/api/scan.hfw/api/mac-cfg.hiwl-trans.hmld.hiface.hlink.hphy.hsta.h
Detected Declarations
function Copyrightfunction iwlmld_kunit_init_linkfunction iwlmld_kunit_add_linkfunction iwlmld_kunit_add_chanctxfunction iwlmld_kunit_assign_chanctx_to_linkfunction iwlmld_kunit_add_link_stafunction iwlmld_kunit_alloc_link_stafunction iwlmld_kunit_add_stafunction iwlmld_kunit_move_sta_statefunction iwlmld_kunit_set_vif_associatedfunction iwlmld_kunit_setup_assocfunction iwlmld_kunit_setup_mlo_assocfunction iwlmld_kunit_setup_non_mlo_assocfunction _iwl_mld_kunit_create_pktfunction iwlmld_kunit_create_he_6ghz_operfunction test_iwl_mld_chandef_valid
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/*
* KUnit tests for channel helper functions
*
* Copyright (C) 2024-2026 Intel Corporation
*/
#include <kunit/test.h>
#include <kunit/test-bug.h>
#include "utils.h"
#include <linux/device.h>
#include "fw/api/scan.h"
#include "fw/api/mac-cfg.h"
#include "iwl-trans.h"
#include "mld.h"
#include "iface.h"
#include "link.h"
#include "phy.h"
#include "sta.h"
int iwlmld_kunit_test_init(struct kunit *test)
{
struct iwl_mld *mld;
struct iwl_trans *trans;
const struct iwl_rf_cfg *cfg;
struct iwl_fw *fw;
struct ieee80211_hw *hw;
KUNIT_ALLOC_AND_ASSERT(test, trans);
KUNIT_ALLOC_AND_ASSERT(test, trans->dev);
KUNIT_ALLOC_AND_ASSERT(test, cfg);
KUNIT_ALLOC_AND_ASSERT(test, fw);
KUNIT_ALLOC_AND_ASSERT(test, hw);
KUNIT_ALLOC_AND_ASSERT(test, hw->wiphy);
mutex_init(&hw->wiphy->mtx);
/* Allocate and initialize the mld structure */
KUNIT_ALLOC_AND_ASSERT(test, mld);
iwl_construct_mld(mld, trans, cfg, fw, hw, NULL);
fw->ucode_capa.num_stations = IWL_STATION_COUNT_MAX;
fw->ucode_capa.num_links = IWL_FW_MAX_LINKS;
mld->fwrt.trans = trans;
mld->fwrt.fw = fw;
mld->fwrt.dev = trans->dev;
/* TODO: add priv_size to hw allocation and setup hw->priv to enable
* testing mac80211 callbacks
*/
KUNIT_ALLOC_AND_ASSERT(test, mld->nvm_data);
KUNIT_ALLOC_AND_ASSERT_SIZE(test, mld->scan.cmd,
sizeof(struct iwl_scan_req_umac_v17));
mld->scan.cmd_size = sizeof(struct iwl_scan_req_umac_v17);
/* This is not the state at the end of the regular opmode_start,
* but it is more common to need it. Explicitly undo this if needed.
*/
mld->trans->state = IWL_TRANS_FW_ALIVE;
mld->fw_status.running = true;
/* Avoid passing mld struct around */
test->priv = mld;
return 0;
}
static void iwlmld_kunit_init_link(struct ieee80211_vif *vif,
struct ieee80211_bss_conf *link,
struct iwl_mld_link *mld_link, int link_id)
{
struct kunit *test = kunit_get_current_test();
struct iwl_mld *mld = test->priv;
struct iwl_mld_vif *mld_vif = iwl_mld_vif_from_mac80211(vif);
int ret;
/* setup mac80211 link */
rcu_assign_pointer(vif->link_conf[link_id], link);
link->link_id = link_id;
link->vif = vif;
link->beacon_int = 100;
link->dtim_period = 3;
link->qos = true;
/* and mld_link */
ret = iwl_mld_allocate_link_fw_id(mld, &mld_link->fw_id, link);
KUNIT_ASSERT_EQ(test, ret, 0);
Annotation
- Immediate include surface: `kunit/test.h`, `kunit/test-bug.h`, `utils.h`, `linux/device.h`, `fw/api/scan.h`, `fw/api/mac-cfg.h`, `iwl-trans.h`, `mld.h`.
- Detected declarations: `function Copyright`, `function iwlmld_kunit_init_link`, `function iwlmld_kunit_add_link`, `function iwlmld_kunit_add_chanctx`, `function iwlmld_kunit_assign_chanctx_to_link`, `function iwlmld_kunit_add_link_sta`, `function iwlmld_kunit_alloc_link_sta`, `function iwlmld_kunit_add_sta`, `function iwlmld_kunit_move_sta_state`, `function iwlmld_kunit_set_vif_associated`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.