Ejemplo n.º 1
0
/*
 * node saveq flush.
 */
void
ath_node_pwrsaveq_flush(ath_node_t node)
{
    struct ath_node *an = ATH_NODE(node);
    struct ath_softc *sc = an->an_sc;
    ath_wbuf_t athwbuf;
    wbuf_t wbuf;
    struct ath_node_pwrsaveq *dataq,*mgtq;
    int dqlen, mqlen;
    ieee80211_tx_control_t *txctl;

    dataq = ATH_NODE_PWRSAVEQ_DATAQ(an); 
    mgtq  = ATH_NODE_PWRSAVEQ_MGMTQ(an); 

    /* XXX if no stations in ps mode, flush mc frames */
    dqlen = ATH_NODE_PWRSAVEQ_QLEN(dataq);

    /*
     * Flush queued mgmt frames.
     */
    ATH_NODE_PWRSAVEQ_LOCK(mgtq);
    if (ATH_NODE_PWRSAVEQ_QLEN(mgtq) != 0) {
        DPRINTF(sc, ATH_DEBUG_PWR_SAVE, "flush mgt ps queue, %u packets queued \n",
                                         ATH_NODE_PWRSAVEQ_QLEN(mgtq));
        for (;;) {

            ATH_NODE_PWRSAVEQ_DEQUEUE(mgtq, athwbuf);
            if (athwbuf == NULL)
                break;
            wbuf = athwbuf->wbuf;
            ASSERT(wbuf);
            mqlen = ATH_NODE_PWRSAVEQ_QLEN(mgtq);
            DPRINTF(sc, ATH_DEBUG_PWR_SAVE, "sendmgmt ps queue, %u packets remaining \n", mqlen);
            /*
             * For a Station node (non bss node) If this is the last packet, turn off the TIM bit,
             * Set the PWR_SAV bit on every frame but the last one
             * to allow encap to test for
             * adding more MORE_DATA bit to wh.
             */
            if (mqlen || dqlen) {
                wbuf_set_moredata(wbuf);
                if (wbuf_is_moredata(wbuf)) {
                    struct ieee80211_frame *wh = (struct ieee80211_frame *)wbuf_header(wbuf);
                    wh->i_fc[1] |= IEEE80211_FC1_MORE_DATA;
                } 
            }

            wbuf_clear_legacy_ps(wbuf);
            txctl = &athwbuf->txctl;

            if (sc->sc_ath_ops.tx(sc, wbuf, txctl) != 0) {
                DPRINTF(sc, ATH_DEBUG_PWR_SAVE, "%s: send error, comple the wbuf\n", __func__);
                ath_node_pwrsaveq_complete_athwbuf(an, athwbuf);
            } else {
                if (athwbuf) {
                    OS_FREE_PS(athwbuf);
                }
            }
        }
    }
    mgtq->nsq_num_ps_frames = 0;
    ATH_NODE_PWRSAVEQ_UNLOCK(mgtq);

    /*
     * Flush queued unicast frames.
     */
    ATH_NODE_PWRSAVEQ_LOCK(dataq);
    if (ATH_NODE_PWRSAVEQ_QLEN(dataq) != 0) {
        DPRINTF(sc, ATH_DEBUG_PWR_SAVE, "flush data ps queue, %u packets queued \n",
            ATH_NODE_PWRSAVEQ_QLEN(dataq));
        for (;;) {

            ATH_NODE_PWRSAVEQ_DEQUEUE(dataq, athwbuf);
            if (athwbuf == NULL)
                break;
            wbuf = athwbuf->wbuf;
            ASSERT(wbuf);
            dqlen = ATH_NODE_PWRSAVEQ_QLEN(dataq);
            DPRINTF(sc, ATH_DEBUG_PWR_SAVE, "senddata ps queue, %u packets remaining \n", dqlen);
            /*
             * For a Station node (non bss node) If this is the last packet, turn off the TIM bit,
             * Set the PWR_SAV bit on every frame but the last one
             * to allow encap to test for
             * adding more MORE_DATA bit to wh.
             */
            if (dqlen) {
                wbuf_set_moredata(wbuf);
                if (wbuf_is_moredata(wbuf)) {
                    struct ieee80211_frame *wh = (struct ieee80211_frame *)wbuf_header(wbuf);
                    wh->i_fc[1] |= IEEE80211_FC1_MORE_DATA;
                } 
            }
            
            wbuf_clear_legacy_ps(wbuf);
            txctl = &athwbuf->txctl;

            if (sc->sc_ath_ops.tx(sc, wbuf, txctl) != 0) {
                DPRINTF(sc, ATH_DEBUG_PWR_SAVE, "%s: send error, comple the wbuf\n", __func__);
                ath_node_pwrsaveq_complete_athwbuf(an, athwbuf);
            } else {
                if (athwbuf) {
                    OS_FREE_PS(athwbuf);
                }
            }
        }
    }
    ATH_NODE_PWRSAVEQ_UNLOCK(dataq);

    /* TIM will be set by UMAC caller */
}
Ejemplo n.º 2
0
/*
 * send one frme out of power save queue .
 * called in reponse to PS poll.
 * returns 1 if succesfully sends a frame. 0 other wise.
 */
