1995-01-25 03:50:33 +00:00
|
|
|
/*-
|
2000-03-20 00:53:46 +00:00
|
|
|
* Copyright (c) 1994-2000
|
1995-01-25 03:50:33 +00:00
|
|
|
* Paul Richards. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
1995-05-30 08:16:23 +00:00
|
|
|
* notice, this list of conditions and the following disclaimer,
|
|
|
|
* verbatim and that no modifications are made prior to this
|
1995-01-25 03:50:33 +00:00
|
|
|
* point in the file.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2000-03-20 00:53:46 +00:00
|
|
|
* 3. The name Paul Richards may not be used to endorse or promote products
|
1995-01-25 03:50:33 +00:00
|
|
|
* derived from this software without specific prior written permission.
|
1994-10-02 21:14:38 +00:00
|
|
|
*
|
1995-01-25 03:50:33 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY PAUL RICHARDS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL PAUL RICHARDS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
1994-10-02 21:14:38 +00:00
|
|
|
*/
|
|
|
|
|
2003-08-24 17:55:58 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2000-12-16 03:29:27 +00:00
|
|
|
/*
|
1994-10-02 21:14:38 +00:00
|
|
|
#define DIAGNOSTIC
|
|
|
|
#define DEBUG
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1994-10-02 21:14:38 +00:00
|
|
|
* TODO ----
|
|
|
|
*
|
|
|
|
* Check all the XXX comments -- some of them are just things I've left
|
|
|
|
* unfinished rather than "difficult" problems that were hacked around.
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1994-10-02 21:14:38 +00:00
|
|
|
* Check log settings.
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1994-10-02 21:14:38 +00:00
|
|
|
* Check how all the arpcom flags get set and used.
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1994-10-02 21:14:38 +00:00
|
|
|
* Re-inline and re-static all routines after debugging.
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1994-10-02 21:14:38 +00:00
|
|
|
* Remember to assign iobase in SHMEM probe routines.
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1994-10-02 21:14:38 +00:00
|
|
|
* Replace all occurences of LANCE-controller-card etc in prints by the name
|
|
|
|
* strings of the appropriate type -- nifty window dressing
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
|
|
|
* Add DEPCA support -- mostly done.
|
|
|
|
*
|
1994-10-02 21:14:38 +00:00
|
|
|
*/
|
|
|
|
|
1998-01-08 23:42:31 +00:00
|
|
|
#include "opt_inet.h"
|
1994-10-02 21:14:38 +00:00
|
|
|
|
|
|
|
/* Some defines that should really be in generic locations */
|
|
|
|
#define FCS_LEN 4
|
1996-01-05 19:12:47 +00:00
|
|
|
#define MULTICAST_FILTER_LEN 8
|
1994-10-02 21:14:38 +00:00
|
|
|
|
1994-10-19 01:59:11 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2000-12-16 01:33:28 +00:00
|
|
|
#include <sys/bus.h>
|
2000-05-28 13:40:48 +00:00
|
|
|
#include <sys/kernel.h>
|
1996-07-19 17:18:20 +00:00
|
|
|
#include <sys/malloc.h>
|
1994-10-19 01:59:11 +00:00
|
|
|
#include <sys/mbuf.h>
|
2000-12-16 01:33:28 +00:00
|
|
|
#include <sys/module.h>
|
1994-10-19 01:59:11 +00:00
|
|
|
#include <sys/socket.h>
|
2000-12-16 01:33:28 +00:00
|
|
|
#include <sys/sockio.h>
|
1994-10-19 01:59:11 +00:00
|
|
|
#include <sys/syslog.h>
|
2000-12-16 01:33:28 +00:00
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
#include <sys/rman.h>
|
1994-10-19 01:59:11 +00:00
|
|
|
|
1999-08-18 22:14:24 +00:00
|
|
|
#include <net/ethernet.h>
|
1994-10-19 01:59:11 +00:00
|
|
|
#include <net/if.h>
|
1999-01-31 00:39:20 +00:00
|
|
|
#include <net/if_dl.h>
|
1994-10-19 01:59:11 +00:00
|
|
|
#include <net/if_types.h>
|
1994-10-02 21:14:38 +00:00
|
|
|
|
1999-08-18 22:14:24 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/if_ether.h>
|
|
|
|
|
1994-10-19 01:59:11 +00:00
|
|
|
#include <net/bpf.h>
|
1994-10-02 21:14:38 +00:00
|
|
|
|
1996-06-25 20:31:01 +00:00
|
|
|
#include <machine/md_var.h>
|
|
|
|
|
2000-05-14 18:21:39 +00:00
|
|
|
#include <dev/lnc/if_lncvar.h>
|
2000-05-14 19:14:41 +00:00
|
|
|
#include <dev/lnc/if_lncreg.h>
|
1994-10-02 21:14:38 +00:00
|
|
|
|
2000-12-29 11:59:41 +00:00
|
|
|
devclass_t lnc_devclass;
|
|
|
|
|
1996-09-14 01:26:16 +00:00
|
|
|
static char const * const nic_ident[] = {
|
|
|
|
"Unknown",
|
|
|
|
"BICC",
|
|
|
|
"NE2100",
|
|
|
|
"DEPCA",
|
1998-02-10 03:22:20 +00:00
|
|
|
"CNET98S", /* PC-98 */
|
1996-09-14 01:26:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static char const * const ic_ident[] = {
|
|
|
|
"Unknown",
|
|
|
|
"LANCE",
|
|
|
|
"C-LANCE",
|
|
|
|
"PCnet-ISA",
|
|
|
|
"PCnet-ISA+",
|
1998-09-17 13:09:16 +00:00
|
|
|
"PCnet-ISA II",
|
1996-09-14 01:26:16 +00:00
|
|
|
"PCnet-32 VL-Bus",
|
1998-09-17 13:09:16 +00:00
|
|
|
"PCnet-PCI",
|
|
|
|
"PCnet-PCI II",
|
|
|
|
"PCnet-FAST",
|
|
|
|
"PCnet-FAST+",
|
1999-08-10 01:03:51 +00:00
|
|
|
"PCnet-Home",
|
1996-09-14 01:26:16 +00:00
|
|
|
};
|
1994-10-02 21:14:38 +00:00
|
|
|
|
2002-03-20 02:08:01 +00:00
|
|
|
static void lnc_setladrf(struct lnc_softc *sc);
|
|
|
|
static void lnc_reset(struct lnc_softc *sc);
|
|
|
|
static void lnc_free_mbufs(struct lnc_softc *sc);
|
|
|
|
static __inline int alloc_mbuf_cluster(struct lnc_softc *sc,
|
|
|
|
struct host_ring_entry *desc);
|
|
|
|
static __inline struct mbuf *chain_mbufs(struct lnc_softc *sc,
|
1998-04-15 17:47:40 +00:00
|
|
|
int start_of_packet,
|
2002-03-20 02:08:01 +00:00
|
|
|
int pkt_len);
|
|
|
|
static __inline struct mbuf *mbuf_packet(struct lnc_softc *sc,
|
1998-04-15 17:47:40 +00:00
|
|
|
int start_of_packet,
|
2002-03-20 02:08:01 +00:00
|
|
|
int pkt_len);
|
2003-07-22 09:22:00 +00:00
|
|
|
static void lnc_rint(struct lnc_softc *sc);
|
|
|
|
static void lnc_tint(struct lnc_softc *sc);
|
2002-03-20 02:08:01 +00:00
|
|
|
|
|
|
|
static void lnc_init(void *);
|
|
|
|
static __inline int mbuf_to_buffer(struct mbuf *m, char *buffer);
|
|
|
|
static __inline struct mbuf *chain_to_cluster(struct mbuf *m);
|
|
|
|
static void lnc_start(struct ifnet *ifp);
|
|
|
|
static int lnc_ioctl(struct ifnet *ifp, u_long command, caddr_t data);
|
|
|
|
static void lnc_watchdog(struct ifnet *ifp);
|
1995-10-31 18:41:49 +00:00
|
|
|
#ifdef DEBUG
|
2002-03-20 02:08:01 +00:00
|
|
|
void lnc_dump_state(struct lnc_softc *sc);
|
|
|
|
void mbuf_dump_chain(struct mbuf *m);
|
1995-12-15 00:54:32 +00:00
|
|
|
#endif
|
1994-10-02 21:14:38 +00:00
|
|
|
|
2000-12-16 01:33:28 +00:00
|
|
|
u_short
|
|
|
|
read_csr(struct lnc_softc *sc, u_short port)
|
|
|
|
{
|
2001-07-04 13:00:21 +00:00
|
|
|
lnc_outw(sc->rap, port);
|
|
|
|
return (lnc_inw(sc->rdp));
|
2000-12-16 01:33:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
write_csr(struct lnc_softc *sc, u_short port, u_short val)
|
|
|
|
{
|
2001-07-04 13:00:21 +00:00
|
|
|
lnc_outw(sc->rap, port);
|
|
|
|
lnc_outw(sc->rdp, val);
|
2000-12-16 01:33:28 +00:00
|
|
|
}
|
|
|
|
|
1998-09-17 13:09:16 +00:00
|
|
|
static __inline void
|
2000-12-16 01:33:28 +00:00
|
|
|
write_bcr(struct lnc_softc *sc, u_short port, u_short val)
|
1998-09-17 13:09:16 +00:00
|
|
|
{
|
2001-07-04 13:00:21 +00:00
|
|
|
lnc_outw(sc->rap, port);
|
|
|
|
lnc_outw(sc->bdp, val);
|
1998-09-17 13:09:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline u_short
|
2000-12-16 01:33:28 +00:00
|
|
|
read_bcr(struct lnc_softc *sc, u_short port)
|
1998-09-17 13:09:16 +00:00
|
|
|
{
|
2001-07-04 13:00:21 +00:00
|
|
|
lnc_outw(sc->rap, port);
|
|
|
|
return (lnc_inw(sc->bdp));
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
lance_probe(struct lnc_softc *sc)
|
|
|
|
{
|
|
|
|
write_csr(sc, CSR0, STOP);
|
|
|
|
|
|
|
|
if ((lnc_inw(sc->rdp) & STOP) && ! (read_csr(sc, CSR3))) {
|
|
|
|
/*
|
|
|
|
* Check to see if it's a C-LANCE. For the LANCE the INEA bit
|
|
|
|
* cannot be set while the STOP bit is. This restriction is
|
|
|
|
* removed for the C-LANCE.
|
|
|
|
*/
|
|
|
|
write_csr(sc, CSR0, INEA);
|
|
|
|
if (read_csr(sc, CSR0) & INEA)
|
|
|
|
return (C_LANCE);
|
|
|
|
else
|
|
|
|
return (LANCE);
|
|
|
|
} else
|
|
|
|
return (UNKNOWN);
|
1998-09-17 13:09:16 +00:00
|
|
|
}
|
|
|
|
|
2000-12-16 01:33:28 +00:00
|
|
|
void
|
|
|
|
lnc_release_resources(device_t dev)
|
|
|
|
{
|
|
|
|
lnc_softc_t *sc = device_get_softc(dev);
|
|
|
|
|
|
|
|
if (sc->irqres) {
|
|
|
|
bus_teardown_intr(dev, sc->irqres, sc->intrhand);
|
|
|
|
bus_release_resource(dev, SYS_RES_IRQ, sc->irqrid, sc->irqres);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sc->portres)
|
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT,
|
|
|
|
sc->portrid, sc->portres);
|
|
|
|
if (sc->drqres)
|
|
|
|
bus_release_resource(dev, SYS_RES_DRQ, sc->drqrid, sc->drqres);
|
|
|
|
|
|
|
|
if (sc->dmat) {
|
|
|
|
if (sc->dmamap) {
|
|
|
|
bus_dmamap_unload(sc->dmat, sc->dmamap);
|
|
|
|
bus_dmamem_free(sc->dmat, sc->recv_ring, sc->dmamap);
|
|
|
|
}
|
|
|
|
bus_dma_tag_destroy(sc->dmat);
|
|
|
|
}
|
2005-10-09 04:18:18 +00:00
|
|
|
|
|
|
|
if (sc->ifp)
|
|
|
|
if_free(sc->ifp);
|
2000-12-16 01:33:28 +00:00
|
|
|
}
|
|
|
|
|
1996-01-05 19:12:47 +00:00
|
|
|
/*
|
|
|
|
* Set up the logical address filter for multicast packets
|
|
|
|
*/
|
1999-01-31 00:39:20 +00:00
|
|
|
static __inline void
|
2000-12-16 01:33:28 +00:00
|
|
|
lnc_setladrf(struct lnc_softc *sc)
|
1994-10-02 21:14:38 +00:00
|
|
|
{
|
2005-06-10 16:49:24 +00:00
|
|
|
struct ifnet *ifp = sc->ifp;
|
1997-01-13 21:26:53 +00:00
|
|
|
struct ifmultiaddr *ifma;
|
1996-01-05 19:12:47 +00:00
|
|
|
u_long index;
|
|
|
|
int i;
|
1994-10-02 21:14:38 +00:00
|
|
|
|
1999-01-31 00:39:20 +00:00
|
|
|
if (sc->flags & IFF_ALLMULTI) {
|
|
|
|
for (i=0; i < MULTICAST_FILTER_LEN; i++)
|
|
|
|
sc->init_block->ladrf[i] = 0xFF;
|
|
|
|
return;
|
|
|
|
}
|
1996-01-05 19:12:47 +00:00
|
|
|
|
1999-01-31 00:39:20 +00:00
|
|
|
/*
|
|
|
|
* For each multicast address, calculate a crc for that address and
|
|
|
|
* then use the high order 6 bits of the crc as a hash code where
|
|
|
|
* bits 3-5 select the byte of the address filter and bits 0-2 select
|
|
|
|
* the bit within that byte.
|
|
|
|
*/
|
1996-01-05 19:12:47 +00:00
|
|
|
|
|
|
|
bzero(sc->init_block->ladrf, MULTICAST_FILTER_LEN);
|
2005-08-24 16:50:46 +00:00
|
|
|
IF_ADDR_LOCK(ifp);
|
2001-02-06 10:12:15 +00:00
|
|
|
TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
|
1997-01-13 21:26:53 +00:00
|
|
|
if (ifma->ifma_addr->sa_family != AF_LINK)
|
|
|
|
continue;
|
1999-01-31 00:39:20 +00:00
|
|
|
|
2004-06-09 14:34:04 +00:00
|
|
|
index = ether_crc32_le(LLADDR((struct sockaddr_dl *)
|
|
|
|
ifma->ifma_addr), ETHER_ADDR_LEN) >> 26;
|
1996-01-05 19:12:47 +00:00
|
|
|
sc->init_block->ladrf[index >> 3] |= 1 << (index & 7);
|
|
|
|
}
|
2005-08-24 16:50:46 +00:00
|
|
|
IF_ADDR_UNLOCK(ifp);
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
|
2000-12-16 01:33:28 +00:00
|
|
|
void
|
|
|
|
lnc_stop(struct lnc_softc *sc)
|
1994-10-02 21:14:38 +00:00
|
|
|
{
|
1996-07-18 22:03:47 +00:00
|
|
|
write_csr(sc, CSR0, STOP);
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
|
1995-10-31 18:41:49 +00:00
|
|
|
static void
|
2000-12-16 01:33:28 +00:00
|
|
|
lnc_reset(struct lnc_softc *sc)
|
1994-10-02 21:14:38 +00:00
|
|
|
{
|
1996-07-18 22:03:47 +00:00
|
|
|
lnc_init(sc);
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
|
1995-10-31 18:41:49 +00:00
|
|
|
static void
|
2000-12-16 01:33:28 +00:00
|
|
|
lnc_free_mbufs(struct lnc_softc *sc)
|
1994-10-02 21:14:38 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We rely on other routines to keep the buff.mbuf field valid. If
|
|
|
|
* it's not NULL then we assume it points to an allocated mbuf.
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (i = 0; i < NDESC(sc->nrdre); i++)
|
|
|
|
if ((sc->recv_ring + i)->buff.mbuf)
|
|
|
|
m_free((sc->recv_ring + i)->buff.mbuf);
|
|
|
|
|
|
|
|
for (i = 0; i < NDESC(sc->ntdre); i++)
|
|
|
|
if ((sc->trans_ring + i)->buff.mbuf)
|
|
|
|
m_free((sc->trans_ring + i)->buff.mbuf);
|
|
|
|
|
|
|
|
if (sc->mbuf_count)
|
|
|
|
m_freem(sc->mbufs);
|
|
|
|
}
|
|
|
|
|
1998-04-15 17:47:40 +00:00
|
|
|
static __inline int
|
2000-12-16 01:33:28 +00:00
|
|
|
alloc_mbuf_cluster(struct lnc_softc *sc, struct host_ring_entry *desc)
|
1994-10-02 21:14:38 +00:00
|
|
|
{
|
|
|
|
register struct mds *md = desc->md;
|
|
|
|
struct mbuf *m=0;
|
|
|
|
int addr;
|
|
|
|
|
|
|
|
/* Try and get cluster off local cache */
|
|
|
|
if (sc->mbuf_count) {
|
|
|
|
sc->mbuf_count--;
|
|
|
|
m = sc->mbufs;
|
|
|
|
sc->mbufs = m->m_next;
|
|
|
|
/* XXX m->m_data = m->m_ext.ext_buf;*/
|
|
|
|
} else {
|
2003-02-19 05:47:46 +00:00
|
|
|
MGET(m, M_DONTWAIT, MT_DATA);
|
1995-05-30 08:16:23 +00:00
|
|
|
if (!m)
|
1994-10-02 21:14:38 +00:00
|
|
|
return(1);
|
2003-02-19 05:47:46 +00:00
|
|
|
MCLGET(m, M_DONTWAIT);
|
1994-10-02 21:14:38 +00:00
|
|
|
if (!m->m_ext.ext_buf) {
|
|
|
|
m_free(m);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
desc->buff.mbuf = m;
|
|
|
|
addr = kvtop(m->m_data);
|
|
|
|
md->md0 = addr;
|
|
|
|
md->md1= ((addr >> 16) & 0xff) | OWN;
|
|
|
|
md->md2 = -(short)(MCLBYTES - sizeof(struct pkthdr));
|
|
|
|
md->md3 = 0;
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
1998-04-15 17:47:40 +00:00
|
|
|
static __inline struct mbuf *
|
2000-12-16 01:33:28 +00:00
|
|
|
chain_mbufs(struct lnc_softc *sc, int start_of_packet, int pkt_len)
|
1994-10-02 21:14:38 +00:00
|
|
|
{
|
|
|
|
struct mbuf *head, *m;
|
|
|
|
struct host_ring_entry *desc;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Turn head into a pkthdr mbuf --
|
|
|
|
* assumes a pkthdr type mbuf was
|
|
|
|
* allocated to the descriptor
|
|
|
|
* originally.
|
|
|
|
*/
|
|
|
|
|
|
|
|
desc = sc->recv_ring + start_of_packet;
|
|
|
|
|
|
|
|
head = desc->buff.mbuf;
|
|
|
|
head->m_flags |= M_PKTHDR;
|
2000-07-04 18:43:32 +00:00
|
|
|
bzero(&head->m_pkthdr, sizeof(head->m_pkthdr));
|
1994-10-02 21:14:38 +00:00
|
|
|
|
|
|
|
m = head;
|
|
|
|
do {
|
|
|
|
m = desc->buff.mbuf;
|
1995-01-25 03:50:33 +00:00
|
|
|
m->m_len = min((MCLBYTES - sizeof(struct pkthdr)), pkt_len);
|
1994-10-02 21:14:38 +00:00
|
|
|
pkt_len -= m->m_len;
|
|
|
|
if (alloc_mbuf_cluster(sc, desc))
|
|
|
|
return((struct mbuf *)NULL);
|
|
|
|
INC_MD_PTR(start_of_packet, sc->nrdre)
|
|
|
|
desc = sc->recv_ring + start_of_packet;
|
|
|
|
m->m_next = desc->buff.mbuf;
|
|
|
|
} while (start_of_packet != sc->recv_next);
|
|
|
|
|
|
|
|
m->m_next = 0;
|
|
|
|
return(head);
|
1995-05-30 08:16:23 +00:00
|
|
|
}
|
1994-10-02 21:14:38 +00:00
|
|
|
|
1998-04-15 17:47:40 +00:00
|
|
|
static __inline struct mbuf *
|
2000-12-16 01:33:28 +00:00
|
|
|
mbuf_packet(struct lnc_softc *sc, int start_of_packet, int pkt_len)
|
1994-10-02 21:14:38 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
struct host_ring_entry *start;
|
|
|
|
struct mbuf *head,*m,*m_prev;
|
|
|
|
char *data,*mbuf_data;
|
|
|
|
short blen;
|
|
|
|
int amount;
|
|
|
|
|
|
|
|
/* Get a pkthdr mbuf for the start of packet */
|
2003-02-19 05:47:46 +00:00
|
|
|
MGETHDR(head, M_DONTWAIT, MT_DATA);
|
1994-10-02 21:14:38 +00:00
|
|
|
if (!head) {
|
|
|
|
LNCSTATS(drop_packet)
|
1995-01-25 03:50:33 +00:00
|
|
|
return(0);
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m = head;
|
|
|
|
m->m_len = 0;
|
|
|
|
start = sc->recv_ring + start_of_packet;
|
1995-01-25 03:50:33 +00:00
|
|
|
/*blen = -(start->md->md2);*/
|
|
|
|
blen = RECVBUFSIZE; /* XXX More PCnet-32 crap */
|
1994-10-02 21:14:38 +00:00
|
|
|
data = start->buff.data;
|
|
|
|
mbuf_data = m->m_data;
|
|
|
|
|
|
|
|
while (start_of_packet != sc->recv_next) {
|
|
|
|
/*
|
|
|
|
* If the data left fits in a single buffer then set
|
|
|
|
* blen to the size of the data left.
|
|
|
|
*/
|
|
|
|
if (pkt_len < blen)
|
|
|
|
blen = pkt_len;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* amount is least of data in current ring buffer and
|
|
|
|
* amount of space left in current mbuf.
|
|
|
|
*/
|
|
|
|
amount = min(blen, M_TRAILINGSPACE(m));
|
|
|
|
if (amount == 0) {
|
|
|
|
/* mbuf must be empty */
|
|
|
|
m_prev = m;
|
2003-02-19 05:47:46 +00:00
|
|
|
MGET(m, M_DONTWAIT, MT_DATA);
|
1994-10-02 21:14:38 +00:00
|
|
|
if (!m) {
|
|
|
|
m_freem(head);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
if (pkt_len >= MINCLSIZE)
|
2003-02-19 05:47:46 +00:00
|
|
|
MCLGET(m, M_DONTWAIT);
|
1994-10-02 21:14:38 +00:00
|
|
|
m->m_len = 0;
|
|
|
|
m_prev->m_next = m;
|
|
|
|
amount = min(blen, M_TRAILINGSPACE(m));
|
|
|
|
mbuf_data = m->m_data;
|
|
|
|
}
|
|
|
|
bcopy(data, mbuf_data, amount);
|
|
|
|
blen -= amount;
|
|
|
|
pkt_len -= amount;
|
|
|
|
m->m_len += amount;
|
|
|
|
data += amount;
|
|
|
|
mbuf_data += amount;
|
|
|
|
|
|
|
|
if (blen == 0) {
|
|
|
|
start->md->md1 &= HADR;
|
|
|
|
start->md->md1 |= OWN;
|
1995-01-25 03:50:33 +00:00
|
|
|
start->md->md2 = -RECVBUFSIZE; /* XXX - shouldn't be necessary */
|
1994-10-02 21:14:38 +00:00
|
|
|
INC_MD_PTR(start_of_packet, sc->nrdre)
|
|
|
|
start = sc->recv_ring + start_of_packet;
|
|
|
|
data = start->buff.data;
|
1995-01-25 03:50:33 +00:00
|
|
|
/*blen = -(start->md->md2);*/
|
|
|
|
blen = RECVBUFSIZE; /* XXX More PCnet-32 crap */
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return(head);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-22 09:22:00 +00:00
|
|
|
static void
|
2000-12-16 01:33:28 +00:00
|
|
|
lnc_rint(struct lnc_softc *sc)
|
1994-10-02 21:14:38 +00:00
|
|
|
{
|
2005-06-10 16:49:24 +00:00
|
|
|
struct ifnet *ifp = sc->ifp;
|
1994-10-02 21:14:38 +00:00
|
|
|
struct host_ring_entry *next, *start;
|
|
|
|
int start_of_packet;
|
|
|
|
struct mbuf *head;
|
|
|
|
struct ether_header *eh;
|
|
|
|
int lookahead;
|
|
|
|
int flags;
|
|
|
|
int pkt_len;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The LANCE will issue a RINT interrupt when the ownership of the
|
|
|
|
* last buffer of a receive packet has been relinquished by the LANCE.
|
|
|
|
* Therefore, it can be assumed that a complete packet can be found
|
|
|
|
* before hitting buffers that are still owned by the LANCE, if not
|
|
|
|
* then there is a bug in the driver that is causing the descriptors
|
1995-05-30 08:16:23 +00:00
|
|
|
* to get out of sync.
|
1994-10-02 21:14:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if ((sc->recv_ring + sc->recv_next)->md->md1 & OWN) {
|
2003-10-31 18:32:15 +00:00
|
|
|
log(LOG_ERR, "%s: Receive interrupt with buffer still owned by controller -- Resetting\n", ifp->if_xname);
|
1996-07-19 17:18:20 +00:00
|
|
|
lnc_reset(sc);
|
1994-10-02 21:14:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!((sc->recv_ring + sc->recv_next)->md->md1 & STP)) {
|
2003-10-31 18:32:15 +00:00
|
|
|
log(LOG_ERR, "%s: Receive interrupt but not start of packet -- Resetting\n", ifp->if_xname);
|
1996-07-19 17:18:20 +00:00
|
|
|
lnc_reset(sc);
|
1994-10-02 21:14:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
lookahead = 0;
|
|
|
|
next = sc->recv_ring + sc->recv_next;
|
|
|
|
while ((flags = next->md->md1) & STP) {
|
|
|
|
|
|
|
|
/* Make a note of the start of the packet */
|
|
|
|
start_of_packet = sc->recv_next;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find the end of the packet. Even if not data chaining,
|
|
|
|
* jabber packets can overrun into a second descriptor.
|
|
|
|
* If there is no error, then the ENP flag is set in the last
|
|
|
|
* descriptor of the packet. If there is an error then the ERR
|
1995-05-30 08:16:23 +00:00
|
|
|
* flag will be set in the descriptor where the error occured.
|
|
|
|
* Therefore, to find the last buffer of a packet we search for
|
1994-10-02 21:14:38 +00:00
|
|
|
* either ERR or ENP.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!(flags & (ENP | MDERR))) {
|
|
|
|
do {
|
|
|
|
INC_MD_PTR(sc->recv_next, sc->nrdre)
|
|
|
|
next = sc->recv_ring + sc->recv_next;
|
|
|
|
flags = next->md->md1;
|
|
|
|
} while (!(flags & (STP | OWN | ENP | MDERR)));
|
|
|
|
|
|
|
|
if (flags & STP) {
|
2003-10-31 18:32:15 +00:00
|
|
|
log(LOG_ERR, "%s: Start of packet found before end of previous in receive ring -- Resetting\n", ifp->if_xname);
|
1996-07-18 22:03:47 +00:00
|
|
|
lnc_reset(sc);
|
1994-10-02 21:14:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (flags & OWN) {
|
|
|
|
if (lookahead) {
|
|
|
|
/*
|
|
|
|
* Looked ahead into a packet still
|
|
|
|
* being received
|
|
|
|
*/
|
|
|
|
sc->recv_next = start_of_packet;
|
|
|
|
break;
|
|
|
|
} else {
|
2003-10-31 18:32:15 +00:00
|
|
|
log(LOG_ERR, "%s: End of received packet not found-- Resetting\n", ifp->if_xname);
|
1996-07-18 22:03:47 +00:00
|
|
|
lnc_reset(sc);
|
1994-10-02 21:14:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-01-25 03:50:33 +00:00
|
|
|
pkt_len = (next->md->md3 & MCNT) - FCS_LEN;
|
1994-10-02 21:14:38 +00:00
|
|
|
|
|
|
|
/* Move pointer onto start of next packet */
|
|
|
|
INC_MD_PTR(sc->recv_next, sc->nrdre)
|
|
|
|
next = sc->recv_ring + sc->recv_next;
|
|
|
|
|
|
|
|
if (flags & MDERR) {
|
2003-10-31 18:32:15 +00:00
|
|
|
const char *if_xname = ifp->if_xname;
|
1994-10-02 21:14:38 +00:00
|
|
|
if (flags & RBUFF) {
|
|
|
|
LNCSTATS(rbuff)
|
2003-10-31 18:32:15 +00:00
|
|
|
log(LOG_ERR, "%s: Receive buffer error\n", if_xname);
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
if (flags & OFLO) {
|
|
|
|
/* OFLO only valid if ENP is not set */
|
|
|
|
if (!(flags & ENP)) {
|
|
|
|
LNCSTATS(oflo)
|
2003-10-31 18:32:15 +00:00
|
|
|
log(LOG_ERR, "%s: Receive overflow error \n", if_xname);
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
1995-01-25 03:50:33 +00:00
|
|
|
} else if (flags & ENP) {
|
2002-11-14 23:54:55 +00:00
|
|
|
if ((ifp->if_flags & IFF_PROMISC)==0) {
|
1994-10-02 21:14:38 +00:00
|
|
|
/*
|
1995-01-25 03:50:33 +00:00
|
|
|
* FRAM and CRC are valid only if ENP
|
|
|
|
* is set and OFLO is not.
|
1994-10-02 21:14:38 +00:00
|
|
|
*/
|
1995-01-25 03:50:33 +00:00
|
|
|
if (flags & FRAM) {
|
1994-10-02 21:14:38 +00:00
|
|
|
LNCSTATS(fram)
|
2003-10-31 18:32:15 +00:00
|
|
|
log(LOG_ERR, "%s: Framing error\n", if_xname);
|
1994-10-02 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* FRAM is only set if there's a CRC
|
|
|
|
* error so avoid multiple messages
|
|
|
|
*/
|
1995-01-25 03:50:33 +00:00
|
|
|
} else if (flags & CRC) {
|
1994-10-02 21:14:38 +00:00
|
|
|
LNCSTATS(crc)
|
2003-10-31 18:32:15 +00:00
|
|
|
log(LOG_ERR, "%s: Receive CRC error\n", if_xname);
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
1998-10-30 11:53:58 +00:00
|
|
|
}
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Drop packet */
|
|
|
|
LNCSTATS(rerr)
|
2002-11-14 23:54:55 +00:00
|
|
|
ifp->if_ierrors++;
|
1994-10-02 21:14:38 +00:00
|
|
|
while (start_of_packet != sc->recv_next) {
|
|
|
|
start = sc->recv_ring + start_of_packet;
|
1995-01-25 03:50:33 +00:00
|
|
|
start->md->md2 = -RECVBUFSIZE; /* XXX - shouldn't be necessary */
|
1994-10-02 21:14:38 +00:00
|
|
|
start->md->md1 &= HADR;
|
|
|
|
start->md->md1 |= OWN;
|
|
|
|
INC_MD_PTR(start_of_packet, sc->nrdre)
|
|
|
|
}
|
|
|
|
} else { /* Valid packet */
|
|
|
|
|
2002-11-14 23:54:55 +00:00
|
|
|
ifp->if_ipackets++;
|
1994-10-02 21:14:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (sc->nic.mem_mode == DMA_MBUF)
|
1995-01-25 03:50:33 +00:00
|
|
|
head = chain_mbufs(sc, start_of_packet, pkt_len);
|
1994-10-02 21:14:38 +00:00
|
|
|
else
|
1995-01-25 03:50:33 +00:00
|
|
|
head = mbuf_packet(sc, start_of_packet, pkt_len);
|
1994-10-02 21:14:38 +00:00
|
|
|
|
|
|
|
if (head) {
|
|
|
|
/*
|
1995-05-30 08:16:23 +00:00
|
|
|
* First mbuf in packet holds the
|
1994-10-02 21:14:38 +00:00
|
|
|
* ethernet and packet headers
|
|
|
|
*/
|
2002-11-14 23:54:55 +00:00
|
|
|
head->m_pkthdr.rcvif = ifp;
|
1999-03-17 16:44:53 +00:00
|
|
|
head->m_pkthdr.len = pkt_len ;
|
1994-10-02 21:14:38 +00:00
|
|
|
eh = (struct ether_header *) head->m_data;
|
|
|
|
|
2000-12-11 18:53:40 +00:00
|
|
|
/*
|
|
|
|
* vmware ethernet hardware emulation loops
|
|
|
|
* packets back to itself, violates IFF_SIMPLEX.
|
|
|
|
* drop it if it is from myself.
|
2000-12-16 01:33:28 +00:00
|
|
|
*/
|
2000-12-11 18:53:40 +00:00
|
|
|
if (bcmp(eh->ether_shost,
|
2005-06-10 16:49:24 +00:00
|
|
|
IFP2ENADDR(sc->ifp), ETHER_ADDR_LEN) == 0) {
|
2000-12-16 01:33:28 +00:00
|
|
|
m_freem(head);
|
2000-12-11 18:53:40 +00:00
|
|
|
} else {
|
2002-11-14 23:54:55 +00:00
|
|
|
(*ifp->if_input)(ifp, head);
|
2000-12-11 18:53:40 +00:00
|
|
|
}
|
1994-10-02 21:14:38 +00:00
|
|
|
} else {
|
2003-10-31 18:32:15 +00:00
|
|
|
log(LOG_ERR,"%s: Packet dropped, no mbufs\n",ifp->if_xname);
|
1994-10-02 21:14:38 +00:00
|
|
|
LNCSTATS(drop_packet)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lookahead++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* At this point all completely received packets have been processed
|
|
|
|
* so clear RINT since any packets that have arrived while we were in
|
|
|
|
* here have been dealt with.
|
|
|
|
*/
|
|
|
|
|
2001-07-04 13:00:21 +00:00
|
|
|
lnc_outw(sc->rdp, RINT | INEA);
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
|
2003-07-22 09:22:00 +00:00
|
|
|
static void
|
2000-12-16 01:33:28 +00:00
|
|
|
lnc_tint(struct lnc_softc *sc)
|
1994-10-02 21:14:38 +00:00
|
|
|
{
|
|
|
|
struct host_ring_entry *next, *start;
|
|
|
|
int start_of_packet;
|
|
|
|
int lookahead;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the driver is reset in this routine then we return immediately to
|
|
|
|
* the interrupt driver routine. Any interrupts that have occured
|
|
|
|
* since the reset will be dealt with there. sc->trans_next
|
|
|
|
* should point to the start of the first packet that was awaiting
|
|
|
|
* transmission after the last transmit interrupt was dealt with. The
|
|
|
|
* LANCE should have relinquished ownership of that descriptor before
|
|
|
|
* the interrupt. Therefore, sc->trans_next should point to a
|
|
|
|
* descriptor with STP set and OWN cleared. If not then the driver's
|
|
|
|
* pointers are out of sync with the LANCE, which signifies a bug in
|
|
|
|
* the driver. Therefore, the following two checks are really
|
|
|
|
* diagnostic, since if the driver is working correctly they should
|
|
|
|
* never happen.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if ((sc->trans_ring + sc->trans_next)->md->md1 & OWN) {
|
2005-06-10 16:49:24 +00:00
|
|
|
log(LOG_ERR, "%s: Transmit interrupt with buffer still owned by controller -- Resetting\n", sc->ifp->if_xname);
|
1996-07-19 17:18:20 +00:00
|
|
|
lnc_reset(sc);
|
1994-10-02 21:14:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The LANCE will write the status information for the packet it just
|
|
|
|
* tried to transmit in one of two places. If the packet was
|
|
|
|
* transmitted successfully then the status will be written into the
|
|
|
|
* last descriptor of the packet. If the transmit failed then the
|
|
|
|
* status will be written into the descriptor that was being accessed
|
|
|
|
* when the error occured and all subsequent descriptors in that
|
|
|
|
* packet will have been relinquished by the LANCE.
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1994-10-02 21:14:38 +00:00
|
|
|
* At this point we know that sc->trans_next points to the start
|
|
|
|
* of a packet that the LANCE has just finished trying to transmit.
|
|
|
|
* We now search for a buffer with either ENP or ERR set.
|
|
|
|
*/
|
|
|
|
|
|
|
|
lookahead = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
start_of_packet = sc->trans_next;
|
|
|
|
next = sc->trans_ring + sc->trans_next;
|
|
|
|
|
|
|
|
#ifdef DIAGNOSTIC
|
2003-10-31 18:32:15 +00:00
|
|
|
if (!(next->md->md1 & STP)) {
|
2005-06-10 16:49:24 +00:00
|
|
|
log(LOG_ERR, "%s: Transmit interrupt but not start of packet -- Resetting\n", sc->ifp->if_xname);
|
2003-10-31 18:32:15 +00:00
|
|
|
lnc_reset(sc);
|
|
|
|
return;
|
|
|
|
}
|
1994-10-02 21:14:38 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
1995-05-30 08:16:23 +00:00
|
|
|
* Find end of packet.
|
1994-10-02 21:14:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
if (!(next->md->md1 & (ENP | MDERR))) {
|
|
|
|
do {
|
|
|
|
INC_MD_PTR(sc->trans_next, sc->ntdre)
|
|
|
|
next = sc->trans_ring + sc->trans_next;
|
|
|
|
} while (!(next->md->md1 & (STP | OWN | ENP | MDERR)));
|
|
|
|
|
|
|
|
if (next->md->md1 & STP) {
|
2005-06-10 16:49:24 +00:00
|
|
|
log(LOG_ERR, "%s: Start of packet found before end of previous in transmit ring -- Resetting\n", sc->ifp->if_xname);
|
1996-07-18 22:03:47 +00:00
|
|
|
lnc_reset(sc);
|
1994-10-02 21:14:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (next->md->md1 & OWN) {
|
|
|
|
if (lookahead) {
|
|
|
|
/*
|
|
|
|
* Looked ahead into a packet still
|
|
|
|
* being transmitted
|
|
|
|
*/
|
|
|
|
sc->trans_next = start_of_packet;
|
|
|
|
break;
|
|
|
|
} else {
|
2005-06-10 16:49:24 +00:00
|
|
|
log(LOG_ERR, "%s: End of transmitted packet not found -- Resetting\n", sc->ifp->if_xname);
|
1996-07-18 22:03:47 +00:00
|
|
|
lnc_reset(sc);
|
1994-10-02 21:14:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Check for ERR first since other flags are irrelevant if an
|
|
|
|
* error occurred.
|
|
|
|
*/
|
|
|
|
if (next->md->md1 & MDERR) {
|
|
|
|
|
|
|
|
LNCSTATS(terr)
|
2005-06-10 16:49:24 +00:00
|
|
|
sc->ifp->if_oerrors++;
|
1994-10-02 21:14:38 +00:00
|
|
|
|
|
|
|
if (next->md->md3 & LCOL) {
|
|
|
|
LNCSTATS(lcol)
|
2005-06-10 16:49:24 +00:00
|
|
|
log(LOG_ERR, "%s: Transmit late collision -- Net error?\n", sc->ifp->if_xname);
|
|
|
|
sc->ifp->if_collisions++;
|
1994-10-02 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Clear TBUFF since it's not valid when LCOL
|
|
|
|
* set
|
|
|
|
*/
|
|
|
|
next->md->md3 &= ~TBUFF;
|
|
|
|
}
|
|
|
|
if (next->md->md3 & LCAR) {
|
|
|
|
LNCSTATS(lcar)
|
2005-06-10 16:49:24 +00:00
|
|
|
log(LOG_ERR, "%s: Loss of carrier during transmit -- Net error?\n", sc->ifp->if_xname);
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
if (next->md->md3 & RTRY) {
|
|
|
|
LNCSTATS(rtry)
|
2005-06-10 16:49:24 +00:00
|
|
|
log(LOG_ERR, "%s: Transmit of packet failed after 16 attempts -- TDR = %d\n", sc->ifp->if_xname, ((sc->trans_ring + sc->trans_next)->md->md3 & TDR));
|
|
|
|
sc->ifp->if_collisions += 16;
|
1994-10-02 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Clear TBUFF since it's not valid when RTRY
|
|
|
|
* set
|
|
|
|
*/
|
|
|
|
next->md->md3 &= ~TBUFF;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* TBUFF is only valid if neither LCOL nor RTRY are set.
|
|
|
|
* We need to check UFLO after LCOL and RTRY so that we
|
|
|
|
* know whether or not TBUFF is valid. If either are
|
|
|
|
* set then TBUFF will have been cleared above. A
|
|
|
|
* UFLO error will turn off the transmitter so we
|
|
|
|
* have to reset.
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1994-10-02 21:14:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
if (next->md->md3 & UFLO) {
|
|
|
|
LNCSTATS(uflo)
|
|
|
|
/*
|
|
|
|
* If an UFLO has occured it's possibly due
|
|
|
|
* to a TBUFF error
|
|
|
|
*/
|
|
|
|
if (next->md->md3 & TBUFF) {
|
|
|
|
LNCSTATS(tbuff)
|
2005-06-10 16:49:24 +00:00
|
|
|
log(LOG_ERR, "%s: Transmit buffer error -- Resetting\n", sc->ifp->if_xname);
|
1994-10-02 21:14:38 +00:00
|
|
|
} else
|
2005-06-10 16:49:24 +00:00
|
|
|
log(LOG_ERR, "%s: Transmit underflow error -- Resetting\n", sc->ifp->if_xname);
|
1996-07-18 22:03:47 +00:00
|
|
|
lnc_reset(sc);
|
1994-10-02 21:14:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
do {
|
|
|
|
INC_MD_PTR(sc->trans_next, sc->ntdre)
|
|
|
|
next = sc->trans_ring + sc->trans_next;
|
|
|
|
} while (!(next->md->md1 & STP) && (sc->trans_next != sc->next_to_send));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Since we check for ERR first then if we get here
|
|
|
|
* the packet was transmitted correctly. There may
|
|
|
|
* still have been non-fatal errors though.
|
|
|
|
* Don't bother checking for DEF, waste of time.
|
|
|
|
*/
|
|
|
|
|
2005-06-10 16:49:24 +00:00
|
|
|
sc->ifp->if_opackets++;
|
1994-10-02 21:14:38 +00:00
|
|
|
|
|
|
|
if (next->md->md1 & MORE) {
|
|
|
|
LNCSTATS(more)
|
2005-06-10 16:49:24 +00:00
|
|
|
sc->ifp->if_collisions += 2;
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ONE is invalid if LCOL is set. If LCOL was set then
|
|
|
|
* ERR would have also been set and we would have
|
|
|
|
* returned from lnc_tint above. Therefore we can
|
|
|
|
* assume if we arrive here that ONE is valid.
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1994-10-02 21:14:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
if (next->md->md1 & ONE) {
|
|
|
|
LNCSTATS(one)
|
2005-06-10 16:49:24 +00:00
|
|
|
sc->ifp->if_collisions++;
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
INC_MD_PTR(sc->trans_next, sc->ntdre)
|
|
|
|
next = sc->trans_ring + sc->trans_next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear descriptors and free any mbufs.
|
|
|
|
*/
|
|
|
|
|
|
|
|
do {
|
|
|
|
start = sc->trans_ring + start_of_packet;
|
|
|
|
start->md->md1 &= HADR;
|
|
|
|
if (sc->nic.mem_mode == DMA_MBUF) {
|
|
|
|
/* Cache clusters on a local queue */
|
|
|
|
if ((start->buff.mbuf->m_flags & M_EXT) && (sc->mbuf_count < MBUF_CACHE_LIMIT)) {
|
|
|
|
if (sc->mbuf_count) {
|
|
|
|
start->buff.mbuf->m_next = sc->mbufs;
|
|
|
|
sc->mbufs = start->buff.mbuf;
|
|
|
|
} else
|
|
|
|
sc->mbufs = start->buff.mbuf;
|
|
|
|
sc->mbuf_count++;
|
|
|
|
start->buff.mbuf = 0;
|
|
|
|
} else {
|
2002-02-05 02:00:56 +00:00
|
|
|
/*
|
|
|
|
* XXX should this be m_freem()?
|
|
|
|
*/
|
|
|
|
m_free(start->buff.mbuf);
|
|
|
|
start->buff.mbuf = NULL;
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
sc->pending_transmits--;
|
|
|
|
INC_MD_PTR(start_of_packet, sc->ntdre)
|
|
|
|
}while (start_of_packet != sc->trans_next);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* There's now at least one free descriptor
|
|
|
|
* in the ring so indicate that we can accept
|
|
|
|
* more packets again.
|
|
|
|
*/
|
|
|
|
|
2005-08-25 05:01:24 +00:00
|
|
|
sc->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
1994-10-02 21:14:38 +00:00
|
|
|
|
|
|
|
lookahead++;
|
|
|
|
|
|
|
|
} while (sc->pending_transmits && !(next->md->md1 & OWN));
|
|
|
|
|
|
|
|
/*
|
1995-05-30 08:16:23 +00:00
|
|
|
* Clear TINT since we've dealt with all
|
1994-10-02 21:14:38 +00:00
|
|
|
* the completed transmissions.
|
|
|
|
*/
|
|
|
|
|
2001-07-04 13:00:21 +00:00
|
|
|
lnc_outw(sc->rdp, TINT | INEA);
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
|
2000-05-16 02:08:04 +00:00
|
|
|
int
|
2000-12-16 01:33:28 +00:00
|
|
|
lnc_attach_common(device_t dev)
|
1994-10-02 21:14:38 +00:00
|
|
|
{
|
2000-12-16 01:33:28 +00:00
|
|
|
lnc_softc_t *sc = device_get_softc(dev);
|
|
|
|
int i;
|
|
|
|
int skip;
|
2005-06-10 16:49:24 +00:00
|
|
|
u_char eaddr[6];
|
1994-10-02 21:14:38 +00:00
|
|
|
|
2001-07-04 13:00:21 +00:00
|
|
|
switch (sc->nic.ident) {
|
|
|
|
case BICC:
|
|
|
|
case CNET98S:
|
2000-12-16 01:33:28 +00:00
|
|
|
skip = 2;
|
2001-07-04 13:00:21 +00:00
|
|
|
break;
|
|
|
|
default:
|
2000-12-16 01:33:28 +00:00
|
|
|
skip = 1;
|
2001-07-04 13:00:21 +00:00
|
|
|
break;
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
1995-01-25 03:50:33 +00:00
|
|
|
|
1994-10-02 21:14:38 +00:00
|
|
|
/* Set default mode */
|
|
|
|
sc->nic.mode = NORMAL;
|
|
|
|
|
|
|
|
/* Fill in arpcom structure entries */
|
|
|
|
|
2005-06-10 16:49:24 +00:00
|
|
|
sc->ifp = if_alloc(IFT_ETHER);
|
|
|
|
if (sc->ifp == NULL) {
|
|
|
|
device_printf(dev, "can not if_alloc()\n");
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
sc->ifp->if_softc = sc;
|
|
|
|
if_initname(sc->ifp, device_get_name(dev),
|
2003-10-31 18:32:15 +00:00
|
|
|
device_get_unit(dev));
|
2005-06-10 16:49:24 +00:00
|
|
|
sc->ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX |
|
2004-08-13 23:20:50 +00:00
|
|
|
IFF_MULTICAST | IFF_NEEDSGIANT;
|
2005-06-10 16:49:24 +00:00
|
|
|
sc->ifp->if_timer = 0;
|
|
|
|
sc->ifp->if_start = lnc_start;
|
|
|
|
sc->ifp->if_ioctl = lnc_ioctl;
|
|
|
|
sc->ifp->if_watchdog = lnc_watchdog;
|
|
|
|
sc->ifp->if_init = lnc_init;
|
|
|
|
IFQ_SET_MAXLEN(&sc->ifp->if_snd, IFQ_MAXLEN);
|
|
|
|
sc->ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
|
|
|
|
IFQ_SET_READY(&sc->ifp->if_snd);
|
1994-10-02 21:14:38 +00:00
|
|
|
|
2000-12-16 01:33:28 +00:00
|
|
|
/* Extract MAC address from PROM */
|
|
|
|
for (i = 0; i < ETHER_ADDR_LEN; i++)
|
2005-06-10 16:49:24 +00:00
|
|
|
eaddr[i] = lnc_inb(i * skip);
|
2000-12-16 01:33:28 +00:00
|
|
|
|
2005-06-10 16:49:24 +00:00
|
|
|
ether_ifattach(sc->ifp, eaddr);
|
1994-10-02 21:14:38 +00:00
|
|
|
|
1996-09-14 01:26:16 +00:00
|
|
|
if (sc->nic.ic == LANCE || sc->nic.ic == C_LANCE)
|
2005-06-10 16:49:24 +00:00
|
|
|
if_printf(sc->ifp, "%s (%s)\n",
|
1996-09-14 01:26:16 +00:00
|
|
|
nic_ident[sc->nic.ident], ic_ident[sc->nic.ic]);
|
|
|
|
else
|
2005-06-10 16:49:24 +00:00
|
|
|
if_printf(sc->ifp, "%s\n", ic_ident[sc->nic.ic]);
|
1994-10-02 21:14:38 +00:00
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
2005-06-10 16:49:24 +00:00
|
|
|
int
|
|
|
|
lnc_detach_common(device_t dev) {
|
|
|
|
lnc_softc_t *sc = device_get_softc(dev);
|
|
|
|
int s = splimp();
|
|
|
|
|
|
|
|
ether_ifdetach(sc->ifp);
|
|
|
|
lnc_stop(sc);
|
|
|
|
lnc_release_resources(dev);
|
|
|
|
|
|
|
|
splx(s);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1996-07-18 22:03:47 +00:00
|
|
|
static void
|
1999-08-20 14:12:14 +00:00
|
|
|
lnc_init(xsc)
|
|
|
|
void *xsc;
|
1996-07-18 22:03:47 +00:00
|
|
|
{
|
2000-12-16 01:33:28 +00:00
|
|
|
struct lnc_softc *sc = xsc;
|
1994-10-02 21:14:38 +00:00
|
|
|
int s, i;
|
|
|
|
char *lnc_mem;
|
|
|
|
|
|
|
|
/* Shut down interface */
|
|
|
|
|
|
|
|
s = splimp();
|
1996-07-18 22:03:47 +00:00
|
|
|
lnc_stop(sc);
|
2005-06-10 16:49:24 +00:00
|
|
|
sc->ifp->if_flags |= IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; /* XXX??? */
|
1994-10-02 21:14:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This sets up the memory area for the controller. Memory is set up for
|
|
|
|
* the initialisation block (12 words of contiguous memory starting
|
|
|
|
* on a word boundary),the transmit and receive ring structures (each
|
|
|
|
* entry is 4 words long and must start on a quadword boundary) and
|
|
|
|
* the data buffers.
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1994-10-02 21:14:38 +00:00
|
|
|
* The alignment tests are particularly paranoid.
|
|
|
|
*/
|
|
|
|
|
|
|
|
sc->recv_next = 0;
|
|
|
|
sc->trans_ring = sc->recv_ring + NDESC(sc->nrdre);
|
|
|
|
sc->trans_next = 0;
|
|
|
|
|
|
|
|
if (sc->nic.mem_mode == SHMEM)
|
2004-03-03 08:33:34 +00:00
|
|
|
lnc_mem = (char *)(uintptr_t)sc->nic.iobase;
|
1994-10-02 21:14:38 +00:00
|
|
|
else
|
|
|
|
lnc_mem = (char *) (sc->trans_ring + NDESC(sc->ntdre));
|
|
|
|
|
2004-03-03 06:54:26 +00:00
|
|
|
lnc_mem = (char *)(((long)lnc_mem + 1) & ~1);
|
|
|
|
sc->init_block = (struct init_block *) ((long) lnc_mem & ~1);
|
1994-10-02 21:14:38 +00:00
|
|
|
lnc_mem = (char *) (sc->init_block + 1);
|
2004-03-03 06:54:26 +00:00
|
|
|
lnc_mem = (char *)(((long)lnc_mem + 7) & ~7);
|
1994-10-02 21:14:38 +00:00
|
|
|
|
|
|
|
/* Initialise pointers to descriptor entries */
|
|
|
|
for (i = 0; i < NDESC(sc->nrdre); i++) {
|
|
|
|
(sc->recv_ring + i)->md = (struct mds *) lnc_mem;
|
|
|
|
lnc_mem += sizeof(struct mds);
|
|
|
|
}
|
|
|
|
for (i = 0; i < NDESC(sc->ntdre); i++) {
|
|
|
|
(sc->trans_ring + i)->md = (struct mds *) lnc_mem;
|
|
|
|
lnc_mem += sizeof(struct mds);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialise the remaining ring entries */
|
|
|
|
|
|
|
|
if (sc->nic.mem_mode == DMA_MBUF) {
|
|
|
|
|
|
|
|
sc->mbufs = 0;
|
|
|
|
sc->mbuf_count = 0;
|
|
|
|
|
|
|
|
/* Free previously allocated mbufs */
|
1999-01-31 00:39:20 +00:00
|
|
|
if (sc->flags & LNC_INITIALISED)
|
1994-10-02 21:14:38 +00:00
|
|
|
lnc_free_mbufs(sc);
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < NDESC(sc->nrdre); i++) {
|
|
|
|
if (alloc_mbuf_cluster(sc, sc->recv_ring+i)) {
|
|
|
|
log(LOG_ERR, "Initialisation failed -- no mbufs\n");
|
|
|
|
splx(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < NDESC(sc->ntdre); i++) {
|
|
|
|
(sc->trans_ring + i)->buff.mbuf = 0;
|
|
|
|
(sc->trans_ring + i)->md->md0 = 0;
|
|
|
|
(sc->trans_ring + i)->md->md1 = 0;
|
|
|
|
(sc->trans_ring + i)->md->md2 = 0;
|
|
|
|
(sc->trans_ring + i)->md->md3 = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < NDESC(sc->nrdre); i++) {
|
|
|
|
(sc->recv_ring + i)->md->md0 = kvtop(lnc_mem);
|
|
|
|
(sc->recv_ring + i)->md->md1 = ((kvtop(lnc_mem) >> 16) & 0xff) | OWN;
|
|
|
|
(sc->recv_ring + i)->md->md2 = -RECVBUFSIZE;
|
|
|
|
(sc->recv_ring + i)->md->md3 = 0;
|
|
|
|
(sc->recv_ring + i)->buff.data = lnc_mem;
|
|
|
|
lnc_mem += RECVBUFSIZE;
|
|
|
|
}
|
|
|
|
for (i = 0; i < NDESC(sc->ntdre); i++) {
|
|
|
|
(sc->trans_ring + i)->md->md0 = kvtop(lnc_mem);
|
|
|
|
(sc->trans_ring + i)->md->md1 = ((kvtop(lnc_mem) >> 16) & 0xff);
|
|
|
|
(sc->trans_ring + i)->md->md2 = 0;
|
|
|
|
(sc->trans_ring + i)->md->md3 = 0;
|
|
|
|
(sc->trans_ring + i)->buff.data = lnc_mem;
|
|
|
|
lnc_mem += TRANSBUFSIZE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sc->next_to_send = 0;
|
|
|
|
|
|
|
|
/* Set up initialisation block */
|
|
|
|
|
|
|
|
sc->init_block->mode = sc->nic.mode;
|
|
|
|
|
|
|
|
for (i = 0; i < ETHER_ADDR_LEN; i++)
|
2005-06-10 16:49:24 +00:00
|
|
|
sc->init_block->padr[i] = IFP2ENADDR(sc->ifp)[i];
|
1994-10-02 21:14:38 +00:00
|
|
|
|
1999-01-31 00:39:20 +00:00
|
|
|
lnc_setladrf(sc);
|
1994-10-02 21:14:38 +00:00
|
|
|
|
|
|
|
sc->init_block->rdra = kvtop(sc->recv_ring->md);
|
|
|
|
sc->init_block->rlen = ((kvtop(sc->recv_ring->md) >> 16) & 0xff) | (sc->nrdre << 13);
|
|
|
|
sc->init_block->tdra = kvtop(sc->trans_ring->md);
|
|
|
|
sc->init_block->tlen = ((kvtop(sc->trans_ring->md) >> 16) & 0xff) | (sc->ntdre << 13);
|
|
|
|
|
|
|
|
|
1999-01-31 00:39:20 +00:00
|
|
|
/* Set flags to show that the memory area is valid */
|
|
|
|
sc->flags |= LNC_INITIALISED;
|
1994-10-02 21:14:38 +00:00
|
|
|
|
|
|
|
sc->pending_transmits = 0;
|
|
|
|
|
|
|
|
/* Give the LANCE the physical address of the initialisation block */
|
|
|
|
|
1999-08-10 01:03:51 +00:00
|
|
|
if (sc->nic.ic == PCnet_Home) {
|
|
|
|
u_short media;
|
|
|
|
/* Set PHY_SEL to HomeRun */
|
|
|
|
media = read_bcr(sc, BCR49);
|
|
|
|
media &= ~3;
|
|
|
|
media |= 1;
|
|
|
|
write_bcr(sc, BCR49, media);
|
|
|
|
}
|
|
|
|
|
1996-07-18 22:03:47 +00:00
|
|
|
write_csr(sc, CSR1, kvtop(sc->init_block));
|
|
|
|
write_csr(sc, CSR2, (kvtop(sc->init_block) >> 16) & 0xff);
|
1994-10-02 21:14:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Depending on which controller this is, CSR3 has different meanings.
|
|
|
|
* For the Am7990 it controls DMA operations, for the Am79C960 it
|
|
|
|
* controls interrupt masks and transmitter algorithms. In either
|
|
|
|
* case, none of the flags are set.
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1994-10-02 21:14:38 +00:00
|
|
|
*/
|
|
|
|
|
1996-07-18 22:03:47 +00:00
|
|
|
write_csr(sc, CSR3, 0);
|
1994-10-02 21:14:38 +00:00
|
|
|
|
|
|
|
/* Let's see if it starts */
|
2000-12-16 01:33:28 +00:00
|
|
|
/*
|
|
|
|
printf("Enabling lnc interrupts\n");
|
2005-06-10 16:49:24 +00:00
|
|
|
sc->ifp->if_timer = 10;
|
2000-12-16 01:33:28 +00:00
|
|
|
write_csr(sc, CSR0, INIT|INEA);
|
|
|
|
*/
|
1994-10-02 21:14:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Now that the initialisation is complete there's no reason to
|
|
|
|
* access anything except CSR0, so we leave RAP pointing there
|
|
|
|
* so we can just access RDP from now on, saving an outw each
|
|
|
|
* time.
|
|
|
|
*/
|
|
|
|
|
2000-12-16 01:33:28 +00:00
|
|
|
write_csr(sc, CSR0, INIT);
|
|
|
|
for(i=0; i < 1000; i++)
|
|
|
|
if (read_csr(sc, CSR0) & IDON)
|
|
|
|
break;
|
|
|
|
|
1996-07-18 22:03:47 +00:00
|
|
|
if (read_csr(sc, CSR0) & IDON) {
|
1994-10-02 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Enable interrupts, start the LANCE, mark the interface as
|
|
|
|
* running and transmit any pending packets.
|
|
|
|
*/
|
1996-07-18 22:03:47 +00:00
|
|
|
write_csr(sc, CSR0, STRT | INEA);
|
2005-08-25 05:01:24 +00:00
|
|
|
sc->ifp->if_drv_flags |= IFF_DRV_RUNNING;
|
|
|
|
sc->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
2005-06-10 16:49:24 +00:00
|
|
|
lnc_start(sc->ifp);
|
1994-10-02 21:14:38 +00:00
|
|
|
} else
|
2003-10-31 18:32:15 +00:00
|
|
|
log(LOG_ERR, "%s: Initialisation failed\n",
|
2005-06-10 16:49:24 +00:00
|
|
|
sc->ifp->if_xname);
|
1994-10-02 21:14:38 +00:00
|
|
|
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The interrupt flag (INTR) will be set and provided that the interrupt enable
|
|
|
|
* flag (INEA) is also set, the interrupt pin will be driven low when any of
|
|
|
|
* the following occur:
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1994-10-02 21:14:38 +00:00
|
|
|
* 1) Completion of the initialisation routine (IDON). 2) The reception of a
|
|
|
|
* packet (RINT). 3) The transmission of a packet (TINT). 4) A transmitter
|
|
|
|
* timeout error (BABL). 5) A missed packet (MISS). 6) A memory error (MERR).
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1994-10-02 21:14:38 +00:00
|
|
|
* The interrupt flag is cleared when all of the above conditions are cleared.
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1994-10-02 21:14:38 +00:00
|
|
|
* If the driver is reset from this routine then it first checks to see if any
|
|
|
|
* interrupts have ocurred since the reset and handles them before returning.
|
|
|
|
* This is because the NIC may signify a pending interrupt in CSR0 using the
|
|
|
|
* INTR flag even if a hardware interrupt is currently inhibited (at least I
|
|
|
|
* think it does from reading the data sheets). We may as well deal with
|
|
|
|
* these pending interrupts now rather than get the overhead of another
|
|
|
|
* hardware interrupt immediately upon returning from the interrupt handler.
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1994-10-02 21:14:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2000-12-16 01:33:28 +00:00
|
|
|
lncintr(void *arg)
|
1994-10-02 21:14:38 +00:00
|
|
|
{
|
2000-12-16 01:33:28 +00:00
|
|
|
lnc_softc_t *sc = arg;
|
1994-10-02 21:14:38 +00:00
|
|
|
u_short csr0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* INEA is the only bit that can be cleared by writing a 0 to it so
|
|
|
|
* we have to include it in any writes that clear other flags.
|
|
|
|
*/
|
|
|
|
|
2001-07-04 13:00:21 +00:00
|
|
|
while ((csr0 = lnc_inw(sc->rdp)) & INTR) {
|
1994-10-02 21:14:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear interrupt flags early to avoid race conditions. The
|
|
|
|
* controller can still set these flags even while we're in
|
|
|
|
* this interrupt routine. If the flag is still set from the
|
|
|
|
* event that caused this interrupt any new events will
|
|
|
|
* be missed.
|
|
|
|
*/
|
|
|
|
|
2001-07-04 13:00:21 +00:00
|
|
|
lnc_outw(sc->rdp, csr0);
|
|
|
|
/*lnc_outw(sc->rdp, IDON | CERR | BABL | MISS | MERR | RINT | TINT | INEA);*/
|
1994-10-02 21:14:38 +00:00
|
|
|
|
2000-12-16 01:33:28 +00:00
|
|
|
#ifdef notyet
|
|
|
|
if (csr0 & IDON) {
|
|
|
|
printf("IDON\n");
|
2005-06-10 16:49:24 +00:00
|
|
|
sc->ifp->if_timer = 0;
|
2000-12-16 01:33:28 +00:00
|
|
|
write_csr(sc, CSR0, STRT | INEA);
|
2005-08-25 05:01:24 +00:00
|
|
|
sc->ifp->if_drv_flags |= IFF_DRV_RUNNING;
|
|
|
|
sc->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
2005-06-10 16:49:24 +00:00
|
|
|
lnc_start(sc->ifp);
|
2000-12-16 01:33:28 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
#endif
|
1994-10-02 21:14:38 +00:00
|
|
|
|
|
|
|
if (csr0 & ERR) {
|
|
|
|
if (csr0 & CERR) {
|
2005-06-10 16:49:24 +00:00
|
|
|
log(LOG_ERR, "%s: Heartbeat error -- SQE test failed\n", sc->ifp->if_xname);
|
1994-10-02 21:14:38 +00:00
|
|
|
LNCSTATS(cerr)
|
|
|
|
}
|
|
|
|
if (csr0 & BABL) {
|
2005-06-10 16:49:24 +00:00
|
|
|
log(LOG_ERR, "%s: Babble error - more than 1519 bytes transmitted\n", sc->ifp->if_xname);
|
1994-10-02 21:14:38 +00:00
|
|
|
LNCSTATS(babl)
|
2005-06-10 16:49:24 +00:00
|
|
|
sc->ifp->if_oerrors++;
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
if (csr0 & MISS) {
|
2005-06-10 16:49:24 +00:00
|
|
|
log(LOG_ERR, "%s: Missed packet -- no receive buffer\n", sc->ifp->if_xname);
|
1994-10-02 21:14:38 +00:00
|
|
|
LNCSTATS(miss)
|
2005-06-10 16:49:24 +00:00
|
|
|
sc->ifp->if_ierrors++;
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
if (csr0 & MERR) {
|
2005-06-10 16:49:24 +00:00
|
|
|
log(LOG_ERR, "%s: Memory error -- Resetting\n", sc->ifp->if_xname);
|
1994-10-02 21:14:38 +00:00
|
|
|
LNCSTATS(merr)
|
1996-07-18 22:03:47 +00:00
|
|
|
lnc_reset(sc);
|
1994-10-02 21:14:38 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (csr0 & RINT) {
|
|
|
|
LNCSTATS(rint)
|
1996-07-18 22:03:47 +00:00
|
|
|
lnc_rint(sc);
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
if (csr0 & TINT) {
|
|
|
|
LNCSTATS(tint)
|
2005-06-10 16:49:24 +00:00
|
|
|
sc->ifp->if_timer = 0;
|
1996-07-18 22:03:47 +00:00
|
|
|
lnc_tint(sc);
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If there's room in the transmit descriptor ring then queue
|
|
|
|
* some more transmit packets.
|
|
|
|
*/
|
|
|
|
|
2005-08-25 05:01:24 +00:00
|
|
|
if (!(sc->ifp->if_drv_flags & IFF_DRV_OACTIVE))
|
2005-06-10 16:49:24 +00:00
|
|
|
lnc_start(sc->ifp);
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-04-15 17:47:40 +00:00
|
|
|
static __inline int
|
1994-10-02 21:14:38 +00:00
|
|
|
mbuf_to_buffer(struct mbuf *m, char *buffer)
|
|
|
|
{
|
|
|
|
|
|
|
|
int len=0;
|
|
|
|
|
|
|
|
for( ; m; m = m->m_next) {
|
|
|
|
bcopy(mtod(m, caddr_t), buffer, m->m_len);
|
|
|
|
buffer += m->m_len;
|
|
|
|
len += m->m_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
return(len);
|
|
|
|
}
|
|
|
|
|
1998-04-15 17:47:40 +00:00
|
|
|
static __inline struct mbuf *
|
1994-10-02 21:14:38 +00:00
|
|
|
chain_to_cluster(struct mbuf *m)
|
|
|
|
{
|
|
|
|
struct mbuf *new;
|
|
|
|
|
2003-02-19 05:47:46 +00:00
|
|
|
MGET(new, M_DONTWAIT, MT_DATA);
|
1994-10-02 21:14:38 +00:00
|
|
|
if (new) {
|
2003-02-19 05:47:46 +00:00
|
|
|
MCLGET(new, M_DONTWAIT);
|
1994-10-02 21:14:38 +00:00
|
|
|
if (new->m_ext.ext_buf) {
|
|
|
|
new->m_len = mbuf_to_buffer(m, new->m_data);
|
|
|
|
m_freem(m);
|
|
|
|
return(new);
|
|
|
|
} else
|
|
|
|
m_free(new);
|
|
|
|
}
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2005-08-25 05:01:24 +00:00
|
|
|
* IFF_DRV_OACTIVE and IFF_DRV_RUNNING are checked in ether_output so it's
|
|
|
|
* redundant to check them again since we wouldn't have got here if they were
|
|
|
|
* not appropriately set. This is also called from lnc_init and lncintr but the
|
1994-10-02 21:14:38 +00:00
|
|
|
* flags should be ok at those points too.
|
|
|
|
*/
|
|
|
|
|
1995-10-31 18:41:49 +00:00
|
|
|
static void
|
1994-10-02 21:14:38 +00:00
|
|
|
lnc_start(struct ifnet *ifp)
|
|
|
|
{
|
|
|
|
|
2000-12-16 01:33:28 +00:00
|
|
|
struct lnc_softc *sc = ifp->if_softc;
|
1994-10-02 21:14:38 +00:00
|
|
|
struct host_ring_entry *desc;
|
|
|
|
int tmp;
|
|
|
|
int end_of_packet;
|
|
|
|
struct mbuf *head, *m;
|
|
|
|
int len, chunk;
|
|
|
|
int addr;
|
|
|
|
int no_entries_needed;
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
2005-06-10 16:49:24 +00:00
|
|
|
IFQ_DRV_DEQUEUE(&sc->ifp->if_snd, head);
|
1994-10-02 21:14:38 +00:00
|
|
|
if (!head)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (sc->nic.mem_mode == DMA_MBUF) {
|
|
|
|
|
|
|
|
no_entries_needed = 0;
|
|
|
|
for (m=head; m; m = m->m_next)
|
|
|
|
no_entries_needed++;
|
|
|
|
|
|
|
|
/*
|
1995-05-30 08:16:23 +00:00
|
|
|
* We try and avoid bcopy as much as possible
|
1994-10-02 21:14:38 +00:00
|
|
|
* but there are two cases when we use it.
|
|
|
|
*
|
|
|
|
* 1) If there are not enough free entries in the ring
|
|
|
|
* to hold each mbuf in the chain then compact the
|
|
|
|
* chain into a single cluster.
|
|
|
|
*
|
|
|
|
* 2) The Am7990 and Am79C90 must not have less than
|
|
|
|
* 100 bytes in the first descriptor of a chained
|
|
|
|
* packet so it's necessary to shuffle the mbuf
|
|
|
|
* contents to ensure this.
|
|
|
|
*/
|
1995-05-30 08:16:23 +00:00
|
|
|
|
1994-10-02 21:14:38 +00:00
|
|
|
|
1999-05-06 18:13:11 +00:00
|
|
|
if (no_entries_needed > (NDESC(sc->ntdre) - sc->pending_transmits)) {
|
1994-10-02 21:14:38 +00:00
|
|
|
if (!(head = chain_to_cluster(head))) {
|
2003-10-31 18:32:15 +00:00
|
|
|
log(LOG_ERR, "%s: Couldn't get mbuf for transmit packet -- Resetting \n ",ifp->if_xname);
|
1996-07-18 22:03:47 +00:00
|
|
|
lnc_reset(sc);
|
1994-10-02 21:14:38 +00:00
|
|
|
return;
|
|
|
|
}
|
1999-05-06 18:13:11 +00:00
|
|
|
} else if ((sc->nic.ic == LANCE) || (sc->nic.ic == C_LANCE)) {
|
1994-10-02 21:14:38 +00:00
|
|
|
if ((head->m_len < 100) && (head->m_next)) {
|
|
|
|
len = 100 - head->m_len;
|
|
|
|
if (M_TRAILINGSPACE(head) < len) {
|
|
|
|
/*
|
1995-05-30 08:16:23 +00:00
|
|
|
* Move data to start of data
|
|
|
|
* area. We assume the first
|
|
|
|
* mbuf has a packet header
|
1994-10-02 21:14:38 +00:00
|
|
|
* and is not a cluster.
|
|
|
|
*/
|
|
|
|
bcopy((caddr_t)head->m_data, (caddr_t)head->m_pktdat, head->m_len);
|
|
|
|
head->m_data = head->m_pktdat;
|
|
|
|
}
|
|
|
|
m = head->m_next;
|
|
|
|
while (m && (len > 0)) {
|
|
|
|
chunk = min(len, m->m_len);
|
|
|
|
bcopy(mtod(m, caddr_t), mtod(head, caddr_t) + head->m_len, chunk);
|
|
|
|
len -= chunk;
|
|
|
|
head->m_len += chunk;
|
|
|
|
m->m_len -= chunk;
|
|
|
|
m->m_data += chunk;
|
|
|
|
if (m->m_len <= 0) {
|
2002-02-05 02:00:56 +00:00
|
|
|
m = m_free(m);
|
|
|
|
head->m_next = m;
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = sc->next_to_send;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* On entering this loop we know that tmp points to a
|
|
|
|
* descriptor with a clear OWN bit.
|
|
|
|
*/
|
|
|
|
|
|
|
|
desc = sc->trans_ring + tmp;
|
|
|
|
len = ETHER_MIN_LEN;
|
|
|
|
for (m = head; m; m = m->m_next) {
|
|
|
|
desc->buff.mbuf = m;
|
|
|
|
addr = kvtop(m->m_data);
|
|
|
|
desc->md->md0 = addr;
|
|
|
|
desc->md->md1 = ((addr >> 16) & 0xff);
|
|
|
|
desc->md->md3 = 0;
|
|
|
|
desc->md->md2 = -m->m_len;
|
|
|
|
sc->pending_transmits++;
|
|
|
|
len -= m->m_len;
|
|
|
|
|
|
|
|
INC_MD_PTR(tmp, sc->ntdre)
|
|
|
|
desc = sc->trans_ring + tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
end_of_packet = tmp;
|
|
|
|
DEC_MD_PTR(tmp, sc->ntdre)
|
|
|
|
desc = sc->trans_ring + tmp;
|
|
|
|
desc->md->md1 |= ENP;
|
|
|
|
|
|
|
|
if (len > 0)
|
|
|
|
desc->md->md2 -= len;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set OWN bits in reverse order, otherwise the Lance
|
|
|
|
* could start sending the packet before all the
|
|
|
|
* buffers have been relinquished by the host.
|
|
|
|
*/
|
|
|
|
|
|
|
|
while (tmp != sc->next_to_send) {
|
|
|
|
desc->md->md1 |= OWN;
|
|
|
|
DEC_MD_PTR(tmp, sc->ntdre)
|
|
|
|
desc = sc->trans_ring + tmp;
|
|
|
|
}
|
|
|
|
sc->next_to_send = end_of_packet;
|
|
|
|
desc->md->md1 |= STP | OWN;
|
|
|
|
} else {
|
|
|
|
sc->pending_transmits++;
|
|
|
|
desc = sc->trans_ring + sc->next_to_send;
|
|
|
|
len = mbuf_to_buffer(head, desc->buff.data);
|
|
|
|
desc->md->md3 = 0;
|
1998-03-09 03:07:54 +00:00
|
|
|
desc->md->md2 = -max(len, ETHER_MIN_LEN - ETHER_CRC_LEN);
|
1994-10-02 21:14:38 +00:00
|
|
|
desc->md->md1 |= OWN | STP | ENP;
|
|
|
|
INC_MD_PTR(sc->next_to_send, sc->ntdre)
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Force an immediate poll of the transmit ring */
|
2001-07-04 13:00:21 +00:00
|
|
|
lnc_outw(sc->rdp, TDMD | INEA);
|
1994-10-02 21:14:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set a timer so if the buggy Am7990.h shuts
|
|
|
|
* down we can wake it up.
|
|
|
|
*/
|
|
|
|
|
|
|
|
ifp->if_timer = 2;
|
|
|
|
|
2005-06-10 16:49:24 +00:00
|
|
|
BPF_MTAP(sc->ifp, head);
|
1994-10-02 21:14:38 +00:00
|
|
|
|
|
|
|
if (sc->nic.mem_mode != DMA_MBUF)
|
|
|
|
m_freem(head);
|
|
|
|
|
|
|
|
} while (sc->pending_transmits < NDESC(sc->ntdre));
|
|
|
|
|
|
|
|
/*
|
2005-08-25 05:01:24 +00:00
|
|
|
* Transmit ring is full so set IFF_DRV_OACTIVE
|
1994-10-02 21:14:38 +00:00
|
|
|
* since we can't buffer any more packets.
|
|
|
|
*/
|
|
|
|
|
2005-08-25 05:01:24 +00:00
|
|
|
sc->ifp->if_drv_flags |= IFF_DRV_OACTIVE;
|
1994-10-02 21:14:38 +00:00
|
|
|
LNCSTATS(trans_ring_full)
|
|
|
|
}
|
|
|
|
|
1995-10-31 18:41:49 +00:00
|
|
|
static int
|
1998-06-07 17:13:14 +00:00
|
|
|
lnc_ioctl(struct ifnet * ifp, u_long command, caddr_t data)
|
1994-10-02 21:14:38 +00:00
|
|
|
{
|
|
|
|
|
2000-12-16 01:33:28 +00:00
|
|
|
struct lnc_softc *sc = ifp->if_softc;
|
1994-10-02 21:14:38 +00:00
|
|
|
int s, error = 0;
|
|
|
|
|
|
|
|
s = splimp();
|
|
|
|
|
|
|
|
switch (command) {
|
|
|
|
case SIOCSIFFLAGS:
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (ifp->if_flags & IFF_DEBUG)
|
|
|
|
sc->lnc_debug = 1;
|
|
|
|
else
|
|
|
|
sc->lnc_debug = 0;
|
|
|
|
#endif
|
|
|
|
if (ifp->if_flags & IFF_PROMISC) {
|
|
|
|
if (!(sc->nic.mode & PROM)) {
|
|
|
|
sc->nic.mode |= PROM;
|
1996-07-18 22:03:47 +00:00
|
|
|
lnc_init(sc);
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
} else if (sc->nic.mode & PROM) {
|
|
|
|
sc->nic.mode &= ~PROM;
|
1996-07-18 22:03:47 +00:00
|
|
|
lnc_init(sc);
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
1999-01-31 00:39:20 +00:00
|
|
|
|
|
|
|
if ((ifp->if_flags & IFF_ALLMULTI) &&
|
|
|
|
!(sc->flags & LNC_ALLMULTI)) {
|
|
|
|
sc->flags |= LNC_ALLMULTI;
|
|
|
|
lnc_init(sc);
|
|
|
|
} else if (!(ifp->if_flags & IFF_ALLMULTI) &&
|
|
|
|
(sc->flags & LNC_ALLMULTI)) {
|
|
|
|
sc->flags &= ~LNC_ALLMULTI;
|
|
|
|
lnc_init(sc);
|
|
|
|
}
|
|
|
|
|
1994-10-02 21:14:38 +00:00
|
|
|
if ((ifp->if_flags & IFF_UP) == 0 &&
|
2005-08-25 05:01:24 +00:00
|
|
|
(ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
|
1994-10-02 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* If interface is marked down and it is running,
|
|
|
|
* then stop it.
|
|
|
|
*/
|
1996-07-18 22:03:47 +00:00
|
|
|
lnc_stop(sc);
|
2005-08-25 05:01:24 +00:00
|
|
|
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
1994-10-02 21:14:38 +00:00
|
|
|
} else if ((ifp->if_flags & IFF_UP) != 0 &&
|
2005-08-25 05:01:24 +00:00
|
|
|
(ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
|
1994-10-02 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* If interface is marked up and it is stopped, then
|
|
|
|
* start it.
|
|
|
|
*/
|
1996-07-18 22:03:47 +00:00
|
|
|
lnc_init(sc);
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SIOCADDMULTI:
|
|
|
|
case SIOCDELMULTI:
|
1999-01-31 00:39:20 +00:00
|
|
|
lnc_init(sc);
|
1997-01-13 21:26:53 +00:00
|
|
|
error = 0;
|
1994-10-02 21:14:38 +00:00
|
|
|
break;
|
|
|
|
default:
|
2002-11-14 23:54:55 +00:00
|
|
|
error = ether_ioctl(ifp, command, data);
|
|
|
|
break;
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
(void) splx(s);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
1995-10-31 18:41:49 +00:00
|
|
|
static void
|
1996-01-30 07:25:44 +00:00
|
|
|
lnc_watchdog(struct ifnet *ifp)
|
1994-10-02 21:14:38 +00:00
|
|
|
{
|
2003-10-31 18:32:15 +00:00
|
|
|
log(LOG_ERR, "%s: Device timeout -- Resetting\n", ifp->if_xname);
|
1996-01-30 07:25:44 +00:00
|
|
|
ifp->if_oerrors++;
|
1996-07-18 22:03:47 +00:00
|
|
|
lnc_reset(ifp->if_softc);
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
1999-01-12 00:36:36 +00:00
|
|
|
void
|
2000-12-16 01:33:28 +00:00
|
|
|
lnc_dump_state(struct lnc_softc *sc)
|
1994-10-02 21:14:38 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2005-06-10 16:49:24 +00:00
|
|
|
printf("\nDriver/NIC [%s] state dump\n", sc->ifp->if_xname);
|
1995-01-25 03:50:33 +00:00
|
|
|
printf("Memory access mode: %b\n", sc->nic.mem_mode, MEM_MODES);
|
|
|
|
printf("Host memory\n");
|
|
|
|
printf("-----------\n");
|
1994-10-02 21:14:38 +00:00
|
|
|
|
1998-08-24 02:28:16 +00:00
|
|
|
printf("Receive ring: base = %p, next = %p\n",
|
|
|
|
(void *)sc->recv_ring, (void *)(sc->recv_ring + sc->recv_next));
|
1994-10-02 21:14:38 +00:00
|
|
|
for (i = 0; i < NDESC(sc->nrdre); i++)
|
1998-08-24 02:28:16 +00:00
|
|
|
printf("\t%d:%p md = %p buff = %p\n",
|
|
|
|
i, (void *)(sc->recv_ring + i),
|
|
|
|
(void *)(sc->recv_ring + i)->md,
|
|
|
|
(void *)(sc->recv_ring + i)->buff.data);
|
1994-10-02 21:14:38 +00:00
|
|
|
|
1998-08-24 02:28:16 +00:00
|
|
|
printf("Transmit ring: base = %p, next = %p\n",
|
|
|
|
(void *)sc->trans_ring, (void *)(sc->trans_ring + sc->trans_next));
|
1994-10-02 21:14:38 +00:00
|
|
|
for (i = 0; i < NDESC(sc->ntdre); i++)
|
1998-08-24 02:28:16 +00:00
|
|
|
printf("\t%d:%p md = %p buff = %p\n",
|
|
|
|
i, (void *)(sc->trans_ring + i),
|
|
|
|
(void *)(sc->trans_ring + i)->md,
|
|
|
|
(void *)(sc->trans_ring + i)->buff.data);
|
1995-01-25 03:50:33 +00:00
|
|
|
printf("Lance memory (may be on host(DMA) or card(SHMEM))\n");
|
1998-08-24 02:28:16 +00:00
|
|
|
printf("Init block = %p\n", (void *)sc->init_block);
|
1995-01-25 03:50:33 +00:00
|
|
|
printf("\tmode = %b rlen:rdra = %x:%x tlen:tdra = %x:%x\n",
|
1994-10-02 21:14:38 +00:00
|
|
|
sc->init_block->mode, INIT_MODE, sc->init_block->rlen,
|
|
|
|
sc->init_block->rdra, sc->init_block->tlen, sc->init_block->tdra);
|
1995-01-25 03:50:33 +00:00
|
|
|
printf("Receive descriptor ring\n");
|
1994-10-02 21:14:38 +00:00
|
|
|
for (i = 0; i < NDESC(sc->nrdre); i++)
|
1995-01-25 03:50:33 +00:00
|
|
|
printf("\t%d buffer = 0x%x%x, BCNT = %d,\tMCNT = %u,\tflags = %b\n",
|
1994-10-02 21:14:38 +00:00
|
|
|
i, ((sc->recv_ring + i)->md->md1 & HADR),
|
|
|
|
(sc->recv_ring + i)->md->md0,
|
|
|
|
-(short) (sc->recv_ring + i)->md->md2,
|
|
|
|
(sc->recv_ring + i)->md->md3,
|
|
|
|
(((sc->recv_ring + i)->md->md1 & ~HADR) >> 8), RECV_MD1);
|
1995-01-25 03:50:33 +00:00
|
|
|
printf("Transmit descriptor ring\n");
|
1994-10-02 21:14:38 +00:00
|
|
|
for (i = 0; i < NDESC(sc->ntdre); i++)
|
1995-01-25 03:50:33 +00:00
|
|
|
printf("\t%d buffer = 0x%x%x, BCNT = %d,\tflags = %b %b\n",
|
1994-10-02 21:14:38 +00:00
|
|
|
i, ((sc->trans_ring + i)->md->md1 & HADR),
|
|
|
|
(sc->trans_ring + i)->md->md0,
|
|
|
|
-(short) (sc->trans_ring + i)->md->md2,
|
|
|
|
((sc->trans_ring + i)->md->md1 >> 8), TRANS_MD1,
|
|
|
|
((sc->trans_ring + i)->md->md3 >> 10), TRANS_MD3);
|
1995-01-25 03:50:33 +00:00
|
|
|
printf("\nnext_to_send = %x\n", sc->next_to_send);
|
1998-08-24 02:28:16 +00:00
|
|
|
printf("\n CSR0 = %b CSR1 = %x CSR2 = %x CSR3 = %x\n\n",
|
|
|
|
read_csr(sc, CSR0), CSR0_FLAGS, read_csr(sc, CSR1),
|
|
|
|
read_csr(sc, CSR2), read_csr(sc, CSR3));
|
1998-09-17 13:09:16 +00:00
|
|
|
|
1994-10-02 21:14:38 +00:00
|
|
|
/* Set RAP back to CSR0 */
|
2001-07-04 13:00:21 +00:00
|
|
|
lnc_outw(sc->rap, CSR0);
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
|
1999-01-12 00:36:36 +00:00
|
|
|
void
|
1994-10-02 21:14:38 +00:00
|
|
|
mbuf_dump_chain(struct mbuf * m)
|
|
|
|
{
|
|
|
|
|
|
|
|
#define MBUF_FLAGS \
|
|
|
|
"\20\1M_EXT\2M_PKTHDR\3M_EOR\4UNKNOWN\5M_BCAST\6M_MCAST"
|
|
|
|
|
|
|
|
if (!m)
|
|
|
|
log(LOG_DEBUG, "m == NULL\n");
|
|
|
|
do {
|
1998-08-24 02:28:16 +00:00
|
|
|
log(LOG_DEBUG, "m = %p\n", (void *)m);
|
|
|
|
log(LOG_DEBUG, "m_hdr.mh_next = %p\n",
|
|
|
|
(void *)m->m_hdr.mh_next);
|
|
|
|
log(LOG_DEBUG, "m_hdr.mh_nextpkt = %p\n",
|
|
|
|
(void *)m->m_hdr.mh_nextpkt);
|
1994-10-02 21:14:38 +00:00
|
|
|
log(LOG_DEBUG, "m_hdr.mh_len = %d\n", m->m_hdr.mh_len);
|
1998-08-24 02:28:16 +00:00
|
|
|
log(LOG_DEBUG, "m_hdr.mh_data = %p\n",
|
|
|
|
(void *)m->m_hdr.mh_data);
|
1994-10-02 21:14:38 +00:00
|
|
|
log(LOG_DEBUG, "m_hdr.mh_type = %d\n", m->m_hdr.mh_type);
|
1998-08-24 02:28:16 +00:00
|
|
|
log(LOG_DEBUG, "m_hdr.mh_flags = %b\n", m->m_hdr.mh_flags,
|
|
|
|
MBUF_FLAGS);
|
1994-10-02 21:14:38 +00:00
|
|
|
if (!(m->m_hdr.mh_flags & (M_PKTHDR | M_EXT)))
|
1998-08-24 02:28:16 +00:00
|
|
|
log(LOG_DEBUG, "M_dat.M_databuf = %p\n",
|
|
|
|
(void *)m->M_dat.M_databuf);
|
1994-10-02 21:14:38 +00:00
|
|
|
else {
|
|
|
|
if (m->m_hdr.mh_flags & M_PKTHDR) {
|
1998-08-24 02:28:16 +00:00
|
|
|
log(LOG_DEBUG, "M_dat.MH.MH_pkthdr.len = %d\n",
|
|
|
|
m->M_dat.MH.MH_pkthdr.len);
|
|
|
|
log(LOG_DEBUG,
|
|
|
|
"M_dat.MH.MH_pkthdr.rcvif = %p\n",
|
|
|
|
(void *)m->M_dat.MH.MH_pkthdr.rcvif);
|
1994-10-02 21:14:38 +00:00
|
|
|
if (!(m->m_hdr.mh_flags & M_EXT))
|
1998-08-24 02:28:16 +00:00
|
|
|
log(LOG_DEBUG,
|
|
|
|
"M_dat.MH.MH_dat.MH_databuf = %p\n",
|
|
|
|
(void *)m->M_dat.MH.MH_dat.MH_databuf);
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
if (m->m_hdr.mh_flags & M_EXT) {
|
1998-08-24 02:28:16 +00:00
|
|
|
log(LOG_DEBUG,
|
|
|
|
"M_dat.MH.MH_dat.MH_ext.ext_buff %p\n",
|
|
|
|
(void *)m->M_dat.MH.MH_dat.MH_ext.ext_buf);
|
|
|
|
log(LOG_DEBUG,
|
|
|
|
"M_dat.MH.MH_dat.MH_ext.ext_free %p\n",
|
|
|
|
(void *)m->M_dat.MH.MH_dat.MH_ext.ext_free);
|
|
|
|
log(LOG_DEBUG,
|
|
|
|
"M_dat.MH.MH_dat.MH_ext.ext_size %d\n",
|
|
|
|
m->M_dat.MH.MH_dat.MH_ext.ext_size);
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
}
|
1999-05-06 18:44:42 +00:00
|
|
|
} while ((m = m->m_next) != NULL);
|
1994-10-02 21:14:38 +00:00
|
|
|
}
|
|
|
|
#endif
|