Beispiel #1
0
/**
 *  @brief This function will dispatch all packets sequentially 
 *  		from start_win until a hole is found and adjust the 
 *  		start_win appropriately
 *
 *  @param priv    	        A pointer to mlan_private
 *  @param rx_reor_tbl_ptr  A pointer to structure RxReorderTbl
 *
 *  @return 	   	        MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
 */
static mlan_status
wlan_11n_scan_and_dispatch(t_void * priv, RxReorderTbl * rx_reor_tbl_ptr)
{
    int i, j, xchg;
    mlan_status ret = MLAN_STATUS_SUCCESS;
    void *rx_tmp_ptr = MNULL;
    mlan_private *pmpriv = (mlan_private *) priv;

    ENTER();

    for (i = 0; i < rx_reor_tbl_ptr->win_size; ++i) {
        pmpriv->adapter->callbacks.moal_spin_lock(pmpriv->adapter->pmoal_handle,
                                                  pmpriv->rx_pkt_lock);
        if (!rx_reor_tbl_ptr->rx_reorder_ptr[i]) {
            pmpriv->adapter->callbacks.moal_spin_unlock(pmpriv->adapter->
                                                        pmoal_handle,
                                                        pmpriv->rx_pkt_lock);
            break;
        }
        rx_tmp_ptr = rx_reor_tbl_ptr->rx_reorder_ptr[i];
        rx_reor_tbl_ptr->rx_reorder_ptr[i] = MNULL;
        pmpriv->adapter->callbacks.moal_spin_unlock(pmpriv->adapter->
                                                    pmoal_handle,
                                                    pmpriv->rx_pkt_lock);
        wlan_11n_dispatch_pkt(priv, rx_tmp_ptr);
    }

    pmpriv->adapter->callbacks.moal_spin_lock(pmpriv->adapter->pmoal_handle,
                                              pmpriv->rx_pkt_lock);
    /* 
     * We don't have a circular buffer, hence use rotation to simulate
     * circular buffer
     */
    if (i > 0) {
        xchg = rx_reor_tbl_ptr->win_size - i;
        for (j = 0; j < xchg; ++j) {
            rx_reor_tbl_ptr->rx_reorder_ptr[j] =
                rx_reor_tbl_ptr->rx_reorder_ptr[i + j];
            rx_reor_tbl_ptr->rx_reorder_ptr[i + j] = MNULL;
        }
    }
    rx_reor_tbl_ptr->start_win = (rx_reor_tbl_ptr->start_win + i)
        & (MAX_TID_VALUE - 1);
    pmpriv->adapter->callbacks.moal_spin_unlock(pmpriv->adapter->pmoal_handle,
                                                pmpriv->rx_pkt_lock);
    LEAVE();
    return ret;
}
/**
 *  @brief This function dispatchs all the packets in the buffer.
 *  		There could be holes in the buffer.
 *    
 *  @param priv    	        A pointer to mlan_private
 *  @param rx_reor_tbl_ptr  A pointer to structure RxReorderTbl
 *  @param start_win        Start window
 *
 *  @return 	   	        MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
 */
static mlan_status
wlan_11n_dispatch_pkt_until_start_win(t_void * priv,
                                      RxReorderTbl * rx_reor_tbl_ptr,
                                      int start_win)
{
    int no_pkt_to_send, i, xchg;
    mlan_status ret = MLAN_STATUS_SUCCESS;

    ENTER();

    no_pkt_to_send = (start_win > rx_reor_tbl_ptr->start_win) ?
        MIN((start_win - rx_reor_tbl_ptr->start_win),
            rx_reor_tbl_ptr->win_size) : rx_reor_tbl_ptr->win_size;

    for (i = 0; i < no_pkt_to_send; ++i) {
        if (rx_reor_tbl_ptr->rx_reorder_ptr[i]) {
            wlan_11n_dispatch_pkt(priv, rx_reor_tbl_ptr->rx_reorder_ptr[i]);
            rx_reor_tbl_ptr->rx_reorder_ptr[i] = MNULL;
        }
    }

    /* 
     * We don't have a circular buffer, hence use rotation to simulate
     * circular buffer
     */
    xchg = rx_reor_tbl_ptr->win_size - no_pkt_to_send;
    for (i = 0; i < xchg; ++i) {
        rx_reor_tbl_ptr->rx_reorder_ptr[i] =
            rx_reor_tbl_ptr->rx_reorder_ptr[no_pkt_to_send + i];
        rx_reor_tbl_ptr->rx_reorder_ptr[no_pkt_to_send + i] = MNULL;
    }

    rx_reor_tbl_ptr->start_win = start_win;

    LEAVE();
    return ret;
}
/**
 *  @brief This function will identify if RxReodering is needed for the packet
 *  		and will do the reordering if required before sending it to kernel
 *  
 *  @param priv     A pointer to mlan_private
 *  @param seq_num  Seqence number of the current packet
 *  @param tid	    Tid of the current packet
 *  @param ta	    Transmiter address of the current packet
 *  @param pkt_type Packetype for the current packet (to identify if its a BAR)
 *  @param payload  Pointer to the payload
 *
 *  @return 	    MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
 */
