static void
minstrel_ht_update_rates(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
{
	struct ieee80211_sta_rates *rates;
	int i = 0;

	rates = kzalloc(sizeof(*rates), GFP_ATOMIC);
	if (!rates)
		return;

	/* Start with max_tp_rate[0] */
	minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_tp_rate[0]);

	if (mp->hw->max_rates >= 3) {
		/* At least 3 tx rates supported, use max_tp_rate[1] next */
		minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_tp_rate[1]);
	}

	if (mp->hw->max_rates >= 2) {
		/*
		 * At least 2 tx rates supported, use max_prob_rate next */
		minstrel_ht_set_rate(mp, mi, rates, i++, mi->max_prob_rate);
	}

	rates->rate[i].idx = -1;
	rate_control_set_rates(mp->hw, mi->sta, rates);
}
Beispiel #2
0
static void
minstrel_update_rates(struct minstrel_priv *mp, struct minstrel_sta_info *mi)
{
	struct ieee80211_sta_rates *ratetbl;
	int i = 0;

	ratetbl = kzalloc(sizeof(*ratetbl), GFP_ATOMIC);
	if (!ratetbl)
		return;

	/* Start with max_tp_rate */
	minstrel_set_rate(mi, ratetbl, i++, mi->max_tp_rate[0]);

	if (mp->hw->max_rates >= 3) {
		/* At least 3 tx rates supported, use max_tp_rate2 next */
		minstrel_set_rate(mi, ratetbl, i++, mi->max_tp_rate[1]);
	}

	if (mp->hw->max_rates >= 2) {
		/* At least 2 tx rates supported, use max_prob_rate next */
		minstrel_set_rate(mi, ratetbl, i++, mi->max_prob_rate);
	}

	/* Use lowest rate last */
	ratetbl->rate[i].idx = mi->lowest_rix;
	ratetbl->rate[i].count = mp->max_retry;
	ratetbl->rate[i].count_cts = mp->max_retry;
	ratetbl->rate[i].count_rts = mp->max_retry;

	rate_control_set_rates(mp->hw, mi->sta, ratetbl);
}
static void
indra_update_rates(struct indra_priv *ip, struct indra_sta_info *ii)
{
	struct ieee80211_sta_rates *ratetbl;
	unsigned int *found;
	unsigned int *loss_min;
	unsigned int **rates_min;
	unsigned int rates[1];
	unsigned int loss;
	int i,j;

	/* Allocate rate table */
	ratetbl = kzalloc(sizeof(*ratetbl), GFP_ATOMIC);
	if (!ratetbl)
		return;
		
	/* Before snr is initialized */	
	if (!ii->last_snr) {
		/* Use lowest rate always */
		ratetbl->rate[0].idx = ii->lowest_rix;
		ratetbl->rate[0].count = ip->max_retry;
		ratetbl->rate[0].count_cts = ip->max_retry;
		ratetbl->rate[0].count_rts = ip->max_retry;

		rate_control_set_rates(ip->hw, ii->sta, ratetbl);
		return;
	}
	
	/* Allocate and initialize temporary arrays */
	found = kzalloc(ip->max_retry*sizeof(*found),GFP_ATOMIC);
	loss_min = kzalloc(ip->max_retry*sizeof(*loss_min),GFP_ATOMIC);
	rates_min = kzalloc(ip->max_retry*sizeof(*rates_min),GFP_ATOMIC);
	for (i = 0; i < ip->max_retry; i++) {
		rates_min[i] = kzalloc(ip->max_retry*sizeof(*rates_min[i]),GFP_ATOMIC);
		loss_min[i] = UINT_MAX;
	}
		
	printk("MICHELE: opt_started\n");	
	/* Optimization */	
	for (i = 0; i < ii->n_rates; i++) {
		struct indra_rate *ir = &ii->r[i];
		/* Check service time bound */
		if (ir->attempts[0]>ip->st_deadline) 
			continue;
		loss = ir->per_snr_map[ii->last_snr];
		if (loss<=loss_min[0]) {
			/* Minimal combination found */
			found[0] = 1;
			rates_min[0][0] = i+1;
			loss_min[0] = loss;
		}
		/* Explore following stages */
		rates[0] = i+1;
		explore_stages(ip,ii,rates,i,found,rates_min,loss_min,2);
	}
	printk("MICHELE: opt_ended\n");	
	//printk("MICHELE: min_rate(1) = %u\n",rates_min[0][0]);
	//printk("MICHELE: min_rate(2) = %u,%u\n",rates_min[1][0],rates_min[1][1]);
	//printk("MICHELE: min_rate(3) = %u,%u,%u\n",rates_min[2][0],rates_min[2][1],rates_min[2][2]);
	//printk("MICHELE: min_rate(4) = %u,%u,%u,%u\n",rates_min[3][0],rates_min[3][1],rates_min[3][2],rates_min[3][3]);
	//printk("MICHELE: min_rate(5) = %u,%u,%u,%u,%u\n",rates_min[4][0],rates_min[4][1],rates_min[4][2],rates_min[4][3],rates_min[4][4]);
	//printk("MICHELE: min_rate(6) = %u,%u,%u,%u,%u,%u\n",rates_min[5][0],rates_min[5][1],rates_min[5][2],rates_min[5][3],rates_min[5][4],rates_min[5][5]);
	//printk("MICHELE: min_rate(7) = %u,%u,%u,%u,%u,%u,%u\n",rates_min[6][0],rates_min[6][1],rates_min[6][2],rates_min[6][3],rates_min[6][4],rates_min[6][5],rates_min[6][6]);
	
	/* Save optimization results in ratetbl */
	for (i = 0; i<ip->max_retry; i++) {
		if (found[i] == 0)
			break;
	}
	for (j = 0; j<i; j++) {
		struct indra_rate *ir = &ii->r[rates_min[i-1][j]-1];
		ratetbl->rate[j].idx = ir->rix;
		ratetbl->rate[j].count = 1;
		ratetbl->rate[j].count_cts = 1;
		ratetbl->rate[j].count_rts = 1;
	}
	rate_control_set_rates(ip->hw, ii->sta, ratetbl);
	
	/* Free memory */
	kfree(found);
	kfree(loss_min);
	for (i = 0; i < ip->max_retry; i++) {
		kfree(rates_min[i]);
	}
	kfree(rates_min);
	
}