Sync w/ FreeBSD-current-980122:

- Rewrite fxp_start() for better clarity and efficiency.
- Remove unused #includes.
This commit is contained in:
thorpej 1998-01-22 08:31:33 +00:00
parent a1de770ebd
commit 0916ab379b

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_fxp.c,v 1.8 1998/01/22 08:04:56 thorpej Exp $ */
/* $NetBSD: if_fxp.c,v 1.9 1998/01/22 08:31:33 thorpej Exp $ */
/*
* Copyright (c) 1995, David Greenman
@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Id: if_fxp.c,v 1.44 1997/10/17 06:27:44 davidg Exp
* Id: if_fxp.c,v 1.47 1998/01/08 23:42:29 eivind Exp
*/
/*
@ -37,6 +37,9 @@
*/
#include "bpfilter.h"
#if !defined(__NetBSD__)
#include "opt_inet.h"
#endif
#include <sys/param.h>
#include <sys/systm.h>
@ -44,7 +47,6 @@
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <sys/socket.h>
#include <sys/syslog.h>
#include <net/if.h>
#include <net/if_dl.h>
@ -96,7 +98,12 @@
#include <sys/sockio.h>
#include <net/ethernet.h>
#include <net/if_arp.h>
#ifdef INET
#include <netinet/if_ether.h>
#endif
#include <vm/vm.h> /* for vtophys */
#include <vm/pmap.h> /* for vtophys */
@ -420,6 +427,10 @@ fxp_attach(parent, self, aux)
* Attach the interface.
*/
if_attach(ifp);
/*
* Let the system queue as many packets as we have TX descriptors.
*/
ifp->if_snd.ifq_maxlen = FXP_NTXCB;
ether_ifattach(ifp, enaddr);
#if NBPFILTER > 0
bpfattach(&sc->sc_ethercom.ec_if.if_bpf, ifp, DLT_EN10MB,
@ -588,6 +599,10 @@ fxp_attach(config_id, unit)
* Attach the interface.
*/
if_attach(ifp);
/*
* Let the system queue as many packets as we have TX descriptors.
*/
ifp->if_snd.ifq_maxlen = FXP_NTXCB;
ether_ifattach(ifp);
#if NBPFILTER > 0
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
@ -803,38 +818,38 @@ fxp_start(ifp)
{
struct fxp_softc *sc = ifp->if_softc;
struct fxp_cb_tx *txp;
struct mbuf *m, *mb_head;
int segment, first = 1;
txloop:
/*
* See if we're all filled up with buffers to transmit, or
* if we need to suspend xmit until the multicast filter
* has been reprogrammed (which can only be done at the
* head of the command chain).
* See if we need to suspend xmit until the multicast filter
* has been reprogrammed (which can only be done at the head
* of the command chain).
*/
if (sc->tx_queued >= FXP_NTXCB || sc->need_mcsetup)
if (sc->need_mcsetup)
return;
txp = NULL;
/*
* We're finished if there is nothing more to add to the list or if
* we're all filled up with buffers to transmit.
*/
while (ifp->if_snd.ifq_head != NULL && sc->tx_queued < FXP_NTXCB) {
struct mbuf *m, *mb_head;
int segment;
/*
* Grab a packet to transmit.
*/
IF_DEQUEUE(&ifp->if_snd, mb_head);
if (mb_head == NULL) {
/*
* No more packets to send.
*/
return;
}
/*
* Get pointer to next available (unused) descriptor.
* Get pointer to next available tx desc.
*/
txp = sc->cbl_last->next;
/*
* Go through each of the mbufs in the chain and initialize
* the transmit buffers descriptors with the physical address
* the transmit buffer descriptors with the physical address
* and size of the mbuf.
*/
tbdinit:
@ -853,19 +868,20 @@ tbdinit:
/*
* We ran out of segments. We have to recopy this mbuf
* chain first.
* chain first. Bail out if we can't get the new
* buffers.
*/
MGETHDR(mn, M_DONTWAIT, MT_DATA);
if (mn == NULL) {
m_freem(mb_head);
return;
break;
}
if (mb_head->m_pkthdr.len > MHLEN) {
MCLGET(mn, M_DONTWAIT);
if ((mn->m_flags & M_EXT) == 0) {
m_freem(mn);
m_freem(mb_head);
return;
break;
}
}
m_copydata(mb_head, 0, mb_head->m_pkthdr.len,
@ -878,17 +894,13 @@ tbdinit:
txp->tbd_number = segment;
txp->mb_head = mb_head;
/*
* Finish the initialization of this TxCB.
*/
txp->cb_status = 0;
txp->cb_command =
FXP_CB_COMMAND_XMIT | FXP_CB_COMMAND_SF | FXP_CB_COMMAND_S;
txp->tx_threshold = tx_threshold;
/*
* Advance the end-of-list forward.
* Advance the end of list forward.
*/
sc->cbl_last->cb_command &= ~FXP_CB_COMMAND_S;
sc->cbl_last = txp;
@ -896,26 +908,13 @@ tbdinit:
/*
* Advance the beginning of the list forward if there are
* no other packets queued (when nothing is queued, cbl_first
* sits on the last TxCB that was sent out)..
* sits on the last TxCB that was sent out).
*/
if (sc->tx_queued == 0)
sc->cbl_first = txp;
sc->tx_queued++;
/*
* Only need to wait prior to the first resume command.
*/
if (first) {
first--;
fxp_scb_wait(sc);
}
/*
* Resume transmission if suspended.
*/
CSR_WRITE_1(sc, FXP_CSR_SCB_COMMAND, FXP_SCB_COMMAND_CU_RESUME);
#if NBPFILTER > 0
/*
* Pass packet to bpf if there is a listener.
@ -923,13 +922,22 @@ tbdinit:
if (ifp->if_bpf)
bpf_mtap(FXP_BPFTAP_ARG(ifp), mb_head);
#endif
}
/*
* We're finished. If we added to the list, issue a RESUME to get DMA
* going again if suspended.
*/
if (txp != NULL) {
fxp_scb_wait(sc);
CSR_WRITE_1(sc, FXP_CSR_SCB_COMMAND, FXP_SCB_COMMAND_CU_RESUME);
/*
* Set a 5 second timer just in case we don't hear from the
* card again.
*/
ifp->if_timer = 5;
goto txloop;
}
}
/*