drivers/net/wireless/intel/iwlegacy/3945-rs.c

Source file repositories/reference/linux-study-clean/drivers/net/wireless/intel/iwlegacy/3945-rs.c

File Facts

System
Linux kernel
Corpus path
drivers/net/wireless/intel/iwlegacy/3945-rs.c
Extension
.c
Size
24384 bytes
Lines
944
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern 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.

Dependency Surface

Detected Declarations

Annotated Snippet

static const struct file_operations rs_sta_dbgfs_stats_table_ops = {
	.read = il3945_sta_dbgfs_stats_table_read,
	.open = simple_open,
	.llseek = default_llseek,
};

static void
il3945_add_debugfs(void *il, void *il_sta, struct dentry *dir)
{
	struct il3945_rs_sta *lq_sta = il_sta;

	debugfs_create_file("rate_stats_table", 0600, dir, lq_sta,
			    &rs_sta_dbgfs_stats_table_ops);
}
#endif

/*
 * Initialization of rate scaling information is done by driver after
 * the station is added. Since mac80211 calls this function before a
 * station is added we ignore it.
 */
static void
il3945_rs_rate_init_stub(void *il_r, struct ieee80211_supported_band *sband,
			 struct cfg80211_chan_def *chandef,
			 struct ieee80211_sta *sta, void *il_sta)
{
}

static const struct rate_control_ops rs_ops = {
	.name = RS_NAME,
	.tx_status = il3945_rs_tx_status,
	.get_rate = il3945_rs_get_rate,
	.rate_init = il3945_rs_rate_init_stub,
	.alloc = il3945_rs_alloc,
	.free = il3945_rs_free,
	.alloc_sta = il3945_rs_alloc_sta,
	.free_sta = il3945_rs_free_sta,
#ifdef CONFIG_MAC80211_DEBUGFS
	.add_sta_debugfs = il3945_add_debugfs,
#endif

};

void
il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id)
{
	struct il_priv *il = hw->priv;
	s32 rssi = 0;
	unsigned long flags;
	struct il3945_rs_sta *rs_sta;
	struct ieee80211_sta *sta;
	struct il3945_sta_priv *psta;

	D_RATE("enter\n");

	rcu_read_lock();

	sta = ieee80211_find_sta(il->vif, il->stations[sta_id].sta.sta.addr);
	if (!sta) {
		D_RATE("Unable to find station to initialize rate scaling.\n");
		rcu_read_unlock();
		return;
	}

	psta = (void *)sta->drv_priv;
	rs_sta = &psta->rs_sta;

	spin_lock_irqsave(&rs_sta->lock, flags);

	rs_sta->tgg = 0;
	switch (il->band) {
	case NL80211_BAND_2GHZ:
		/* TODO: this always does G, not a regression */
		if (il->active.flags & RXON_FLG_TGG_PROTECT_MSK) {
			rs_sta->tgg = 1;
			rs_sta->expected_tpt = il3945_expected_tpt_g_prot;
		} else
			rs_sta->expected_tpt = il3945_expected_tpt_g;
		break;
	case NL80211_BAND_5GHZ:
		rs_sta->expected_tpt = il3945_expected_tpt_a;
		break;
	default:
		BUG();
		break;
	}

	spin_unlock_irqrestore(&rs_sta->lock, flags);

	rssi = il->_3945.last_rx_rssi;

Annotation

Implementation Notes