int
ath_node_pwrsaveq_send(ath_node_t node, u_int8_t frame_type)
{
    struct ath_node *an = ATH_NODE(node);
    struct ath_softc *sc = an->an_sc;
    ath_wbuf_t athwbuf;
    wbuf_t wbuf = NULL;
    int qlen;
    struct ath_node_pwrsaveq *dataq, *mgtq;
    ieee80211_tx_control_t *txctl;
    struct ieee80211_frame *wh;
    u_int8_t more_frag;

    dataq = ATH_NODE_PWRSAVEQ_DATAQ(an); 
    mgtq  = ATH_NODE_PWRSAVEQ_MGMTQ(an); 

next_frag:

    ATH_NODE_PWRSAVEQ_LOCK(dataq);
    ATH_NODE_PWRSAVEQ_LOCK(mgtq);

    if (frame_type == IEEE80211_FC0_TYPE_MGT) {
        ATH_NODE_PWRSAVEQ_DEQUEUE(mgtq, athwbuf);
        if (athwbuf)
            wbuf = athwbuf->wbuf;
        if (wbuf && wbuf_is_pwrsaveframe(wbuf))  {
            /* ps frame (null (or) pspoll frame) */
            --mgtq->nsq_num_ps_frames;
        } 
    } else {
        ATH_NODE_PWRSAVEQ_DEQUEUE(dataq, athwbuf);
        if (athwbuf)
            wbuf = athwbuf->wbuf;
    }

    if (athwbuf == NULL || wbuf == NULL) {
        ATH_NODE_PWRSAVEQ_UNLOCK(mgtq);
        ATH_NODE_PWRSAVEQ_UNLOCK(dataq);
        return 0;
    }
        
    qlen = ATH_NODE_PWRSAVEQ_QLEN(dataq);
    qlen += ATH_NODE_PWRSAVEQ_QLEN(mgtq);

    ATH_NODE_PWRSAVEQ_UNLOCK(mgtq);
    ATH_NODE_PWRSAVEQ_UNLOCK(dataq);

    wh = (struct ieee80211_frame *)wbuf_header(wbuf);
    more_frag = wh->i_fc[1] & IEEE80211_FC1_MORE_FRAG;

    /* 
     * If there are more packets, set the more packets bit
     * in the packet dispatched to the station; otherwise
     * turn off the TIM bit.
     */
    if (qlen != 0) {
        DPRINTF(sc, ATH_DEBUG_PWR_SAVE, "send packet, %u still queued \n", qlen);
        /* 
         * encap will set more data bit.
         */
        wbuf_set_moredata(wbuf);
        if (wbuf_is_moredata(wbuf)) {
             wh->i_fc[1] |= IEEE80211_FC1_MORE_DATA;
        } 
    } else {
        DPRINTF(sc, ATH_DEBUG_PWR_SAVE, "%s", "send packet, queue empty \n");
        /* TIM bit will be set by UMAC caller */
    }

    wbuf_clear_legacy_ps(wbuf);
    txctl = &athwbuf->txctl;

    if (sc->sc_ath_ops.tx(sc, wbuf, txctl) != 0) {
        DPRINTF(sc, ATH_DEBUG_PWR_SAVE, "%s: send error, comple the wbuf\n", __func__);
        ath_node_pwrsaveq_complete_athwbuf(an, athwbuf);
        /* process all fragment together */
        if (more_frag)
            goto next_frag;

        return 0;
    }

    if (athwbuf) {
        OS_FREE_PS(athwbuf);
    }

    /* process all fragments together */
    if (more_frag)
        goto next_frag;

    return 1;
}
Ejemplo n.º 3
0
/*
 * node saveq flush.
 */
