drivers/net/wireless/mediatek/mt76/channel.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/mediatek/mt76/channel.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/mediatek/mt76/channel.c- Extension
.c- Size
- 10133 bytes
- Lines
- 428
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
mt76.h
Detected Declarations
function Copyrightfunction mt76_phy_update_channelfunction mt76_add_chanctxfunction mt76_remove_chanctxfunction mt76_change_chanctxfunction mt76_assign_vif_chanctxfunction mt76_unassign_vif_chanctxfunction mt76_switch_vif_chanctxfunction mt76_put_vif_phy_linkfunction mt76_roc_completefunction mt76_roc_complete_workfunction mt76_abort_rocfunction mt76_remain_on_channelfunction mt76_cancel_remain_on_channelexport mt76_add_chanctxexport mt76_remove_chanctxexport mt76_change_chanctxexport mt76_assign_vif_chanctxexport mt76_unassign_vif_chanctxexport mt76_switch_vif_chanctxexport mt76_abort_rocexport mt76_remain_on_channelexport mt76_cancel_remain_on_channel
Annotated Snippet
if (!mlink) {
ret = -ENOMEM;
goto out;
}
mlink_alloc = true;
}
mlink->ctx = conf;
ret = dev->drv->vif_link_add(phy, vif, link_conf, mlink);
if (ret) {
if (mlink_alloc)
kfree(mlink);
goto out;
}
if (link_conf != &vif->bss_conf)
rcu_assign_pointer(mvif->link[link_id], mlink);
out:
mutex_unlock(&dev->mutex);
return ret;
}
EXPORT_SYMBOL_GPL(mt76_assign_vif_chanctx);
void mt76_unassign_vif_chanctx(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_bss_conf *link_conf,
struct ieee80211_chanctx_conf *conf)
{
struct mt76_chanctx *ctx = (struct mt76_chanctx *)conf->drv_priv;
struct mt76_vif_link *mlink = (struct mt76_vif_link *)vif->drv_priv;
struct mt76_phy *phy = ctx->phy;
struct mt76_dev *dev = phy->dev;
if (dev->scan.vif == vif)
mt76_abort_scan(dev);
mutex_lock(&dev->mutex);
if (vif->type == NL80211_IFTYPE_MONITOR &&
is_zero_ether_addr(vif->addr))
goto out;
mlink = mt76_vif_conf_link(dev, vif, link_conf);
if (!mlink)
goto out;
dev->drv->vif_link_remove(phy, vif, link_conf, mlink);
mlink->ctx = NULL;
out:
mutex_unlock(&dev->mutex);
}
EXPORT_SYMBOL_GPL(mt76_unassign_vif_chanctx);
int mt76_switch_vif_chanctx(struct ieee80211_hw *hw,
struct ieee80211_vif_chanctx_switch *vifs,
int n_vifs,
enum ieee80211_chanctx_switch_mode mode)
{
struct mt76_chanctx *old_ctx = (struct mt76_chanctx *)vifs->old_ctx->drv_priv;
struct mt76_chanctx *new_ctx = (struct mt76_chanctx *)vifs->new_ctx->drv_priv;
struct ieee80211_chanctx_conf *conf = vifs->new_ctx;
struct mt76_phy *old_phy = old_ctx->phy;
struct mt76_phy *phy = hw->priv;
struct mt76_dev *dev = phy->dev;
struct mt76_vif_link *mlink;
bool update_chan;
int i, ret = 0;
if (mode == CHANCTX_SWMODE_SWAP_CONTEXTS)
phy = new_ctx->phy = dev->band_phys[conf->def.chan->band];
else
phy = new_ctx->phy;
if (!phy)
return -EINVAL;
update_chan = phy->chanctx != new_ctx;
if (update_chan) {
if (dev->scan.phy == phy)
mt76_abort_scan(dev);
cancel_delayed_work_sync(&phy->mac_work);
}
mutex_lock(&dev->mutex);
if (mode == CHANCTX_SWMODE_SWAP_CONTEXTS &&
phy != old_phy && old_phy->chanctx == old_ctx)
old_phy->chanctx = NULL;
Annotation
- Immediate include surface: `mt76.h`.
- Detected declarations: `function Copyright`, `function mt76_phy_update_channel`, `function mt76_add_chanctx`, `function mt76_remove_chanctx`, `function mt76_change_chanctx`, `function mt76_assign_vif_chanctx`, `function mt76_unassign_vif_chanctx`, `function mt76_switch_vif_chanctx`, `function mt76_put_vif_phy_link`, `function mt76_roc_complete`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.