software/drivers/sd8887/src/wlan/mlan/mlan_wmm.c
/**
 *  @brief Initialize WMM priority queues
 *
 *  @param priv     Pointer to the mlan_private driver data struct
 *  @param pwmm_ie  Pointer to the IEEEtypes_WmmParameter_t data struct
 *
 *  @return         N/A
 */
@brief Initialize WMM priority queues
@param priv     Pointer to the mlan_private driver data struct
@param pwmm_ie  Pointer to the IEEEtypes_WmmParameter_t data struct

@return         N/A
@brief Initialize WMM priority queues @param priv Pointer to the mlan_private driver data struct @param pwmm_ie Pointer to the IEEEtypes_WmmParameter_t data struct @return N / A
void
wlan_wmm_setup_queue_priorities(pmlan_private priv,
				IEEEtypes_WmmParameter_t *pwmm_ie)
{
	t_u16 cw_min, avg_back_off, tmp[4];
	t_u32 i, j, num_ac;
	t_u8 ac_idx;
	ENTER();
	if (!pwmm_ie || priv->wmm_enabled == MFALSE) {
		wlan_wmm_default_queue_priorities(priv);
		LEAVE();
		return;
	}
	memset(priv->adapter, tmp, 0, sizeof(tmp));
	HEXDUMP("WMM: setup_queue_priorities: param IE",
		(t_u8 *)pwmm_ie, sizeof(IEEEtypes_WmmParameter_t));
	PRINTM(MINFO, "WMM Parameter IE: version=%d, "
	       "qos_info Parameter Set Count=%d, Reserved=%#x\n",
	       pwmm_ie->vend_hdr.version, pwmm_ie->qos_info.para_set_count,
	       pwmm_ie->reserved);
	for (num_ac = 0; num_ac < NELEMENTS(pwmm_ie->ac_params); num_ac++) {
		cw_min = (1 << pwmm_ie->ac_params[num_ac].ecw.ecw_min) - 1;
		avg_back_off
			=
			(cw_min >> 1) +
			pwmm_ie->ac_params[num_ac].aci_aifsn.aifsn;
		ac_idx = wmm_aci_to_qidx_map[pwmm_ie->ac_params[num_ac].
					     aci_aifsn.aci];
		priv->wmm.queue_priority[ac_idx] = ac_idx;
		tmp[ac_idx] = avg_back_off;
		PRINTM(MCMND, "WMM: CWmax=%d CWmin=%d Avg Back-off=%d\n",
		       (1 << pwmm_ie->ac_params[num_ac].ecw.ecw_max) - 1,
		       cw_min, avg_back_off);
		PRINTM_AC(&pwmm_ie->ac_params[num_ac]);
	}
	HEXDUMP("WMM: avg_back_off", (t_u8 *)tmp, sizeof(tmp));
	HEXDUMP("WMM: queue_priority", priv->wmm.queue_priority,
		sizeof(priv->wmm.queue_priority));
	for (i = 0; i < num_ac; i++) {
		for (j = 1; j < num_ac - i; j++) {
			if (tmp[j - 1] > tmp[j]) {
				SWAP_U16(tmp[j - 1], tmp[j]);
				SWAP_U8(priv->wmm.queue_priority[j - 1],
					priv->wmm.queue_priority[j]);
			} else if (tmp[j - 1] == tmp[j]) {
				if (priv->wmm.queue_priority[j - 1]
				    < priv->wmm.queue_priority[j]) {
					SWAP_U8(priv->wmm.queue_priority[j - 1],
						priv->wmm.queue_priority[j]);
				}
			}
		}
	}
	wlan_wmm_queue_priorities_tid(priv, priv->wmm.queue_priority);
	HEXDUMP("WMM: avg_back_off, sort", (t_u8 *)tmp, sizeof(tmp));
	DBG_HEXDUMP(MCMD_D, "WMM: queue_priority, sort",
		    priv->wmm.queue_priority, sizeof(priv->wmm.queue_priority));
	LEAVE();
}
void wlan_wmm_setup_queue_priorities ( pmlan_private priv , IEEEtypes_WmmParameter_t * pwmm_ie ) { t_u16 cw_min , avg_back_off , tmp [ 4 ] ; t_u32 i , j , num_ac ; t_u8 ac_idx ; ENTER ( ) ; if ( ! pwmm_ie || priv -> wmm_enabled == MFALSE ) { wlan_wmm_default_queue_priorities ( priv ) ; LEAVE ( ) ; return ; } memset ( priv -> adapter , tmp , 0 , sizeof ( tmp ) ) ; HEXDUMP ( " " , ( t_u8 * ) pwmm_ie , sizeof ( IEEEtypes_WmmParameter_t ) ) ; PRINTM ( MINFO , " " " \n " , pwmm_ie -> vend_hdr . version , pwmm_ie -> qos_info . para_set_count , pwmm_ie -> reserved ) ; for ( num_ac = 0 ; num_ac < NELEMENTS ( pwmm_ie -> ac_params ) ; num_ac ++ ) { cw_min = ( 1 << pwmm_ie -> ac_params [ num_ac ] . ecw . ecw_min ) - 1 ; avg_back_off = ( cw_min >> 1 ) + pwmm_ie -> ac_params [ num_ac ] . aci_aifsn . aifsn ; ac_idx = wmm_aci_to_qidx_map [ pwmm_ie -> ac_params [ num_ac ] . aci_aifsn . aci ] ; priv -> wmm . queue_priority [ ac_idx ] = ac_idx ; tmp [ ac_idx ] = avg_back_off ; PRINTM ( MCMND , " \n " , ( 1 << pwmm_ie -> ac_params [ num_ac ] . ecw . ecw_max ) - 1 , cw_min , avg_back_off ) ; PRINTM_AC ( & pwmm_ie -> ac_params [ num_ac ] ) ; } HEXDUMP ( " " , ( t_u8 * ) tmp , sizeof ( tmp ) ) ; HEXDUMP ( " " , priv -> wmm . queue_priority , sizeof ( priv -> wmm . queue_priority ) ) ; for ( i = 0 ; i < num_ac ; i ++ ) { for ( j = 1 ; j < num_ac - i ; j ++ ) { if ( tmp [ j - 1 ] > tmp [ j ] ) { SWAP_U16 ( tmp [ j - 1 ] , tmp [ j ] ) ; SWAP_U8 ( priv -> wmm . queue_priority [ j - 1 ] , priv -> wmm . queue_priority [ j ] ) ; } else if ( tmp [ j - 1 ] == tmp [ j ] ) { if ( priv -> wmm . queue_priority [ j - 1 ] < priv -> wmm . queue_priority [ j ] ) { SWAP_U8 ( priv -> wmm . queue_priority [ j - 1 ] , priv -> wmm . queue_priority [ j ] ) ; } } } } wlan_wmm_queue_priorities_tid ( priv , priv -> wmm . queue_priority ) ; HEXDUMP ( " " , ( t_u8 * ) tmp , sizeof ( tmp ) ) ; DBG_HEXDUMP ( MCMD_D , " " , priv -> wmm . queue_priority , sizeof ( priv -> wmm . queue_priority ) ) ; LEAVE ( ) ; }
@brief Initialize WMM priority queues
  @param priv     Pointer to the mlan_private driver data struct
  @param pwmm_ie  Pointer to the IEEEtypes_WmmParameter_t data struct
@brief Initialize WMM priority queues @param priv Pointer to the mlan_private driver data struct @param pwmm_ie Pointer to the IEEEtypes_WmmParameter_t data struct
/* WMM is not enabled, just set the defaults and return */ /* Bubble sort */