mlan_status
mlan_11n_rxreorder_pkt(void *priv, t_u16 seq_num, t_u16 tid,
                       t_u8 * ta, t_u8 pkt_type, void *payload)
{
    RxReorderTbl *rx_reor_tbl_ptr;
    int start_win, end_win, win_size;
    mlan_status ret = MLAN_STATUS_SUCCESS;
    pmlan_adapter pmadapter = ((mlan_private *) priv)->adapter;

    ENTER();

    if (!
        (rx_reor_tbl_ptr =
         wlan_11n_get_rxreorder_tbl((mlan_private *) priv, tid, ta))) {
        LEAVE();
        if (pkt_type == PKT_TYPE_BAR)
            return ret;
        else {
            wlan_11n_dispatch_pkt(priv, payload);
            return ret;
        }
    } else {
        if (pkt_type == PKT_TYPE_BAR)
            PRINTM(MDAT_D, "BAR ");

        start_win = rx_reor_tbl_ptr->start_win;
        win_size = rx_reor_tbl_ptr->win_size;
        end_win = ((start_win + win_size) - 1) & ~(MAX_TID_VALUE);
        if (rx_reor_tbl_ptr->timer_context.timer_is_set)
            pmadapter->callbacks.moal_stop_timer(rx_reor_tbl_ptr->timer_context.
                                                 timer);
        pmadapter->callbacks.moal_start_timer(rx_reor_tbl_ptr->timer_context.
                                              timer, MFALSE,
                                              MIN_FLUSH_TIMER_MS * win_size);
        rx_reor_tbl_ptr->timer_context.timer_is_set = MTRUE;

        PRINTM(MDAT_D, "TID %d, TA %02x:%02x:%02x:%02x:%02x:%02x\n",
               tid, ta[0], ta[1], ta[2], ta[3], ta[4], ta[5]);
        PRINTM(MDAT_D, "1:seq_num %d start_win %d win_size %d end_win %d\n",
               seq_num, start_win, win_size, end_win);
        /* 
         * If seq_num is less then starting win then ignore and drop the
         * packet
         */
        if ((start_win + TWOPOW11) > (MAX_TID_VALUE - 1)) {     /* Wrap */
            if (seq_num >= ((start_win + (TWOPOW11)) &
                            ~(MAX_TID_VALUE)) && (seq_num < start_win)) {
                LEAVE();
                return MLAN_STATUS_FAILURE;
            }
        } else if ((seq_num < start_win) ||
                   (seq_num > (start_win + (TWOPOW11)))) {
            LEAVE();
            return MLAN_STATUS_FAILURE;
        }

        /* 
         * If this packet is a BAR we adjust seq_num as
         * WinStart = seq_num
         */
        if (pkt_type == PKT_TYPE_BAR)
            seq_num = ((seq_num + win_size) - 1) & ~(MAX_TID_VALUE);

        PRINTM(MDAT_D, "2:seq_num %d start_win %d win_size %d end_win %d\n",
               seq_num, start_win, win_size, end_win);

        if (((end_win < start_win) && (seq_num < (TWOPOW11 -
                                                  (MAX_TID_VALUE - start_win)))
             && (seq_num > end_win))
            || ((end_win > start_win) &&
                ((seq_num > end_win) || (seq_num < start_win)))) {
            end_win = seq_num;
            if (((seq_num - win_size) + 1) >= 0)
                start_win = (end_win - win_size) + 1;
            else
                start_win = (MAX_TID_VALUE - (win_size - seq_num)) + 1;
            if ((ret = wlan_11n_dispatch_pkt_until_start_win(priv,
                                                             rx_reor_tbl_ptr,
                                                             start_win))) {
                LEAVE();
                return ret;
            }
        }

        PRINTM(MDAT_D, "3:seq_num %d start_win %d win_size %d"
               " end_win %d\n", seq_num, start_win, win_size, end_win);
        if (pkt_type != PKT_TYPE_BAR) {
            if (seq_num >= start_win)
                rx_reor_tbl_ptr->rx_reorder_ptr[seq_num - start_win] = payload;
            else                /* Wrap condition */
                rx_reor_tbl_ptr->rx_reorder_ptr[(seq_num
                                                 + (MAX_TID_VALUE)) -
                                                start_win] = payload;
        }

        wlan_11n_display_tbl_ptr(pmadapter, rx_reor_tbl_ptr);

        /* 
         * Dispatch all packets sequentially from start_win until a
         * hole is found and adjust the start_win appropriately
         */
        ret = wlan_11n_scan_and_dispatch(priv, rx_reor_tbl_ptr);

        wlan_11n_display_tbl_ptr(pmadapter, rx_reor_tbl_ptr);
    }

    LEAVE();
    return ret;
}