void
ieee80211_node_saveq_flush(struct ieee80211_node *ni)
{
    struct ieee80211vap *vap = ni->ni_vap;
    wbuf_t wbuf;
    struct node_powersave_queue *dataq,*mgtq;
    int dqlen, mqlen;

#if LMAC_SUPPORT_POWERSAVE_QUEUE
    struct ieee80211com *ic = ni->ni_ic;

    ic->ic_node_pwrsaveq_flush(ic, ni);
    if (vap->iv_set_tim != NULL)
        vap->iv_set_tim(ni, 0, false);
    return;
#endif

    dataq = IEEE80211_NODE_SAVEQ_DATAQ(ni);
    mgtq  = IEEE80211_NODE_SAVEQ_MGMTQ(ni);

    /* XXX if no stations in ps mode, flush mc frames */
    dqlen = IEEE80211_NODE_SAVEQ_QLEN(dataq);

    /*
     * Flush queued mgmt frames.
     */
    IEEE80211_NODE_SAVEQ_LOCK(mgtq);
    if (IEEE80211_NODE_SAVEQ_QLEN(mgtq) != 0) {
        IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni,
                       "flush mgt ps queue, %u packets queued \n",
                       IEEE80211_NODE_SAVEQ_QLEN(mgtq));
        for (;;) {

            IEEE80211_NODE_SAVEQ_DEQUEUE(mgtq, wbuf);
            if (wbuf == NULL)
                break;
            mqlen = IEEE80211_NODE_SAVEQ_QLEN(mgtq);
            /*
             * For a Station node (non bss node) If this is the last packet, turn off the TIM bit,
             * Set the PWR_SAV bit on every frame but the last one
             * to allow encap to test for
             * adding more MORE_DATA bit to wh.
             */
            if ((ni != ni->ni_bss_node) && (mqlen || dqlen)) {
                wbuf_set_moredata(wbuf);
            }
            ieee80211_send_mgmt(ni->ni_vap,ni,wbuf,false);
        }
    }
    mgtq->nsq_num_ps_frames = 0;
    IEEE80211_NODE_SAVEQ_UNLOCK(mgtq);

    /*
     * Flush queued unicast frames.
     */
    IEEE80211_NODE_SAVEQ_LOCK(dataq);
    if (IEEE80211_NODE_SAVEQ_QLEN(dataq) != 0) {
        IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni,
                       "flush data ps queue, %u packets queued \n",
                       IEEE80211_NODE_SAVEQ_QLEN(dataq));
        for (;;) {

            IEEE80211_NODE_SAVEQ_DEQUEUE(dataq, wbuf);
            if (wbuf == NULL)
                break;
            dqlen = IEEE80211_NODE_SAVEQ_QLEN(dataq);
            IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni,
                           "senddata ps queue, %u packets remaining \n", dqlen);
            /*
             * For a Station node (non bss node) If this is the last packet, turn off the TIM bit,
             * Set the PWR_SAV bit on every frame but the last one
             * to allow encap to test for
             * adding more MORE_DATA bit to wh.
             */
            if ((ni != ni->ni_bss_node) && dqlen) {
                wbuf_set_moredata(wbuf);
            }

            ieee80211_send_wbuf(vap,ni, wbuf);
        }
    }
    IEEE80211_NODE_SAVEQ_UNLOCK(dataq);

#ifdef ATH_SWRETRY
    /* also check whether there is frame in tid q */
    if (vap->iv_set_tim != NULL && (ni->ni_ic)->ic_exist_pendingfrm_tidq(ni->ni_ic, ni) !=0)
#else
    if (vap->iv_set_tim != NULL)
#endif
        vap->iv_set_tim(ni, 0, false);
}
Ejemplo n.º 4
0
/*
 * send one frme out of power save queue .
 * called in reponse to PS poll.
 * returns 1 if succesfully sends a frame. 0 other wise.
 */
int
ieee80211_node_saveq_send(struct ieee80211_node *ni, int frame_type)
{
    struct ieee80211vap *vap = ni->ni_vap;
    wbuf_t wbuf;
    int qlen;
    struct node_powersave_queue *dataq,*mgtq;

    /*
     * do not send any frames if the vap is paused.
     * wait until the vap is unpaused.
     */
    if (ieee80211_vap_is_paused(vap)) return 0;

    dataq = IEEE80211_NODE_SAVEQ_DATAQ(ni);
    mgtq  = IEEE80211_NODE_SAVEQ_MGMTQ(ni);

    IEEE80211_NODE_SAVEQ_LOCK(dataq);
    IEEE80211_NODE_SAVEQ_LOCK(mgtq);

    if (frame_type == IEEE80211_FC0_TYPE_MGT) {
        IEEE80211_NODE_SAVEQ_DEQUEUE(mgtq, wbuf);
        if (wbuf && wbuf_is_pwrsaveframe(wbuf))  {
            /* ps frame (null (or) pspoll frame) */
            --mgtq->nsq_num_ps_frames;
        }
    } else {
        IEEE80211_NODE_SAVEQ_DEQUEUE(dataq, wbuf);
    }

    if (wbuf == NULL) {
        IEEE80211_NODE_SAVEQ_UNLOCK(mgtq);
        IEEE80211_NODE_SAVEQ_UNLOCK(dataq);
        return 0;
    }

    qlen = IEEE80211_NODE_SAVEQ_QLEN(dataq);
    qlen += IEEE80211_NODE_SAVEQ_QLEN(mgtq);

    IEEE80211_NODE_SAVEQ_UNLOCK(mgtq);
    IEEE80211_NODE_SAVEQ_UNLOCK(dataq);
    /*
     * If there are more packets, set the more packets bit
     * in the packet dispatched to the station; otherwise
     * turn off the TIM bit.
     */
    if (qlen != 0) {
        IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni,
                       "send packet, %u still queued \n", qlen);
        /*
         * encap will set more data bit.
         */
        wbuf_set_moredata(wbuf);
    } else {
        IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni,
                       "%s", "send packet, queue empty \n");
