Second part of ALTQ driver modifications, covering:

an(4), ath(4), hme(4), ndis(4), vr(4) and wi(4)

Please help testing: http://people.freebsd.org/~mlaier/ALTQ_driver/

Tested by:	Vaidas Damosevicius (an, ath, wi)
		Roman Divacky (vr)
Submitted by:	yongari (hme)
This commit is contained in:
Max Laier 2004-08-01 23:58:04 +00:00
parent 6e0fbb01c5
commit 154b8df2ed
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=132986
7 changed files with 56 additions and 31 deletions

View File

@ -760,7 +760,9 @@ an_attach(sc, unit, flags)
ifp->if_watchdog = an_watchdog;
ifp->if_init = an_init;
ifp->if_baudrate = 10000000;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
IFQ_SET_READY(&ifp->if_snd);
bzero(sc->an_config.an_nodename, sizeof(sc->an_config.an_nodename));
bcopy(AN_DEFAULT_NODENAME, sc->an_config.an_nodename,
@ -1254,7 +1256,7 @@ an_intr(xsc)
/* Re-enable interrupts. */
CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), AN_INTRS(sc->mpi350));
if ((ifp->if_flags & IFF_UP) && (ifp->if_snd.ifq_head != NULL))
if ((ifp->if_flags & IFF_UP) && !IFQ_DRV_IS_EMPTY(&ifp->if_snd))
an_start(ifp);
AN_UNLOCK(sc);
@ -2655,7 +2657,7 @@ an_start(ifp)
/* We can't send in monitor mode so toss any attempts. */
if (sc->an_monitor && (ifp->if_flags & IFF_PROMISC)) {
for (;;) {
IF_DEQUEUE(&ifp->if_snd, m0);
IFQ_DRV_DEQUEUE(&ifp->if_snd, m0);
if (m0 == NULL)
break;
m_freem(m0);
@ -2669,7 +2671,7 @@ an_start(ifp)
bzero((char *)&tx_frame_802_3, sizeof(tx_frame_802_3));
while (sc->an_rdata.an_tx_ring[idx] == 0) {
IF_DEQUEUE(&ifp->if_snd, m0);
IFQ_DRV_DEQUEUE(&ifp->if_snd, m0);
if (m0 == NULL)
break;
@ -2730,7 +2732,7 @@ an_start(ifp)
while (sc->an_rdata.an_tx_empty ||
idx != sc->an_rdata.an_tx_cons) {
IF_DEQUEUE(&ifp->if_snd, m0);
IFQ_DRV_DEQUEUE(&ifp->if_snd, m0);
if (m0 == NULL) {
break;
}

View File

@ -304,7 +304,9 @@ ath_attach(u_int16_t devid, struct ath_softc *sc)
ifp->if_watchdog = ath_watchdog;
ifp->if_ioctl = ath_ioctl;
ifp->if_init = ath_init;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
IFQ_SET_READY(&ifp->if_snd);
ic->ic_softc = sc;
ic->ic_newassoc = ath_newassoc;
@ -662,7 +664,7 @@ ath_stop(struct ifnet *ifp)
ath_stoprecv(sc);
else
sc->sc_rxlink = NULL;
IF_DRAIN(&ifp->if_snd);
IFQ_DRV_PURGE(&ifp->if_snd);
ath_beacon_free(sc);
ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
if (!sc->sc_invalid)
@ -759,7 +761,7 @@ ath_start(struct ifnet *ifp)
ATH_TXBUF_UNLOCK(sc);
break;
}
IF_DEQUEUE(&ifp->if_snd, m);
IFQ_DRV_DEQUEUE(&ifp->if_snd, m); /* XXX: LOCK */
if (m == NULL) {
ATH_TXBUF_LOCK(sc);
TAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list);

View File

@ -276,7 +276,9 @@ hme_config(struct hme_softc *sc)
ifp->if_ioctl = hme_ioctl;
ifp->if_init = hme_init;
ifp->if_watchdog = hme_watchdog;
ifp->if_snd.ifq_maxlen = HME_NTXQ;
IFQ_SET_MAXLEN(&ifp->if_snd, HME_NTXQ);
ifp->if_snd.ifq_drv_maxlen = HME_NTXQ;
IFQ_SET_READY(&ifp->if_snd);
hme_mifinit(sc);
@ -1002,14 +1004,14 @@ hme_start(struct ifnet *ifp)
error = 0;
for (;;) {
IF_DEQUEUE(&ifp->if_snd, m);
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
if (m == NULL)
break;
error = hme_load_txmbuf(sc, m);
if (error == -1) {
ifp->if_flags |= IFF_OACTIVE;
IF_PREPEND(&ifp->if_snd, m);
IFQ_DRV_PREPEND(&ifp->if_snd, m);
break;
} else if (error > 0) {
printf("hme_start: error %d while loading mbuf\n",

View File

@ -490,7 +490,13 @@ ndis_attach(dev)
ifp->if_watchdog = ndis_watchdog;
ifp->if_init = ndis_init;
ifp->if_baudrate = 10000000;
#if __FreeBSD_version < 502114
ifp->if_snd.ifq_maxlen = 50;
#else
IFQ_SET_MAXLEN(&ifp->if_snd, 50);
ifp->if_snd.ifq_drv_maxlen = 25;
IFQ_SET_READY(&ifp->if_snd);
#endif
ifp->if_capenable = ifp->if_capabilities;
ifp->if_hwassist = sc->ndis_hwassist;
@ -1151,7 +1157,11 @@ ndis_starttask(arg)
struct ifnet *ifp;
ifp = arg;
#if __FreeBSD_version < 502114
if (ifp->if_snd.ifq_head != NULL)
#else
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
#endif
ndis_start(ifp);
return;
}
@ -1191,15 +1201,24 @@ ndis_start(ifp)
p0 = &sc->ndis_txarray[sc->ndis_txidx];
while(sc->ndis_txpending) {
#if __FreeBSD_version < 502114
IF_DEQUEUE(&ifp->if_snd, m);
#else
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
#endif
if (m == NULL)
break;
sc->ndis_txarray[sc->ndis_txidx] = NULL;
if (ndis_mtop(m, &sc->ndis_txarray[sc->ndis_txidx])) {
#if __FreeBSD_version >= 502114
IFQ_DRV_PREPEND(&ifp->if_snd, m);
#endif
NDIS_UNLOCK(sc);
#if __FreeBSD_version < 502114
IF_PREPEND(&ifp->if_snd, m);
#endif
return;
}

View File

@ -736,7 +736,9 @@ vr_attach(dev)
ifp->if_watchdog = vr_watchdog;
ifp->if_init = vr_init;
ifp->if_baudrate = 10000000;
IFQ_SET_MAXLEN(&ifp->if_snd, VR_TX_LIST_CNT - 1);
ifp->if_snd.ifq_maxlen = VR_TX_LIST_CNT - 1;
IFQ_SET_READY(&ifp->if_snd);
#ifdef DEVICE_POLLING
ifp->if_capabilities |= IFCAP_POLLING;
#endif
@ -1167,7 +1169,7 @@ vr_poll_locked(struct ifnet *ifp, enum poll_cmd cmd, int count)
sc->rxcycles = count;
vr_rxeof(sc);
vr_txeof(sc);
if (ifp->if_snd.ifq_head != NULL)
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) {
vr_start_locked(ifp);
if (cmd == POLL_AND_CHECK_STATUS) {
@ -1310,7 +1312,7 @@ vr_intr(void *arg)
/* Re-enable interrupts. */
CSR_WRITE_2(sc, VR_IMR, VR_INTRS);
if (_IF_QLEN(&ifp->if_snd) != 0)
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
vr_start_locked(ifp);
done_locked:
@ -1389,14 +1391,14 @@ vr_start_locked(struct ifnet *ifp)
cur_tx = sc->vr_cdata.vr_tx_prod;
while (cur_tx->vr_mbuf == NULL) {
IF_DEQUEUE(&ifp->if_snd, m_head);
IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head);
if (m_head == NULL)
break;
/* Pack the data into the descriptor. */
if (vr_encap(sc, cur_tx, m_head)) {
/* Rollback, send what we were able to encap. */
IF_PREPEND(&ifp->if_snd, m_head);
IFQ_DRV_PREPEND(&ifp->if_snd, m_head);
break;
}
@ -1621,7 +1623,7 @@ vr_watchdog(struct ifnet *ifp)
vr_reset(sc);
vr_init_locked(sc);
if (ifp->if_snd.ifq_head != NULL)
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
vr_start_locked(ifp);
VR_UNLOCK(sc);

View File

@ -114,12 +114,6 @@ __FBSDID("$FreeBSD$");
#include <dev/wi/if_wireg.h>
#include <dev/wi/if_wivar.h>
#if 0 /* ALTQ */
#define IF_POLL(ifq, m) ((m) = (ifq)->ifq_head)
#define IFQ_POLL(ifq, m) IF_POLL((ifq), (m))
#define IFQ_DEQUEUE(ifq, m) IF_DEQUEUE((ifq), (m))
#endif
static void wi_start(struct ifnet *);
static int wi_reset(struct wi_softc *);
static void wi_watchdog(struct ifnet *);
@ -308,7 +302,9 @@ wi_attach(device_t dev)
ifp->if_start = wi_start;
ifp->if_watchdog = wi_watchdog;
ifp->if_init = wi_init;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
IFQ_SET_READY(&ifp->if_snd);
ic->ic_phytype = IEEE80211_T_DS;
ic->ic_opmode = IEEE80211_M_STA;
@ -616,7 +612,7 @@ wi_intr(void *arg)
wi_info_intr(sc);
if ((ifp->if_flags & IFF_OACTIVE) == 0 &&
(sc->sc_flags & WI_FLAGS_OUTRANGE) == 0 &&
_IF_QLEN(&ifp->if_snd) != 0)
!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
wi_start(ifp);
/* Re-enable interrupts. */
@ -906,14 +902,14 @@ wi_start(struct ifnet *ifp)
} else {
if (ic->ic_state != IEEE80211_S_RUN)
break;
IFQ_POLL(&ifp->if_snd, m0);
IFQ_DRV_DEQUEUE(&ifp->if_snd, m0);
if (m0 == NULL)
break;
if (sc->sc_txd[cur].d_len != 0) {
IFQ_DRV_PREPEND(&ifp->if_snd, m0);
ifp->if_flags |= IFF_OACTIVE;
break;
}
IFQ_DEQUEUE(&ifp->if_snd, m0);
ifp->if_opackets++;
m_copydata(m0, 0, ETHER_HDR_LEN,
(caddr_t)&frmhdr.wi_ehdr);

View File

@ -736,7 +736,9 @@ vr_attach(dev)
ifp->if_watchdog = vr_watchdog;
ifp->if_init = vr_init;
ifp->if_baudrate = 10000000;
IFQ_SET_MAXLEN(&ifp->if_snd, VR_TX_LIST_CNT - 1);
ifp->if_snd.ifq_maxlen = VR_TX_LIST_CNT - 1;
IFQ_SET_READY(&ifp->if_snd);
#ifdef DEVICE_POLLING
ifp->if_capabilities |= IFCAP_POLLING;
#endif
@ -1167,7 +1169,7 @@ vr_poll_locked(struct ifnet *ifp, enum poll_cmd cmd, int count)
sc->rxcycles = count;
vr_rxeof(sc);
vr_txeof(sc);
if (ifp->if_snd.ifq_head != NULL)
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) {
vr_start_locked(ifp);
if (cmd == POLL_AND_CHECK_STATUS) {
@ -1310,7 +1312,7 @@ vr_intr(void *arg)
/* Re-enable interrupts. */
CSR_WRITE_2(sc, VR_IMR, VR_INTRS);
if (_IF_QLEN(&ifp->if_snd) != 0)
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
vr_start_locked(ifp);
done_locked:
@ -1389,14 +1391,14 @@ vr_start_locked(struct ifnet *ifp)
cur_tx = sc->vr_cdata.vr_tx_prod;
while (cur_tx->vr_mbuf == NULL) {
IF_DEQUEUE(&ifp->if_snd, m_head);
IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head);
if (m_head == NULL)
break;
/* Pack the data into the descriptor. */
if (vr_encap(sc, cur_tx, m_head)) {
/* Rollback, send what we were able to encap. */
IF_PREPEND(&ifp->if_snd, m_head);
IFQ_DRV_PREPEND(&ifp->if_snd, m_head);
break;
}
@ -1621,7 +1623,7 @@ vr_watchdog(struct ifnet *ifp)
vr_reset(sc);
vr_init_locked(sc);
if (ifp->if_snd.ifq_head != NULL)
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
vr_start_locked(ifp);
VR_UNLOCK(sc);