mac80211解析七

本文介绍了mac80211在模块初始化时如何启动minstrel速率控制模块,以及minstrel如何通过tx.c中的句柄设置速率变量。随后详细讨论了速率控制的注册过程,包括相关函数的实现,如低速发送函数和速率调整算法。这些函数和结构体共同作用于无线设备驱动的速率控制策略,允许根据计算结果动态调整发送速率。
摘要由CSDN通过智能技术生成

mac80211的模块初始化的时候,也初始化了minstrel,minstrel是调用速率控制函数模快,通过tx.c中的ieee80211_tx_h_rate_ctrl句柄填充结构体ieee80211_tx_info的速率变量ieee80211_tx_rate

模块初始化后调用了ieee80211_rate_control_register进行速率控制注册,注册了定义好的速率控制操作结构体mac80211_minstrel_ht,内容如下:


static const struct rate_control_ops mac80211_minstrel_ht = {
    .name = "minstrel_ht",
    .tx_status = minstrel_ht_tx_status,
    .get_rate = minstrel_ht_get_rate,
    .rate_init = minstrel_ht_rate_init,
    .rate_update = minstrel_ht_rate_update,
    .alloc_sta = minstrel_ht_alloc_sta,
    .free_sta = minstrel_ht_free_sta,
    .alloc = minstrel_ht_alloc,
    .free = minstrel_ht_free,
#ifdef CPTCFG_MAC80211_DEBUGFS
    .add_sta_debugfs = minstrel_ht_add_sta_debugfs,
    .remove_sta_debugfs = minstrel_ht_remove_sta_debugfs,
#endif
    .get_expected_throughput = minstrel_ht_get_expected_throughput,
};

其中minstrel_ht_get_rate函数,这个函数在高速率控制函数rc80211_minstrel_ht.c文件中,内容如下:


static void
minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
                     struct ieee80211_tx_rate_control *txrc)
{
    const struct mcs_group *sample_group;
    struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb);
    struct ieee80211_tx_rate *rate = &info->status.rates[0];
    struct minstrel_ht_sta_priv *msp = priv_sta;
    struct minstrel_ht_sta *mi = &msp->ht;
    struct minstrel_priv *mp = priv;
    int sample_idx;

    if (rate_control_send_low(sta, priv_sta, txrc))
        return;

    if (!msp->is_ht)
        return mac80211_minstrel.get_rate(priv, sta, &msp->legacy, txrc);

    info->flags |= mi->tx_flags;
    minstrel_ht_check_cck_shortpreamble(mp, mi, txrc->short_preamble);

#ifdef CPTCFG_MAC80211_DEBUGFS
    if (mp->fixed_rate_idx != -1)
        return;
#endif

    /* Don't use EAPOL frames for sampling on non-mrr hw */
    if (mp->hw->max_rates == 1 &&
        (info->control.flags & IEEE80211_TX_CTRL_PORT_CTRL_PROTO))
        sample_idx = -1;
    else
        sample_idx = minstrel_get_sample_rate(mp, mi);

    mi->total_packets++;

    /* wraparound */
    if (mi->total_packets == ~0) {
        mi->total_packets = 0;
        mi->sample_packets = 0;
    }

    if (sample_idx < 0)
        return;

    sample_group = &minstrel_mcs_groups[sample_idx / MCS_GROUP_RATES];
    info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
    rate->count = 1;

    if (sample_idx / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) {
        int idx = sample_idx % ARRAY_SIZE(mp->cck_rates);
        rate->idx = mp->cck_rates[idx];
        rate->flags = 0;
        return;
    }

    rate->idx = sample_idx % MCS_GROUP_RATES +
            (sample_group->streams - 1) * 8;
    rate->f
  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值