#ifdef ATH_SWRETRY
        /* also check whether there is frame in tid q */
        if (vap->iv_set_tim != NULL && (ni->ni_ic)->ic_exist_pendingfrm_tidq(ni->ni_ic, ni) !=0)
#else
        if (vap->iv_set_tim != NULL)
#endif
            vap->iv_set_tim(ni, 0, false);
    }

    if (frame_type == IEEE80211_FC0_TYPE_MGT) {
        /* send the management frame down to the ath  */
        ieee80211_send_mgmt(vap,ni,wbuf,true);
    } else {
        /* send the data down to the ath  */
        ieee80211_send_wbuf(vap,ni,wbuf);
    }

    return 1;

}
Ejemplo n.º 5
0
/*
 * node saveq flush.
 */
void
ieee80211_node_saveq_flush(struct ieee80211_node *ni)
{
    struct ieee80211vap *vap = ni->ni_vap;
    wbuf_t wbuf;
    struct node_powersave_queue *dataq,*mgtq;
    int dqlen, mqlen;

    dataq = IEEE80211_NODE_SAVEQ_DATAQ(ni); 
    mgtq  = IEEE80211_NODE_SAVEQ_MGMTQ(ni); 

    /* XXX if no stations in ps mode, flush mc frames */
    dqlen = IEEE80211_NODE_SAVEQ_QLEN(dataq);

    /*
	 * Flush queued mgmt frames.
	 */
    IEEE80211_NODE_SAVEQ_LOCK(mgtq);
	if (IEEE80211_NODE_SAVEQ_QLEN(mgtq) != 0) {
		IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni,
		    "flush mgt ps queue, %u packets queued \n",
                       IEEE80211_NODE_SAVEQ_QLEN(mgtq));
		for (;;) {

			IEEE80211_NODE_SAVEQ_DEQUEUE(mgtq, wbuf);
			if (wbuf == NULL)
				break;
            mqlen = IEEE80211_NODE_SAVEQ_QLEN(mgtq);
			/*
			 * For a Station node (non bss node) If this is the last packet, turn off the TIM bit,
             * Set the PWR_SAV bit on every frame but the last one
             * to allow encap to test for
             * adding more MORE_DATA bit to wh.
			 */
            if ((ni != ni->ni_bss_node) && (mqlen || dqlen)) {
                wbuf_set_moredata(wbuf);
            }
            /* force send management frame so that the frames will not loop back into the save queue again */
            ieee80211_send_mgmt(ni->ni_vap,ni,wbuf,true);
		}
	}
    mgtq->nsq_num_ps_frames = 0;
    IEEE80211_NODE_SAVEQ_UNLOCK(mgtq);

	/*
     * Flush queued unicast frames.
     */
    IEEE80211_NODE_SAVEQ_LOCK(dataq);
    if (IEEE80211_NODE_SAVEQ_QLEN(dataq) != 0) {
        IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni,
            "flush data ps queue, %u packets queued \n",
            IEEE80211_NODE_SAVEQ_QLEN(dataq));
        for (;;) {

            IEEE80211_NODE_SAVEQ_DEQUEUE(dataq, wbuf);
            if (wbuf == NULL)
                break;
            dqlen = IEEE80211_NODE_SAVEQ_QLEN(dataq);
            IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni,
                           "senddata ps queue, %u packets remaining \n", dqlen);
            /*
             * For a Station node (non bss node) If this is the last packet, turn off the TIM bit,
             * Set the PWR_SAV bit on every frame but the last one
             * to allow encap to test for
             * adding more MORE_DATA bit to wh.
             */
            if ((ni != ni->ni_bss_node) && dqlen) {
                wbuf_set_moredata(wbuf);
            }
            
            ieee80211_send_wbuf(vap,ni, wbuf); 
        }
    }
    IEEE80211_NODE_SAVEQ_UNLOCK(dataq);

    if (vap->iv_set_tim != NULL)
        vap->iv_set_tim(ni, 0);
}