software/drivers/sd8887/src/wlan/mlan/mlan_wmm.c
/**
 *  @brief This function gets the highest priority list pointer
 *
 *  @param pmadapter      A pointer to mlan_adapter
 *  @param priv           A pointer to mlan_private
 *  @param tid            A pointer to return tid
 *
 *  @return             raListTbl
 */
@brief This function gets the highest priority list pointer
@param pmadapter      A pointer to mlan_adapter
@param priv           A pointer to mlan_private
@param tid            A pointer to return tid


@brief This function gets the highest priority list pointer @param pmadapter A pointer to mlan_adapter @param priv A pointer to mlan_private @param tid A pointer to return tid
static raListTbl *
wlan_wmm_get_highest_priolist_ptr(pmlan_adapter pmadapter,
				  pmlan_private *priv, int *tid)
{
	pmlan_private priv_tmp;
	raListTbl *ptr, *head;
	mlan_bssprio_node *bssprio_node, *bssprio_head;
	tid_tbl_t *tid_ptr;
	int i, j;
	int next_prio = 0;
	int next_tid = 0;
	ENTER();
	PRINTM(MDAT_D, "POP\n");
	for (j = pmadapter->priv_num - 1; j >= 0; --j) {
		if (!(util_peek_list(pmadapter->pmoal_handle,
				     &pmadapter->bssprio_tbl[j].bssprio_head,
				     MNULL, MNULL)))
			continue;
		if (pmadapter->bssprio_tbl[j].bssprio_cur ==
		    (mlan_bssprio_node *)
		    &pmadapter->bssprio_tbl[j].bssprio_head) {
			pmadapter->bssprio_tbl[j].bssprio_cur =
				pmadapter->bssprio_tbl[j].bssprio_cur->pnext;
		}
		bssprio_head
			= bssprio_node = pmadapter->bssprio_tbl[j].bssprio_cur;
		do {
			priv_tmp = bssprio_node->priv;
			if ((priv_tmp->port_ctrl_mode == MTRUE)
			    && (priv_tmp->port_open == MFALSE)) {
				PRINTM(MINFO, "get_highest_prio_ptr(): "
				       "PORT_CLOSED Ignore pkts from BSS%d\n",
				       priv_tmp->bss_index);
				goto next_intf;
			}
			if (priv_tmp->tx_pause == MTRUE) {
				PRINTM(MINFO, "get_highest_prio_ptr(): "
				       "TX PASUE Ignore pkts from BSS%d\n",
				       priv_tmp->bss_index);
				goto next_intf;
			}
			pmadapter->callbacks.moal_spin_lock(pmadapter->
							    pmoal_handle,
							    priv_tmp->wmm.
							    ra_list_spinlock);
			for (i = util_scalar_read(pmadapter->pmoal_handle,
						  &priv_tmp->wmm.
						  highest_queued_prio, MNULL,
						  MNULL); i >= LOW_PRIO_TID;
			     --i) {
				tid_ptr =
					&(priv_tmp)->wmm.
					tid_tbl_ptr[tos_to_tid[i]];
				if (!util_peek_list
				    (pmadapter->pmoal_handle, &tid_ptr->ra_list,
				     MNULL, MNULL))
					continue;
				head = ptr = tid_ptr->ra_list_curr->pnext;
				if (ptr == (raListTbl *)&tid_ptr->ra_list)
					head = ptr = ptr->pnext;
				do {
					if (!ptr->tx_pause &&
					    util_peek_list(pmadapter->
							   pmoal_handle,
							   &ptr->buf_head,
							   MNULL, MNULL)) {
						if (i % 2)
							next_prio = i - 1;
						else
							next_prio = i + 1;
						next_tid =
							tos_to_tid[next_prio];
						if (priv_tmp->wmm.
						    pkts_queued[next_tid] &&
						    (priv_tmp->wmm.
						     pkts_queued[next_tid] >
						     priv_tmp->wmm.
						     pkts_paused[next_tid]))
							util_scalar_write
								(pmadapter->
								 pmoal_handle,
								 &priv_tmp->wmm.
								 highest_queued_prio,
								 next_prio,
								 MNULL, MNULL);
						else
							util_scalar_conditional_write
								(pmadapter->
								 pmoal_handle,
								 &priv_tmp->wmm.
								 highest_queued_prio,
								 MLAN_SCALAR_COND_GREATER_THAN,
								 i, i, MNULL,
								 MNULL);
						*priv = priv_tmp;
						*tid = tos_to_tid[i];
						PRINTM(MDAT_D,
						       "get highest prio ptr %p, tid %d\n",
						       ptr, *tid);
						LEAVE();
						return ptr;
					}
					ptr = ptr->pnext;
					if (ptr ==
					    (raListTbl *)&tid_ptr->ra_list)
						ptr = ptr->pnext;
				} while (ptr != head);
			}
			if (util_scalar_read(pmadapter->pmoal_handle,
					     &priv_tmp->wmm.tx_pkts_queued,
					     MNULL, MNULL))
				util_scalar_write(pmadapter->pmoal_handle,
						  &priv_tmp->wmm.
						  highest_queued_prio,
						  HIGH_PRIO_TID, MNULL, MNULL);
			else
				util_scalar_write(pmadapter->pmoal_handle,
						  &priv_tmp->wmm.
						  highest_queued_prio,
						  NO_PKT_PRIO_TID, MNULL,
						  MNULL);
			pmadapter->callbacks.moal_spin_unlock(pmadapter->
							      pmoal_handle,
							      priv_tmp->wmm.
							      ra_list_spinlock);
next_intf:
			bssprio_node = bssprio_node->pnext;
			if (bssprio_node == (mlan_bssprio_node *)
			    &pmadapter->bssprio_tbl[j].bssprio_head)
				bssprio_node = bssprio_node->pnext;
			pmadapter->bssprio_tbl[j].bssprio_cur = bssprio_node;
		} while (bssprio_node != bssprio_head);
	}
	LEAVE();
	return MNULL;
}
static raListTbl * wlan_wmm_get_highest_priolist_ptr ( pmlan_adapter pmadapter , pmlan_private * priv , int * tid ) { pmlan_private priv_tmp ; raListTbl * ptr , * head ; mlan_bssprio_node * bssprio_node , * bssprio_head ; tid_tbl_t * tid_ptr ; int i , j ; int next_prio = 0 ; int next_tid = 0 ; ENTER ( ) ; PRINTM ( MDAT_D , " \n " ) ; for ( j = pmadapter -> priv_num - 1 ; j >= 0 ; -- j ) { if ( ! ( util_peek_list ( pmadapter -> pmoal_handle , & pmadapter -> bssprio_tbl [ j ] . bssprio_head , MNULL , MNULL ) ) ) continue ; if ( pmadapter -> bssprio_tbl [ j ] . bssprio_cur == ( mlan_bssprio_node * ) & pmadapter -> bssprio_tbl [ j ] . bssprio_head ) { pmadapter -> bssprio_tbl [ j ] . bssprio_cur = pmadapter -> bssprio_tbl [ j ] . bssprio_cur -> pnext ; } bssprio_head = bssprio_node = pmadapter -> bssprio_tbl [ j ] . bssprio_cur ; do { priv_tmp = bssprio_node -> priv ; if ( ( priv_tmp -> port_ctrl_mode == MTRUE ) && ( priv_tmp -> port_open == MFALSE ) ) { PRINTM ( MINFO , " " " \n " , priv_tmp -> bss_index ) ; goto next_intf ; } if ( priv_tmp -> tx_pause == MTRUE ) { PRINTM ( MINFO , " " " \n " , priv_tmp -> bss_index ) ; goto next_intf ; } pmadapter -> callbacks . moal_spin_lock ( pmadapter -> pmoal_handle , priv_tmp -> wmm . ra_list_spinlock ) ; for ( i = util_scalar_read ( pmadapter -> pmoal_handle , & priv_tmp -> wmm . highest_queued_prio , MNULL , MNULL ) ; i >= LOW_PRIO_TID ; -- i ) { tid_ptr = & ( priv_tmp ) -> wmm . tid_tbl_ptr [ tos_to_tid [ i ] ] ; if ( ! util_peek_list ( pmadapter -> pmoal_handle , & tid_ptr -> ra_list , MNULL , MNULL ) ) continue ; head = ptr = tid_ptr -> ra_list_curr -> pnext ; if ( ptr == ( raListTbl * ) & tid_ptr -> ra_list ) head = ptr = ptr -> pnext ; do { if ( ! ptr -> tx_pause && util_peek_list ( pmadapter -> pmoal_handle , & ptr -> buf_head , MNULL , MNULL ) ) { if ( i % 2 ) next_prio = i - 1 ; else next_prio = i + 1 ; next_tid = tos_to_tid [ next_prio ] ; if ( priv_tmp -> wmm . pkts_queued [ next_tid ] && ( priv_tmp -> wmm . pkts_queued [ next_tid ] > priv_tmp -> wmm . pkts_paused [ next_tid ] ) ) util_scalar_write ( pmadapter -> pmoal_handle , & priv_tmp -> wmm . highest_queued_prio , next_prio , MNULL , MNULL ) ; else util_scalar_conditional_write ( pmadapter -> pmoal_handle , & priv_tmp -> wmm . highest_queued_prio , MLAN_SCALAR_COND_GREATER_THAN , i , i , MNULL , MNULL ) ; * priv = priv_tmp ; * tid = tos_to_tid [ i ] ; PRINTM ( MDAT_D , " \n " , ptr , * tid ) ; LEAVE ( ) ; return ptr ; } ptr = ptr -> pnext ; if ( ptr == ( raListTbl * ) & tid_ptr -> ra_list ) ptr = ptr -> pnext ; } while ( ptr != head ) ; } if ( util_scalar_read ( pmadapter -> pmoal_handle , & priv_tmp -> wmm . tx_pkts_queued , MNULL , MNULL ) ) util_scalar_write ( pmadapter -> pmoal_handle , & priv_tmp -> wmm . highest_queued_prio , HIGH_PRIO_TID , MNULL , MNULL ) ; else util_scalar_write ( pmadapter -> pmoal_handle , & priv_tmp -> wmm . highest_queued_prio , NO_PKT_PRIO_TID , MNULL , MNULL ) ; pmadapter -> callbacks . moal_spin_unlock ( pmadapter -> pmoal_handle , priv_tmp -> wmm . ra_list_spinlock ) ; next_intf : bssprio_node = bssprio_node -> pnext ; if ( bssprio_node == ( mlan_bssprio_node * ) & pmadapter -> bssprio_tbl [ j ] . bssprio_head ) bssprio_node = bssprio_node -> pnext ; pmadapter -> bssprio_tbl [ j ] . bssprio_cur = bssprio_node ; } while ( bssprio_node != bssprio_head ) ; } LEAVE ( ) ; return MNULL ; }
@brief This function gets the highest priority list pointer
  @param pmadapter      A pointer to mlan_adapter
  @param priv           A pointer to mlan_private
  @param tid            A pointer to return tid
@brief This function gets the highest priority list pointer @param pmadapter A pointer to mlan_adapter @param priv A pointer to mlan_private @param tid A pointer to return tid
/* Ignore data pkts from a BSS if port is closed */ /* Ignore data pkts from a BSS if tx pause */ /*
				 * Always choose the next ra we transmitted
				 * last time, this way we pick the ra's in
				 * round robin fashion.
				 */ /* Because WMM only support BK/BE/VI/VO, we have 8 tid
						 * We should balance the traffic of the same AC */ /* if highest_queued_prio > i, set it to i */ /* hold priv->ra_list_spinlock to maintain ptr */ /* If priv still has packets queued, reset to HIGH_PRIO_TID */ /* No packet at any TID for this priv.  Mark as such to skip
				 * checking TIDs for this priv (until pkt is added). */