Stop embedding struct ifnet at the top of driver softcs. Instead the

struct ifnet or the layer 2 common structure it was embedded in have
been replaced with a struct ifnet pointer to be filled by a call to the
new function, if_alloc(). The layer 2 common structure is also allocated
via if_alloc() based on the interface type. It is hung off the new
struct ifnet member, if_l2com.

This change removes the size of these structures from the kernel ABI and
will allow us to better manage them as interfaces come and go.

Other changes of note:
 - Struct arpcom is no longer referenced in normal interface code.
   Instead the Ethernet address is accessed via the IFP2ENADDR() macro.
   To enforce this ac_enaddr has been renamed to _ac_enaddr.
 - The second argument to ether_ifattach is now always the mac address
   from driver private storage rather than sometimes being ac_enaddr.

Reviewed by:	sobomax, sam
This commit is contained in:
Brooks Davis 2005-06-10 16:49:24 +00:00
parent 7f1d8b7517
commit fc74a9f93a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=147256
290 changed files with 4465 additions and 3774 deletions

View File

@ -46,9 +46,17 @@
.In net/if_types.h
.\"
.Ss "Interface Manipulation Functions"
.Ft "struct ifnet *"
.Fn if_alloc "u_char type"
.Ft void
.Fn if_attach "struct ifnet *ifp"
.Ft void
.Fn if_detach "struct ifnet *ifp"
.Ft void
.Fn if_free "struct ifnet *ifp"
.Ft void
.Fn if_free_type "struct ifnet *ifp" "u_char type"
.Ft void
.Fn if_down "struct ifnet *ifp"
.Ft int
.Fn ifioctl "struct socket *so" "u_long cmd" "caddr_t data" "struct thread *td"
@ -219,6 +227,11 @@ are as follows:
.Pq Vt "void *"
A pointer to the driver's private state block.
(Initialized by driver.)
.It Va if_l2com
.Pq Vt "void *"
A pointer to the common data for the interface's layer 2 protocol.
(Initialized by
.Fn if_alloc . )
.It Va if_link
.Pq Fn TAILQ_ENTRY ifnet
.Xr queue 3
@ -270,6 +283,8 @@ This number can be used in a
to refer to a particular interface by index
(see
.Xr link_addr 3 ) .
(Initialized by
.Fn if_alloc . )
.It Va if_timer
.Pq Vt short
Number of seconds until the watchdog timer
@ -988,6 +1003,14 @@ A reference count of requests for this particular membership.
.El
.Ss Interface Manipulation Functions
.Bl -ohang -offset indent
.It Fn if_alloc
Allocate and initialize an
.Fa ifp .
Initalization includes the allocation of an interface index and may
include the allocation of a
.Fa type
specific structure in
.Va if_l2com .
.It Fn if_attach
Link the specified interface
.Fa ifp
@ -999,6 +1022,29 @@ structure to be the first element in that list.
(A pointer to
this address structure is saved in the global array
.Va ifnet_addrs . )
The
.Fa ifp
must have been allocted by
.Fn if_alloc .
.It Fn if_detach
Shut down and unlink the specified
.Fa ifp
from the interface list.
.It Fn if_free
Free the given
.Fa ifp
back to the system.
The interface must have been previously detached if it was ever attached.
.It Fn if_free_type
Identical to
.Fn if_free
except that the given
.Fa type
is used to free
.Va if_l2com
instead of the type in
.Va if_type .
This is intended for use with drivers that change their interface type.
.It Fn if_down
Mark the interface
.Fa ifp

View File

@ -231,7 +231,7 @@ ndis_status_func(adapter, status, sbuf, slen)
block = adapter;
sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
if (ifp->if_flags & IFF_DEBUG)
device_printf (sc->ndis_dev, "status: %x\n", status);
return;
@ -247,7 +247,7 @@ ndis_statusdone_func(adapter)
block = adapter;
sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
if (ifp->if_flags & IFF_DEBUG)
device_printf (sc->ndis_dev, "status complete\n");
return;
@ -291,7 +291,7 @@ ndis_resetdone_func(adapter, status, addressingreset)
block = adapter;
sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
if (ifp->if_flags & IFF_DEBUG)
device_printf (sc->ndis_dev, "reset done...\n");

View File

@ -1058,7 +1058,7 @@ NdisWriteErrorLogEntry(ndis_handle adapter, ndis_error_code code,
dev = block->nmb_physdeviceobj->do_devext;
drv = block->nmb_deviceobj->do_drvobj;
sc = device_get_softc(dev);
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
error = pe_get_message((vm_offset_t)drv->dro_driverstart,
code, &str, &i, &flags);
@ -1404,10 +1404,10 @@ NdisReadNetworkAddress(status, addr, addrlen, adapter)
block = (ndis_miniport_block *)adapter;
sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
if (bcmp(sc->arpcom.ac_enaddr, empty, ETHER_ADDR_LEN) == 0)
if (bcmp(IFP2ENADDR(sc->ifp), empty, ETHER_ADDR_LEN) == 0)
*status = NDIS_STATUS_FAILURE;
else {
*addr = sc->arpcom.ac_enaddr;
*addr = IFP2ENADDR(sc->ifp);
*addrlen = ETHER_ADDR_LEN;
*status = NDIS_STATUS_SUCCESS;
}

View File

@ -331,7 +331,7 @@ dscp2index(u_int8_t dscp)
* use m_pkthdr.rcvif to pass this info.
*/
#define RIOM_SET_PRECINDEX(m, idx) \
do { (m)->m_pkthdr.rcvif = (struct ifnet *)((long)(idx)); } while (0)
do { (m)->m_pkthdr.rcvif = (void *)((long)(idx)); } while (0)
#define RIOM_GET_PRECINDEX(m) \
({ long idx; idx = (long)((m)->m_pkthdr.rcvif); \
(m)->m_pkthdr.rcvif = NULL; idx; })

View File

@ -44,6 +44,7 @@
#include <net/if_arp.h>
#include <net/iso88025.h>
#include <net/if_media.h>
#include <net/if_types.h>
#include <net/bpf.h>
#ifndef BPF_MTAP
@ -131,9 +132,15 @@ oltr_attach(device_t dev)
{
struct oltr_softc *sc = device_get_softc(dev);
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp;
int rc = 0;
int media = IFM_TOKEN|IFM_TOK_UTP16;
ifp = sc->ifp = if_alloc(IFT_ISO88025);
if (ifp == NULL) {
device_printf(dev, "couldn't if_alloc()");
return (-1);
}
/*
* Allocate interrupt and DMA channel
@ -164,7 +171,7 @@ oltr_attach(device_t dev)
ifp->if_ioctl = oltr_ioctl;
ifp->if_flags = IFF_BROADCAST | IFF_NEEDSGIANT;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
bcopy(sc->config.macaddress, sc->arpcom.ac_enaddr, sizeof(sc->config.macaddress));
bcopy(sc->config.macaddress, IFP2ENADDR(sc->ifp), sizeof(sc->config.macaddress));
/*
* Do ifmedia setup.
@ -312,7 +319,7 @@ oltr_close(struct oltr_softc *sc)
void
oltr_stop(struct oltr_softc *sc)
{
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->ifp;
/*printf("oltr%d: oltr_stop\n", sc->unit);*/
@ -325,7 +332,7 @@ static void
oltr_init(void * xsc)
{
struct oltr_softc *sc = (struct oltr_softc *)xsc;
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->ifp;
struct ifmedia *ifm = &sc->ifmedia;
int poll = 0, i, rc = 0, s;
int work_size;
@ -480,7 +487,7 @@ oltr_init(void * xsc)
/*
* Open the adapter
*/
rc = TRlldOpen(sc->TRlldAdapter, sc->arpcom.ac_enaddr, sc->GroupAddress,
rc = TRlldOpen(sc->TRlldAdapter, IFP2ENADDR(sc->ifp), sc->GroupAddress,
sc->FunctionalAddress, 1552, sc->AdapterMode);
switch(rc) {
case TRLLD_OPEN_OK:
@ -739,7 +746,7 @@ static void
DriverStatus(void *DriverHandle, TRlldStatus_t *Status)
{
struct oltr_softc *sc = (struct oltr_softc *)DriverHandle;
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->ifp;
char *Protocol[] = { /* 0 */ "Unknown",
/* 1 */ "TKP",
@ -881,7 +888,7 @@ static void
DriverTransmitFrameCompleted(void *DriverHandle, void *FrameHandle, int TransmitStatus)
{
struct oltr_softc *sc = (struct oltr_softc *)DriverHandle;
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->ifp;
TRlldTransmit_t *frame = (TRlldTransmit_t *)FrameHandle;
/*printf("oltr%d: DriverTransmitFrameCompleted\n", sc->unit);*/
@ -908,7 +915,7 @@ static void
DriverReceiveFrameCompleted(void *DriverHandle, int ByteCount, int FragmentCount, void *FragmentHandle, int ReceiveStatus)
{
struct oltr_softc *sc = (struct oltr_softc *)DriverHandle;
struct ifnet *ifp = (struct ifnet *)&sc->arpcom.ac_if;
struct ifnet *ifp = sc->ifp;
struct mbuf *m0, *m1, *m;
int frame_len = ByteCount, i = (int)FragmentHandle, rc, s;
int mbuf_offset, mbuf_size, frag_offset, copy_length;

View File

@ -233,7 +233,7 @@ static int
oltr_pci_detach(device_t dev)
{
struct oltr_softc *sc = device_get_softc(dev);
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->ifp;
int s, i;
device_printf(dev, "driver unloading\n");
@ -241,6 +241,7 @@ oltr_pci_detach(device_t dev)
s = splimp();
iso88025_ifdetach(ifp, ISO88025_BPF_SUPPORTED);
if_free(ifp);
if (sc->state > OL_CLOSED)
oltr_stop(sc);

View File

@ -68,7 +68,7 @@ struct oltr_tx_buf {
#define TX_BUFFER_LEN 2048
struct oltr_softc {
struct arpcom arpcom;
struct ifnet *ifp;
struct ifmedia ifmedia;
bus_space_handle_t oltr_bhandle;
bus_space_tag_t oltr_btag;

View File

@ -127,7 +127,7 @@ extern int ifqmaxlen;
#ifdef __FreeBSD__
static MALLOC_DEFINE(M_PFLOG, PFLOGNAME, "Packet Filter Logging Interface");
static LIST_HEAD(pflog_list, pflog_softc) pflog_list;
#define SCP2IFP(sc) (&(sc)->sc_if)
#define SCP2IFP(sc) ((sc)->sc_ifp)
IFC_SIMPLE_DECLARE(pflog, 1);
static void
@ -144,6 +144,7 @@ pflog_clone_destroy(struct ifnet *ifp)
bpfdetach(ifp);
if_detach(ifp);
if_free(ifp);
LIST_REMOVE(sc, sc_next);
free(sc, M_PFLOG);
}
@ -155,14 +156,17 @@ pflog_clone_create(struct if_clone *ifc, int unit)
struct ifnet *ifp;
MALLOC(sc, struct pflog_softc *, sizeof(*sc), M_PFLOG, M_WAITOK|M_ZERO);
ifp = sc->sc_ifp = if_alloc(IFT_PFLOG);
if (ifp == NULL) {
free(sc, M_PFLOG);
return (ENOSPC);
}
ifp = SCP2IFP(sc);
if_initname(ifp, ifc->ifc_name, unit);
ifp->if_mtu = PFLOGMTU;
ifp->if_ioctl = pflogioctl;
ifp->if_output = pflogoutput;
ifp->if_start = pflogstart;
ifp->if_type = IFT_PFLOG;
ifp->if_snd.ifq_maxlen = ifqmaxlen;
ifp->if_hdrlen = PFLOG_HDRLEN;
ifp->if_softc = sc;

View File

@ -30,9 +30,11 @@
#define _NET_IF_PFLOG_H_
struct pflog_softc {
struct ifnet sc_if; /* the interface */
#ifdef __FreeBSD__
struct ifnet *sc_ifp; /* the interface */
LIST_ENTRY(pflog_softc) sc_next;
#else
struct ifnet sc_if; /* the interface */
#endif
};

View File

@ -161,7 +161,7 @@ extern int hz;
#ifdef __FreeBSD__
static MALLOC_DEFINE(M_PFSYNC, PFSYNCNAME, "Packet Filter State Sync. Interface");
static LIST_HEAD(pfsync_list, pfsync_softc) pfsync_list;
#define SCP2IFP(sc) (&(sc)->sc_if)
#define SCP2IFP(sc) ((sc)->sc_ifp)
IFC_SIMPLE_DECLARE(pfsync, 1);
static void
@ -178,6 +178,7 @@ pfsync_clone_destroy(struct ifnet *ifp)
bpfdetach(ifp);
#endif
if_detach(ifp);
if_free(ifp);
LIST_REMOVE(sc, sc_next);
free(sc, M_PFSYNC);
}
@ -190,6 +191,11 @@ pfsync_clone_create(struct if_clone *ifc, int unit)
MALLOC(sc, struct pfsync_softc *, sizeof(*sc), M_PFSYNC,
M_WAITOK|M_ZERO);
ifp = sc->sc_ifp = if_alloc(IFT_PFSYNC);
if (ifp == NULL) {
free(sc, M_PFSYNC);
return (ENOSPC);
}
pfsync_sync_ok = 1;
sc->sc_mbuf = NULL;
@ -206,7 +212,6 @@ pfsync_clone_create(struct if_clone *ifc, int unit)
ifp->if_ioctl = pfsyncioctl;
ifp->if_output = pfsyncoutput;
ifp->if_start = pfsyncstart;
ifp->if_type = IFT_PFSYNC;
ifp->if_snd.ifq_maxlen = ifqmaxlen;
ifp->if_hdrlen = PFSYNC_HDRLEN;
ifp->if_baudrate = IF_Mbps(100);

View File

@ -147,7 +147,11 @@ union sc_statep {
extern int pfsync_sync_ok;
struct pfsync_softc {
#ifdef __FreeBSD__
struct ifnet *sc_ifp;
#else
struct ifnet sc_if;
#endif
struct ifnet *sc_sync_ifp;
struct ip_moptions sc_imo;

View File

@ -669,14 +669,19 @@ an_attach(sc, unit, flags)
int unit;
int flags;
{
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp;
int error = EIO;
int i, nrate, mword;
u_int8_t r;
mtx_init(&sc->an_mtx, device_get_nameunit(sc->an_dev), MTX_NETWORK_LOCK,
MTX_DEF | MTX_RECURSE);
ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
printf("an%d: can not if_alloc()\n", sc->an_unit);
goto fail;
}
sc->an_gone = 0;
sc->an_associated = 0;
sc->an_monitor = 0;
@ -746,9 +751,6 @@ an_attach(sc, unit, flags)
}
#endif
bcopy((char *)&sc->an_caps.an_oemaddr,
(char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
ifp->if_softc = sc;
sc->an_unit = unit;
if_initname(ifp, device_get_name(sc->an_dev),
@ -806,12 +808,15 @@ an_attach(sc, unit, flags)
/*
* Call MI attach routine.
*/
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
ether_ifattach(ifp, sc->an_caps.an_oemaddr);
callout_handle_init(&sc->an_stat_ch);
return(0);
fail:;
mtx_destroy(&sc->an_mtx);
if (ifp != NULL)
if_free(ifp);
return(error);
}
@ -819,7 +824,7 @@ int
an_detach(device_t dev)
{
struct an_softc *sc = device_get_softc(dev);
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->an_ifp;
if (sc->an_gone) {
device_printf(dev,"already unloaded\n");
@ -830,6 +835,7 @@ an_detach(device_t dev)
ifmedia_removeall(&sc->an_ifmedia);
ifp->if_flags &= ~IFF_RUNNING;
ether_ifdetach(ifp);
if_free(ifp);
sc->an_gone = 1;
AN_UNLOCK(sc);
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
@ -857,7 +863,7 @@ an_rxeof(sc)
AN_LOCK_ASSERT(sc);
ifp = &sc->arpcom.ac_if;
ifp = sc->an_ifp;
if (!sc->mpi350) {
id = CSR_READ_2(sc, AN_RX_FID);
@ -1109,7 +1115,7 @@ an_txeof(sc, status)
struct ifnet *ifp;
int id, i;
ifp = &sc->arpcom.ac_if;
ifp = sc->an_ifp;
ifp->if_timer = 0;
ifp->if_flags &= ~IFF_OACTIVE;
@ -1162,7 +1168,7 @@ an_stats_update(xsc)
sc = xsc;
AN_LOCK(sc);
ifp = &sc->arpcom.ac_if;
ifp = sc->an_ifp;
sc->an_status.an_type = AN_RID_STATUS;
sc->an_status.an_len = sizeof(struct an_ltv_status);
@ -1207,7 +1213,7 @@ an_intr(xsc)
return;
}
ifp = &sc->arpcom.ac_if;
ifp = sc->an_ifp;
/* Disable interrupts. */
CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), 0);
@ -1784,7 +1790,7 @@ an_setdef(sc, areq)
struct an_ltv_aplist *ap;
struct an_ltv_gen *sp;
ifp = &sc->arpcom.ac_if;
ifp = sc->an_ifp;
switch (areq->an_type) {
case AN_RID_GENCONFIG:
@ -1792,7 +1798,7 @@ an_setdef(sc, areq)
ifa = ifaddr_byindex(ifp->if_index);
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
bcopy((char *)&cfg->an_macaddr, (char *)&sc->arpcom.ac_enaddr,
bcopy((char *)&cfg->an_macaddr, IFP2ENADDR(sc->an_ifp),
ETHER_ADDR_LEN);
bcopy((char *)&cfg->an_macaddr, LLADDR(sdl), ETHER_ADDR_LEN);
@ -2529,7 +2535,7 @@ an_init(xsc)
void *xsc;
{
struct an_softc *sc = xsc;
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->an_ifp;
AN_LOCK(sc);
@ -2557,7 +2563,7 @@ an_init(xsc)
}
/* Set our MAC address. */
bcopy((char *)&sc->arpcom.ac_enaddr,
bcopy((char *)IFP2ENADDR(sc->an_ifp),
(char *)&sc->an_config.an_macaddr, ETHER_ADDR_LEN);
if (ifp->if_flags & IFF_BROADCAST)
@ -2834,7 +2840,7 @@ an_stop(sc)
return;
}
ifp = &sc->arpcom.ac_if;
ifp = sc->an_ifp;
an_cmd(sc, AN_CMD_FORCE_SYNCLOSS, 0);
CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), 0);
@ -2907,7 +2913,7 @@ an_resume(dev)
sc = device_get_softc(dev);
AN_LOCK(sc);
ifp = &sc->arpcom.ac_if;
ifp = sc->an_ifp;
sc->an_gone = 0;
an_reset(sc);

View File

@ -440,7 +440,7 @@ struct an_tx_ring_data {
};
struct an_softc {
struct arpcom arpcom;
struct ifnet *an_ifp;
int an_unit;

View File

@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$");
#include <dev/ar/if_ar.h>
#else /* NETGRAPH */
#include <net/if_sppp.h>
#include <net/if_types.h>
#include <net/bpf.h>
#endif /* NETGRAPH */
@ -90,7 +91,7 @@ devclass_t ar_devclass;
struct ar_softc {
#ifndef NETGRAPH
struct sppp ifsppp;
struct ifnet *ifp;
#endif /* NETGRAPH */
int unit; /* With regards to all ar devices */
int subunit; /* With regards to this card */
@ -144,6 +145,7 @@ struct ar_softc {
u_long opackets, ipackets;
#endif /* NETGRAPH */
};
#define SC2IFP(sc) (sc)->ifp
static int next_ar_unit = 0;
@ -281,7 +283,14 @@ ar_attach(device_t device)
ar_init_msci(sc);
#ifndef NETGRAPH
ifp = &sc->ifsppp.pp_if;
ifp = SC2IFP(sc) = if_alloc(IFT_PPP);
if (ifp == NULL) {
if (BUS_TEARDOWN_INTR(device_get_parent(device), device,
hc->res_irq, hc->intr_cookie) != 0) {
printf("intr teardown failed.. continuing\n");
}
return (1);
}
ifp->if_softc = sc;
if_initname(ifp, device_get_name(device),
@ -293,7 +302,7 @@ ar_attach(device_t device)
ifp->if_start = arstart;
ifp->if_watchdog = arwatchdog;
sc->ifsppp.pp_flags = PP_KEEPALIVE;
IFP2SP(sc->ifp)->pp_flags = PP_KEEPALIVE;
switch(hc->interface[unit]) {
default: iface = "UNKNOWN"; break;
@ -310,7 +319,7 @@ ar_attach(device_t device)
sc->subunit,
iface);
sppp_attach((struct ifnet *)&sc->ifsppp);
sppp_attach(SC2IFP(sc));
if_attach(ifp);
bpfattach(ifp, DLT_PPP, PPP_HEADER_LEN);
@ -562,7 +571,7 @@ ar_xmit(struct ar_softc *sc)
dmac_channel *dmac;
#ifndef NETGRAPH
ifp = &sc->ifsppp.pp_if;
ifp = SC2IFP(sc);
#endif /* NETGRAPH */
dmac = &sc->sca->dmac[DMAC_TXCH(sc->scachan)];
@ -695,7 +704,7 @@ arstart(struct ar_softc *sc)
#ifndef NETGRAPH
BPF_MTAP(ifp, mtx);
m_freem(mtx);
++sc->ifsppp.pp_if.if_opackets;
++SC2IFP(sc)->if_opackets;
#else /* NETGRAPH */
m_freem(mtx);
sc->outbytes += len;
@ -822,7 +831,7 @@ arwatchdog(struct ar_softc *sc)
if(sc->hc->bustype == AR_BUS_ISA)
ARC_SET_SCA(sc->hc, sc->scano);
/* XXX if(sc->ifsppp.pp_if.if_flags & IFF_DEBUG) */
/* XXX if(SC2IFP(sc)->if_flags & IFF_DEBUG) */
printf("ar%d: transmit failed, "
"ST0 %x, ST1 %x, ST3 %x, DSR %x.\n",
sc->unit,
@ -1680,7 +1689,7 @@ ar_get_packets(struct ar_softc *sc)
continue;
}
#ifndef NETGRAPH
m->m_pkthdr.rcvif = &sc->ifsppp.pp_if;
m->m_pkthdr.rcvif = SC2IFP(sc);
#else /* NETGRAPH */
m->m_pkthdr.rcvif = NULL;
sc->inbytes += len;
@ -1697,9 +1706,9 @@ ar_get_packets(struct ar_softc *sc)
}
ar_copy_rxbuf(m, sc, len);
#ifndef NETGRAPH
BPF_MTAP(&sc->ifsppp.pp_if, m);
sppp_input(&sc->ifsppp.pp_if, m);
sc->ifsppp.pp_if.if_ipackets++;
BPF_MTAP(SC2IFP(sc), m);
sppp_input(SC2IFP(sc), m);
SC2IFP(sc)->if_ipackets++;
#else /* NETGRAPH */
NG_SEND_DATA_ONLY(error, sc->hook, m);
sc->ipackets++;
@ -1737,7 +1746,7 @@ ar_get_packets(struct ar_softc *sc)
ar_eat_packet(sc, 1);
#ifndef NETGRAPH
sc->ifsppp.pp_if.if_ierrors++;
SC2IFP(sc)->if_ierrors++;
#else /* NETGRAPH */
sc->ierrors[0]++;
#endif /* NETGRAPH */
@ -1810,8 +1819,8 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
"txpacket no %lu.\n",
sc->unit,
#ifndef NETGRAPH
sc->ifsppp.pp_if.if_opackets);
sc->ifsppp.pp_if.if_oerrors++;
SC2IFP(sc)->if_opackets);
SC2IFP(sc)->if_oerrors++;
#else /* NETGRAPH */
sc->opackets);
sc->oerrors++;
@ -1825,7 +1834,7 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
"cda %04x, eda %04x.\n",
sc->unit,
#ifndef NETGRAPH
sc->ifsppp.pp_if.if_opackets,
SC2IFP(sc)->if_opackets,
#else /* NETGRAPH */
sc->opackets,
#endif /* NETGRAPH */
@ -1833,7 +1842,7 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
dmac->cda,
dmac->eda);
#ifndef NETGRAPH
sc->ifsppp.pp_if.if_oerrors++;
SC2IFP(sc)->if_oerrors++;
#else /* NETGRAPH */
sc->oerrors++;
#endif /* NETGRAPH */
@ -1851,10 +1860,10 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
*/
sc->xmit_busy = 0;
#ifndef NETGRAPH
sc->ifsppp.pp_if.if_flags &= ~IFF_OACTIVE;
sc->ifsppp.pp_if.if_timer = 0;
SC2IFP(sc)->if_flags &= ~IFF_OACTIVE;
SC2IFP(sc)->if_timer = 0;
#else /* NETGRAPH */
/* XXX c->ifsppp.pp_if.if_flags &= ~IFF_OACTIVE; */
/* XXX SC2IFP(sc)->if_flags &= ~IFF_OACTIVE; */
sc->out_dog = 0; /* XXX */
#endif /* NETGRAPH */
@ -1879,12 +1888,12 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
/* End of frame */
if(dsr & SCA_DSR_EOM) {
TRC(int tt = sc->ifsppp.pp_if.if_ipackets;)
TRC(int tt = SC2IFP(sc)->if_ipackets;)
TRC(int ind = sc->rxhind;)
ar_get_packets(sc);
#ifndef NETGRAPH
#define IPACKETS sc->ifsppp.pp_if.if_ipackets
#define IPACKETS SC2IFP(sc)->if_ipackets
#else /* NETGRAPH */
#define IPACKETS sc->ipackets
#endif /* NETGRAPH */
@ -1933,8 +1942,8 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
"rxpkts %lu.\n",
sc->unit,
#ifndef NETGRAPH
sc->ifsppp.pp_if.if_ipackets);
sc->ifsppp.pp_if.if_ierrors++;
SC2IFP(sc)->if_ipackets);
SC2IFP(sc)->if_ierrors++;
#else /* NETGRAPH */
sc->ipackets);
sc->ierrors[1]++;
@ -1950,7 +1959,7 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
"cda %x, eda %x, dsr %x.\n",
sc->unit,
#ifndef NETGRAPH
sc->ifsppp.pp_if.if_ipackets,
SC2IFP(sc)->if_ipackets,
#else /* NETGRAPH */
sc->ipackets,
#endif /* NETGRAPH */
@ -1964,7 +1973,7 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
*/
ar_eat_packet(sc, 0);
#ifndef NETGRAPH
sc->ifsppp.pp_if.if_ierrors++;
SC2IFP(sc)->if_ierrors++;
#else /* NETGRAPH */
sc->ierrors[2]++;
#endif /* NETGRAPH */
@ -1977,7 +1986,7 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
"rxpkts %lu, rxind %d, "
"cda %x, eda %x, dsr %x. After\n",
sc->unit,
sc->ifsppp.pp_if.if_ipackets,
SC2IFP(sc)->if_ipackets,
sc->rxhind,
dmac->cda,
dmac->eda,
@ -1996,8 +2005,8 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
printf("ar%d: RX End of transfer, rxpkts %lu.\n",
sc->unit,
#ifndef NETGRAPH
sc->ifsppp.pp_if.if_ipackets);
sc->ifsppp.pp_if.if_ierrors++;
SC2IFP(sc)->if_ipackets);
SC2IFP(sc)->if_ierrors++;
#else /* NETGRAPH */
sc->ipackets);
sc->ierrors[3]++;
@ -2018,7 +2027,7 @@ ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
if(dotxstart & 0x0C) {
sc = &hc->sc[mch + (NCHAN * scano)];
#ifndef NETGRAPH
arstart(&sc->ifsppp.pp_if);
arstart(SC2IFP(sc));
#else /* NETGRAPH */
arstart(sc);
#endif /* NETGRAPH */

View File

@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
#include <net/if.h>
#include <net/if_arp.h>
#include <net/if_media.h>
#include <net/if_types.h>
#include <net/ethernet.h>
#include <net80211/ieee80211_var.h>
@ -109,7 +110,7 @@ __FBSDID("$FreeBSD$");
#define BROADCASTADDR (etherbroadcastaddr)
#define _ARL_CURPROC (curproc)
#else
#define BROADCASTADDR (sc->arpcom.ac_if.if_broadcastaddr)
#define BROADCASTADDR (sc->arl_ifp->if_broadcastaddr)
#define _ARL_CURPROC (curthread)
#endif
@ -188,11 +189,15 @@ arl_attach(dev)
device_t dev;
{
struct arl_softc* sc = device_get_softc(dev);
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp;
int attached, configured = 0;
D(("attach\n"));
ifp = sc->arl_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL)
return (ENOSPC);
configured = ar->configuredStatusFlag;
attached = (ifp->if_softc != 0);
@ -248,7 +253,7 @@ arl_attach(dev)
#if __FreeBSD_version < 500100
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
#else
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
ether_ifattach(ifp, ar->lanCardNodeId);
#endif
}
@ -734,7 +739,7 @@ arl_init(xsc)
void *xsc;
{
struct arl_softc *sc = xsc;
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->arl_ifp;
int s;
D(("init\n"));
@ -768,7 +773,7 @@ arl_put(sc)
int i;
if (ARL_CHECKREG(sc))
sc->arpcom.ac_if.if_oerrors++;
sc->arl_ifp->if_oerrors++;
/* copy dst adr */
for(i = 0; i < 6; i++)
@ -802,7 +807,7 @@ arl_put(sc)
ar->commandByte = 0x85; /* send command */
ARL_CHANNEL(sc);
if (arl_command(sc))
sc->arpcom.ac_if.if_oerrors++;
sc->arl_ifp->if_oerrors++;
}
/*
@ -873,7 +878,7 @@ arl_stop(sc)
s = splimp();
ifp = &sc->arpcom.ac_if;
ifp = sc->arl_ifp;
ifp->if_timer = 0; /* disable timer */
ifp->if_flags &= ~(IFF_RUNNING|IFF_OACTIVE);
@ -967,7 +972,7 @@ arl_read(sc, buf, len)
int len;
{
register struct ether_header *eh;
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->arl_ifp;
struct mbuf *m;
eh = (struct ether_header *)buf;
@ -984,7 +989,7 @@ arl_read(sc, buf, len)
* This test does not support multicasts.
*/
if ((ifp->if_flags & IFF_PROMISC)
&& bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr,
&& bcmp(eh->ether_dhost, IFP2ENADDR(sc->arl_ifp),
sizeof(eh->ether_dhost)) != 0
&& bcmp(eh->ether_dhost, BROADCASTADDR,
sizeof(eh->ether_dhost)) != 0)
@ -1049,7 +1054,7 @@ arl_intr(arg)
void *arg;
{
register struct arl_softc *sc = (struct arl_softc *) arg;
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->arl_ifp;
/* enable interrupt */
ar->controlRegister = (sc->arl_control & ~ARL_CLEAR_INTERRUPT);
@ -1057,7 +1062,7 @@ arl_intr(arg)
if (ar->txStatusVector) {
if (ar->txStatusVector != 1)
sc->arpcom.ac_if.if_collisions++;
sc->arl_ifp->if_collisions++;
ifp->if_timer = 0; /* disable timer */
ifp->if_flags &= ~IFF_OACTIVE;
arl_start(ifp);

View File

@ -275,8 +275,6 @@ arl_isa_probe (device_t dev)
}
if (ar->diagnosticInfo == 0xFF) {
/* Copy arp to arpcom struct */
bcopy(ar->lanCardNodeId, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
device_set_desc_copy(dev, arl_make_desc(ar->hardwareType,
ar->radioModule));
error = 0;
@ -313,7 +311,7 @@ arl_isa_attach (device_t dev)
}
#if __FreeBSD_version < 502108
device_printf(dev, "Ethernet address %6D\n", sc->arpcom.ac_enaddr, ":");
device_printf(dev, "Ethernet address %6D\n", IFP2ENADDR(sc->arl_ifp), ":");
#endif
return arl_attach(dev);
@ -327,9 +325,10 @@ arl_isa_detach(device_t dev)
arl_stop(sc);
ifmedia_removeall(&sc->arl_ifmedia);
#if __FreeBSD_version < 500100
ether_ifdetach(&sc->arpcom.ac_if, ETHER_BPF_SUPPORTED);
ether_ifdetach(sc->arl_ifp, ETHER_BPF_SUPPORTED);
#else
ether_ifdetach(&sc->arpcom.ac_if);
ether_ifdetach(sc->arl_ifp);
if_free(sc->arl_ifp);
#endif
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
arl_release_resources(dev);

View File

@ -281,7 +281,7 @@ struct arl_sigcache {
#ifdef _KERNEL
struct arl_softc {
struct arpcom arpcom; /* Ethernet common */
struct ifnet *arl_ifp;
int arl_unit;
struct arl_private * arl_mem; /* arlan data */

View File

@ -376,7 +376,7 @@ ath_rate_newstate(struct ath_softc *sc, enum ieee80211_state state)
if (ic->ic_opmode == IEEE80211_M_STA)
interval /= 2;
callout_reset(&asc->timer, (interval * hz) / 1000,
ath_ratectl, &sc->sc_if);
ath_ratectl, sc->sc_ifp);
}
}
@ -475,7 +475,7 @@ ath_ratectl(void *arg)
if (ic->ic_opmode == IEEE80211_M_STA)
interval /= 2;
callout_reset(&asc->timer, (interval * hz) / 1000,
ath_ratectl, &sc->sc_if);
ath_ratectl, sc->sc_ifp);
}
static void

View File

@ -360,7 +360,7 @@ ath_rate_newstate(struct ath_softc *sc, enum ieee80211_state state)
if (ic->ic_opmode == IEEE80211_M_STA)
interval /= 2;
callout_reset(&osc->timer, (interval * hz) / 1000,
ath_ratectl, &sc->sc_if);
ath_ratectl, sc->sc_ifp);
}
}
@ -456,7 +456,7 @@ ath_ratectl(void *arg)
if (ic->ic_opmode == IEEE80211_M_STA)
interval /= 2;
callout_reset(&osc->timer, (interval * hz) / 1000,
ath_ratectl, &sc->sc_if);
ath_ratectl, sc->sc_ifp);
}
static void

View File

@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$");
#include <net/if.h>
#include <net/if_dl.h>
#include <net/if_media.h>
#include <net/if_types.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_llc.h>
@ -228,7 +229,7 @@ enum {
};
#define IFF_DUMPPKTS(sc, m) \
((sc->sc_debug & (m)) || \
(sc->sc_if.if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2))
(sc->sc_ifp->if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2))
#define DPRINTF(sc, m, fmt, ...) do { \
if (sc->sc_debug & (m)) \
printf(fmt, __VA_ARGS__); \
@ -241,7 +242,7 @@ static void ath_printrxbuf(struct ath_buf *bf, int);
static void ath_printtxbuf(struct ath_buf *bf, int);
#else
#define IFF_DUMPPKTS(sc, m) \
((sc->sc_if.if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2))
((sc->sc_ifp->if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2))
#define DPRINTF(m, fmt, ...)
#define KEYPRINTF(sc, k, ix, mac)
#endif
@ -251,14 +252,21 @@ MALLOC_DEFINE(M_ATHDEV, "athdev", "ath driver dma buffers");
int
ath_attach(u_int16_t devid, struct ath_softc *sc)
{
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp;
struct ieee80211com *ic = &sc->sc_ic;
struct ath_hal *ah;
struct ath_hal *ah = NULL;
HAL_STATUS status;
int error = 0, i;
DPRINTF(sc, ATH_DEBUG_ANY, "%s: devid 0x%x\n", __func__, devid);
ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(sc->sc_dev, "can not if_alloc()\n");
error = ENOSPC;
goto bad;
}
/* set these up early for if_printf use */
if_initname(ifp, device_get_name(sc->sc_dev),
device_get_unit(sc->sc_dev));
@ -591,6 +599,8 @@ ath_attach(u_int16_t devid, struct ath_softc *sc)
bad:
if (ah)
ath_hal_detach(ah);
if (ifp != NULL)
if_free(ifp);
sc->sc_invalid = 1;
return error;
}
@ -598,7 +608,7 @@ ath_attach(u_int16_t devid, struct ath_softc *sc)
int
ath_detach(struct ath_softc *sc)
{
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags %x\n",
__func__, ifp->if_flags);
@ -629,7 +639,7 @@ ath_detach(struct ath_softc *sc)
void
ath_suspend(struct ath_softc *sc)
{
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags %x\n",
__func__, ifp->if_flags);
@ -640,13 +650,13 @@ ath_suspend(struct ath_softc *sc)
void
ath_resume(struct ath_softc *sc)
{
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags %x\n",
__func__, ifp->if_flags);
if (ifp->if_flags & IFF_UP) {
ath_init(ifp);
ath_init(sc);
if (ifp->if_flags & IFF_RUNNING)
ath_start(ifp);
}
@ -659,7 +669,7 @@ ath_resume(struct ath_softc *sc)
void
ath_shutdown(struct ath_softc *sc)
{
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
DPRINTF(sc, ATH_DEBUG_ANY, "%s: if_flags %x\n",
__func__, ifp->if_flags);
@ -674,7 +684,7 @@ void
ath_intr(void *arg)
{
struct ath_softc *sc = arg;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
struct ath_hal *ah = sc->sc_ah;
HAL_INT status;
@ -772,7 +782,7 @@ static void
ath_fatal_proc(void *arg, int pending)
{
struct ath_softc *sc = arg;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
if_printf(ifp, "hardware error; resetting\n");
ath_reset(ifp);
@ -782,7 +792,7 @@ static void
ath_rxorn_proc(void *arg, int pending)
{
struct ath_softc *sc = arg;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
if_printf(ifp, "rx FIFO overrun; resetting\n");
ath_reset(ifp);
@ -836,7 +846,7 @@ ath_init(void *arg)
{
struct ath_softc *sc = (struct ath_softc *) arg;
struct ieee80211com *ic = &sc->sc_ic;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211_node *ni;
struct ath_hal *ah = sc->sc_ah;
HAL_STATUS status;
@ -1199,7 +1209,7 @@ ath_media_change(struct ifnet *ifp)
error = ieee80211_media_change(ifp);
if (error == ENETRESET) {
if (IS_UP(ifp))
ath_init(ifp); /* XXX lose error */
ath_init(ifp->if_softc); /* XXX lose error */
error = 0;
}
return error;
@ -1604,7 +1614,7 @@ ath_calcrxfilter(struct ath_softc *sc, enum ieee80211_state state)
{
struct ieee80211com *ic = &sc->sc_ic;
struct ath_hal *ah = sc->sc_ah;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
u_int32_t rfilt;
rfilt = (ath_hal_getrxfilter(ah) & HAL_RX_FILTER_PHYERR)
@ -1626,7 +1636,7 @@ ath_mode_init(struct ath_softc *sc)
{
struct ieee80211com *ic = &sc->sc_ic;
struct ath_hal *ah = sc->sc_ah;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
u_int32_t rfilt, mfilt[2], val;
u_int8_t pos;
struct ifmultiaddr *ifma;
@ -1646,7 +1656,7 @@ ath_mode_init(struct ath_softc *sc)
*
* XXX should get from lladdr instead of arpcom but that's more work
*/
IEEE80211_ADDR_COPY(ic->ic_myaddr, IFP2AC(ifp)->ac_enaddr);
IEEE80211_ADDR_COPY(ic->ic_myaddr, IFP2ENADDR(ifp));
ath_hal_setmac(ah, ic->ic_myaddr);
/* calculate and install multicast filter */
@ -2016,7 +2026,7 @@ static void
ath_bstuck_proc(void *arg, int pending)
{
struct ath_softc *sc = arg;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
if_printf(ifp, "stuck beacon; resetting (bmiss count %u)\n",
sc->sc_bmisscount);
@ -2233,7 +2243,7 @@ ath_descdma_setup(struct ath_softc *sc,
{
#define DS2PHYS(_dd, _ds) \
((_dd)->dd_desc_paddr + ((caddr_t)(_ds) - (caddr_t)(_dd)->dd_desc))
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
struct ath_desc *ds;
struct ath_buf *bf;
int i, bsize, error;
@ -2623,7 +2633,7 @@ ath_rx_proc(void *arg, int npending)
struct ath_softc *sc = arg;
struct ath_buf *bf;
struct ieee80211com *ic = &sc->sc_ic;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
struct ath_hal *ah = sc->sc_ah;
struct ath_desc *ds;
struct mbuf *m;
@ -3149,7 +3159,7 @@ ath_tx_start(struct ath_softc *sc, struct ieee80211_node *ni, struct ath_buf *bf
txopLimit, CTS_DURATION)
struct ieee80211com *ic = &sc->sc_ic;
struct ath_hal *ah = sc->sc_ah;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
const struct chanAccParams *cap = &ic->ic_wme.wme_chanParams;
int i, error, iswep, ismcast, keyix, hdrlen, pktlen, try0;
u_int8_t rix, txrate, ctsrate;
@ -3730,7 +3740,7 @@ static void
ath_tx_proc_q0(void *arg, int npending)
{
struct ath_softc *sc = arg;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
ath_tx_processq(sc, &sc->sc_txq[0]);
ath_tx_processq(sc, sc->sc_cabq);
@ -3751,7 +3761,7 @@ static void
ath_tx_proc_q0123(void *arg, int npending)
{
struct ath_softc *sc = arg;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
/*
* Process each active queue.
@ -3778,7 +3788,7 @@ static void
ath_tx_proc(void *arg, int npending)
{
struct ath_softc *sc = arg;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
int i;
/*
@ -3860,7 +3870,7 @@ static void
ath_draintxq(struct ath_softc *sc)
{
struct ath_hal *ah = sc->sc_ah;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
int i;
/* XXX return value */
@ -4084,7 +4094,7 @@ ath_calibrate(void *arg)
* to load new gain values.
*/
sc->sc_stats.ast_per_rfgain++;
ath_reset(&sc->sc_if);
ath_reset(sc->sc_ifp);
}
if (!ath_hal_calibrate(ah, &sc->sc_curchan)) {
DPRINTF(sc, ATH_DEBUG_ANY,
@ -4291,7 +4301,7 @@ ath_getchannels(struct ath_softc *sc, u_int cc,
HAL_BOOL outdoor, HAL_BOOL xchanmode)
{
struct ieee80211com *ic = &sc->sc_ic;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
struct ath_hal *ah = sc->sc_ah;
HAL_CHANNEL *chans;
int i, ix, nchan;
@ -4680,7 +4690,7 @@ ath_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
* probably a better way to deal with this.
*/
if (!sc->sc_invalid && ic->ic_bss != NULL)
ath_init(ifp); /* XXX lose error */
ath_init(sc); /* XXX lose error */
} else
ath_stop_locked(ifp);
break;
@ -4716,7 +4726,7 @@ ath_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
if (error == ENETRESET) {
if (IS_RUNNING(ifp) &&
ic->ic_roaming != IEEE80211_ROAMING_MANUAL)
ath_init(ifp); /* XXX lose error */
ath_init(sc); /* XXX lose error */
error = 0;
}
if (error == ERESTART)
@ -4836,7 +4846,7 @@ static int
ath_sysctl_tpscale(SYSCTL_HANDLER_ARGS)
{
struct ath_softc *sc = arg1;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
u_int32_t scale;
int error;
@ -4929,7 +4939,7 @@ ath_sysctlattach(struct ath_softc *sc)
static void
ath_bpfattach(struct ath_softc *sc)
{
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
bpfattach2(ifp, DLT_IEEE802_11_RADIO,
sizeof(struct ieee80211_frame) + sizeof(sc->sc_tx_th),
@ -4959,7 +4969,7 @@ static void
ath_announce(struct ath_softc *sc)
{
#define HAL_MODE_DUALBAND (HAL_MODE_11A|HAL_MODE_11B)
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->sc_ifp;
struct ath_hal *ah = sc->sc_ah;
u_int modes, cc;

View File

@ -172,7 +172,7 @@ struct ath_txq {
} while (0)
struct ath_softc {
struct arpcom sc_arp; /* interface common */
struct ifnet *sc_ifp; /* interface common */
struct ath_stats sc_stats; /* interface statistics */
struct ieee80211com sc_ic; /* IEEE 802.11 common */
int sc_regdomain;
@ -286,7 +286,6 @@ struct ath_softc {
struct callout sc_cal_ch; /* callout handle for cals */
struct callout sc_scan_ch; /* callout handle for scan */
};
#define sc_if sc_arp.ac_if
#define sc_tx_th u_tx_rt.th
#define sc_rx_th u_rx_rt.th

View File

@ -258,7 +258,7 @@ int
awi_attach(struct awi_softc *sc)
{
struct ieee80211com *ic = &sc->sc_ic;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = AC2IFP(&sc->sc_arp);
int s, i, error, nrate;
int mword;
enum ieee80211_phymode mode;
@ -372,7 +372,7 @@ awi_attach(struct awi_softc *sc)
int
awi_detach(struct awi_softc *sc)
{
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = AC2IFP(&sc->sc_arp);
int s;
if (!sc->sc_attached)
@ -402,7 +402,7 @@ int
awi_activate(struct device *self, enum devact act)
{
struct awi_softc *sc = (struct awi_softc *)self;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = AC2IFP(&sc->sc_arp);
int s, error = 0;
s = splnet();
@ -423,7 +423,7 @@ void
awi_power(int why, void *arg)
{
struct awi_softc *sc = arg;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = AC2IFP(&sc->sc_arp);
int s;
int ocansleep;
@ -456,7 +456,7 @@ void
awi_shutdown(void *arg)
{
struct awi_softc *sc = arg;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = AC2IFP(&sc->sc_arp);
if (sc->sc_attached)
awi_stop(ifp, 1);
@ -542,7 +542,7 @@ awi_init0(void *arg)
{
struct awi_softc *sc = arg;
(void)awi_init(&sc->sc_if);
(void)awi_init(AC2IFP(&sc->sc_arp));
}
#endif
@ -1125,7 +1125,7 @@ awi_media_status(struct ifnet *ifp, struct ifmediareq *imr)
static int
awi_mode_init(struct awi_softc *sc)
{
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = AC2IFP(&sc->sc_arp);
int n, error;
#ifdef __FreeBSD__
struct ifmultiaddr *ifma;
@ -1197,7 +1197,7 @@ static void
awi_rx_int(struct awi_softc *sc)
{
struct ieee80211com *ic = &sc->sc_ic;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = AC2IFP(&sc->sc_arp);
struct ieee80211_node *ni;
u_int8_t state, rate, rssi;
u_int16_t len;
@ -1274,7 +1274,7 @@ awi_rx_int(struct awi_softc *sc)
static void
awi_tx_int(struct awi_softc *sc)
{
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = AC2IFP(&sc->sc_arp);
u_int8_t flags;
while (sc->sc_txdone != sc->sc_txnext) {
@ -1296,7 +1296,7 @@ awi_tx_int(struct awi_softc *sc)
static struct mbuf *
awi_devget(struct awi_softc *sc, u_int32_t off, u_int16_t len)
{
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = AC2IFP(&sc->sc_arp);
struct mbuf *m;
struct mbuf *top, **mp;
u_int tlen;
@ -1397,7 +1397,7 @@ awi_hw_init(struct awi_softc *sc)
return ENXIO;
if (i >= AWI_SELFTEST_TIMEOUT*hz/1000) {
printf("%s: failed to complete selftest (timeout)\n",
sc->sc_if.if_xname);
AC2IFP(&sc->sc_arp)->if_xname);
return ENXIO;
}
status = awi_read_1(sc, AWI_SELFTEST);
@ -1413,7 +1413,7 @@ awi_hw_init(struct awi_softc *sc)
}
if (status != AWI_SELFTEST_PASSED) {
printf("%s: failed to complete selftest (code %x)\n",
sc->sc_if.if_xname, status);
AC2IFP(&sc->sc_arp)->if_xname, status);
return ENXIO;
}
@ -1421,7 +1421,7 @@ awi_hw_init(struct awi_softc *sc)
awi_read_bytes(sc, AWI_BANNER, sc->sc_banner, AWI_BANNER_LEN);
if (memcmp(sc->sc_banner, "PCnetMobile:", 12) != 0) {
printf("%s: failed to complete selftest (bad banner)\n",
sc->sc_if.if_xname);
AC2IFP(&sc->sc_arp)->if_xname);
for (i = 0; i < AWI_BANNER_LEN; i++)
printf("%s%02x", i ? ":" : "\t", sc->sc_banner[i]);
printf("\n");
@ -1446,7 +1446,7 @@ awi_hw_init(struct awi_softc *sc)
error = awi_cmd(sc, AWI_CMD_NOP, AWI_WAIT);
if (error) {
printf("%s: failed to complete selftest",
sc->sc_if.if_xname);
AC2IFP(&sc->sc_arp)->if_xname);
if (error == ENXIO)
printf(" (no hardware)\n");
else if (error != EWOULDBLOCK)
@ -1484,7 +1484,7 @@ awi_init_mibs(struct awi_softc *sc)
(error = awi_mib(sc, AWI_CMD_GET_MIB, AWI_MIB_MGT, AWI_WAIT)) ||
(error = awi_mib(sc, AWI_CMD_GET_MIB, AWI_MIB_PHY, AWI_WAIT))) {
printf("%s: failed to get default mib value (error %d)\n",
sc->sc_if.if_xname, error);
AC2IFP(&sc->sc_arp)->if_xname, error);
return error;
}
@ -1492,7 +1492,7 @@ awi_init_mibs(struct awi_softc *sc)
for (cs = awi_chanset; ; cs++) {
if (cs->cs_type == 0) {
printf("%s: failed to set available channel\n",
sc->sc_if.if_xname);
AC2IFP(&sc->sc_arp)->if_xname);
return ENXIO;
}
if (cs->cs_type == sc->sc_mib_phy.IEEE_PHY_Type &&
@ -1672,7 +1672,7 @@ awi_cmd(struct awi_softc *sc, u_int8_t cmd, int wflag)
return EINVAL;
default:
printf("%s: command %d failed %x\n",
sc->sc_if.if_xname, cmd, status);
AC2IFP(&sc->sc_arp)->if_xname, cmd, status);
return ENXIO;
}
return 0;
@ -1689,7 +1689,7 @@ awi_cmd_wait(struct awi_softc *sc)
return ENXIO;
if (awi_read_1(sc, AWI_CMD) != sc->sc_cmd_inprog) {
printf("%s: failed to access hardware\n",
sc->sc_if.if_xname);
AC2IFP(&sc->sc_arp)->if_xname);
sc->sc_invalid = 1;
return ENXIO;
}
@ -1734,7 +1734,7 @@ awi_cmd_done(struct awi_softc *sc)
if (status != AWI_STAT_OK) {
printf("%s: command %d failed %x\n",
sc->sc_if.if_xname, cmd, status);
AC2IFP(&sc->sc_arp)->if_xname, cmd, status);
sc->sc_substate = AWI_ST_NONE;
return;
}
@ -1849,7 +1849,7 @@ awi_intr_lock(struct awi_softc *sc)
}
if (status != 0) {
printf("%s: failed to lock interrupt\n",
sc->sc_if.if_xname);
AC2IFP(&sc->sc_arp)->if_xname);
return ENXIO;
}
return 0;

View File

@ -79,7 +79,6 @@ struct awi_softc {
#endif
#ifdef __FreeBSD__
struct arpcom sc_arp;
#define sc_if sc_arp.ac_if
device_t sc_dev;
#endif
struct am79c930_softc sc_chip;

View File

@ -322,7 +322,7 @@ bfe_dma_alloc(device_t dev)
static int
bfe_attach(device_t dev)
{
struct ifnet *ifp;
struct ifnet *ifp = NULL;
struct bfe_softc *sc;
int unit, error = 0, rid;
@ -372,7 +372,12 @@ bfe_attach(device_t dev)
}
/* Set up ifnet structure */
ifp = &sc->arpcom.ac_if;
ifp = sc->bfe_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
printf("bfe%d: failed to if_alloc()\n", sc->bfe_unit);
error = ENOSPC;
goto fail;
}
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
@ -400,7 +405,7 @@ bfe_attach(device_t dev)
goto fail;
}
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
ether_ifattach(ifp, sc->bfe_enaddr);
callout_handle_init(&sc->bfe_stat_ch);
/*
@ -422,8 +427,11 @@ bfe_attach(device_t dev)
goto fail;
}
fail:
if(error)
if(error) {
bfe_release_resources(sc);
if (ifp != NULL)
if_free(ifp);
}
return (error);
}
@ -438,11 +446,12 @@ bfe_detach(device_t dev)
KASSERT(mtx_initialized(&sc->bfe_mtx), ("bfe mutex not initialized"));
BFE_LOCK(sc);
ifp = &sc->arpcom.ac_if;
ifp = sc->bfe_ifp;
if (device_is_attached(dev)) {
bfe_stop(sc);
ether_ifdetach(ifp);
if_free(ifp);
}
bfe_chip_reset(sc);
@ -610,12 +619,12 @@ bfe_get_config(struct bfe_softc *sc)
bfe_read_eeprom(sc, eeprom);
sc->arpcom.ac_enaddr[0] = eeprom[79];
sc->arpcom.ac_enaddr[1] = eeprom[78];
sc->arpcom.ac_enaddr[2] = eeprom[81];
sc->arpcom.ac_enaddr[3] = eeprom[80];
sc->arpcom.ac_enaddr[4] = eeprom[83];
sc->arpcom.ac_enaddr[5] = eeprom[82];
sc->bfe_enaddr[0] = eeprom[79];
sc->bfe_enaddr[1] = eeprom[78];
sc->bfe_enaddr[2] = eeprom[81];
sc->bfe_enaddr[3] = eeprom[80];
sc->bfe_enaddr[4] = eeprom[83];
sc->bfe_enaddr[5] = eeprom[82];
sc->bfe_phyaddr = eeprom[90] & 0x1f;
sc->bfe_mdc_port = (eeprom[90] >> 14) & 0x1;
@ -849,7 +858,7 @@ bfe_cam_write(struct bfe_softc *sc, u_char *data, int index)
static void
bfe_set_rx_mode(struct bfe_softc *sc)
{
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->bfe_ifp;
struct ifmultiaddr *ifma;
u_int32_t val;
int i = 0;
@ -868,7 +877,7 @@ bfe_set_rx_mode(struct bfe_softc *sc)
CSR_WRITE_4(sc, BFE_CAM_CTRL, 0);
bfe_cam_write(sc, sc->arpcom.ac_enaddr, i++);
bfe_cam_write(sc, IFP2ENADDR(sc->bfe_ifp), i++);
if (ifp->if_flags & IFF_ALLMULTI)
val |= BFE_RXCONF_ALLMULTI;
@ -1077,7 +1086,7 @@ bfe_txeof(struct bfe_softc *sc)
BFE_LOCK_ASSERT(sc);
ifp = &sc->arpcom.ac_if;
ifp = sc->bfe_ifp;
chipidx = CSR_READ_4(sc, BFE_DMATX_STAT) & BFE_STAT_CDMASK;
chipidx /= sizeof(struct bfe_desc);
@ -1123,7 +1132,7 @@ bfe_rxeof(struct bfe_softc *sc)
status = CSR_READ_4(sc, BFE_DMARX_STAT);
current = (status & BFE_STAT_CDMASK) / sizeof(struct bfe_desc);
ifp = &sc->arpcom.ac_if;
ifp = sc->bfe_ifp;
while(current != cons) {
r = &sc->bfe_rx_ring[cons];
@ -1177,7 +1186,7 @@ bfe_intr(void *xsc)
struct ifnet *ifp;
u_int32_t istat, imask, flag;
ifp = &sc->arpcom.ac_if;
ifp = sc->bfe_ifp;
BFE_LOCK(sc);
@ -1395,7 +1404,7 @@ static void
bfe_init_locked(void *xsc)
{
struct bfe_softc *sc = (struct bfe_softc*)xsc;
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->bfe_ifp;
BFE_LOCK_ASSERT(sc);
@ -1567,7 +1576,7 @@ bfe_stop(struct bfe_softc *sc)
untimeout(bfe_tick, sc, sc->bfe_stat_ch);
ifp = &sc->arpcom.ac_if;
ifp = sc->bfe_ifp;
bfe_chip_halt(sc);
bfe_tx_ring_free(sc);

View File

@ -491,7 +491,7 @@ struct bfe_hw_stats {
struct bfe_softc
{
struct arpcom arpcom; /* interface info */
struct ifnet *bfe_ifp; /* interface info */
device_t bfe_dev;
device_t bfe_miibus;
bus_space_handle_t bfe_bhandle;
@ -522,6 +522,7 @@ struct bfe_softc
u_int8_t bfe_unit; /* interface number */
u_int8_t bfe_core_unit;
u_int8_t bfe_up;
u_char bfe_enaddr[6];
int bfe_if_flags;
char *bfe_vpd_prodname;
char *bfe_vpd_readonly;

View File

@ -1156,7 +1156,7 @@ bge_setmulti(sc)
BGE_LOCK_ASSERT(sc);
ifp = &sc->arpcom.ac_if;
ifp = sc->bge_ifp;
if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
for (i = 0; i < 4; i++)
@ -1544,9 +1544,9 @@ bge_blockinit(sc)
/* Set random backoff seed for TX */
CSR_WRITE_4(sc, BGE_TX_RANDOM_BACKOFF,
sc->arpcom.ac_enaddr[0] + sc->arpcom.ac_enaddr[1] +
sc->arpcom.ac_enaddr[2] + sc->arpcom.ac_enaddr[3] +
sc->arpcom.ac_enaddr[4] + sc->arpcom.ac_enaddr[5] +
IFP2ENADDR(sc->bge_ifp)[0] + IFP2ENADDR(sc->bge_ifp)[1] +
IFP2ENADDR(sc->bge_ifp)[2] + IFP2ENADDR(sc->bge_ifp)[3] +
IFP2ENADDR(sc->bge_ifp)[4] + IFP2ENADDR(sc->bge_ifp)[5] +
BGE_TX_BACKOFF_SEED_MASK);
/* Set inter-packet gap */
@ -2248,7 +2248,8 @@ bge_attach(dev)
struct ifnet *ifp;
struct bge_softc *sc;
u_int32_t hwcfg = 0;
u_int32_t mac_addr = 0;
u_int32_t mac_tmp = 0;
u_char eaddr[6];
int unit, error = 0, rid;
sc = device_get_softc(dev);
@ -2334,16 +2335,16 @@ bge_attach(dev)
/*
* Get station address from the EEPROM.
*/
mac_addr = bge_readmem_ind(sc, 0x0c14);
if ((mac_addr >> 16) == 0x484b) {
sc->arpcom.ac_enaddr[0] = (u_char)(mac_addr >> 8);
sc->arpcom.ac_enaddr[1] = (u_char)mac_addr;
mac_addr = bge_readmem_ind(sc, 0x0c18);
sc->arpcom.ac_enaddr[2] = (u_char)(mac_addr >> 24);
sc->arpcom.ac_enaddr[3] = (u_char)(mac_addr >> 16);
sc->arpcom.ac_enaddr[4] = (u_char)(mac_addr >> 8);
sc->arpcom.ac_enaddr[5] = (u_char)mac_addr;
} else if (bge_read_eeprom(sc, (caddr_t)&sc->arpcom.ac_enaddr,
mac_tmp = bge_readmem_ind(sc, 0x0c14);
if ((mac_tmp >> 16) == 0x484b) {
eaddr[0] = (u_char)(mac_tmp >> 8);
eaddr[1] = (u_char)mac_tmp;
mac_tmp = bge_readmem_ind(sc, 0x0c18);
eaddr[2] = (u_char)(mac_tmp >> 24);
eaddr[3] = (u_char)(mac_tmp >> 16);
eaddr[4] = (u_char)(mac_tmp >> 8);
eaddr[5] = (u_char)mac_tmp;
} else if (bge_read_eeprom(sc, eaddr,
BGE_EE_MAC_OFFSET + 2, ETHER_ADDR_LEN)) {
printf("bge%d: failed to read station address\n", unit);
bge_release_resources(sc);
@ -2389,7 +2390,13 @@ bge_attach(dev)
sc->bge_tx_max_coal_bds = 128;
/* Set up ifnet structure */
ifp = &sc->arpcom.ac_if;
ifp = sc->bge_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
printf("bge%d: failed to if_alloc()\n", sc->bge_unit);
bge_release_resources(sc);
error = ENXIO;
goto fail;
}
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
@ -2449,6 +2456,7 @@ bge_attach(dev)
printf("bge%d: MII without any PHY!\n", sc->bge_unit);
bge_release_resources(sc);
bge_free_jumbo_mem(sc);
if_free(ifp);
error = ENXIO;
goto fail;
}
@ -2478,7 +2486,7 @@ bge_attach(dev)
/*
* Call MI attach routine.
*/
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
ether_ifattach(ifp, eaddr);
callout_init(&sc->bge_stat_ch, CALLOUT_MPSAFE);
/*
@ -2488,7 +2496,7 @@ bge_attach(dev)
bge_intr, sc, &sc->bge_intrhand);
if (error) {
bge_release_resources(sc);
bge_detach(dev);
printf("bge%d: couldn't set up irq\n", unit);
}
@ -2504,7 +2512,7 @@ bge_detach(dev)
struct ifnet *ifp;
sc = device_get_softc(dev);
ifp = &sc->arpcom.ac_if;
ifp = sc->bge_ifp;
BGE_LOCK(sc);
bge_stop(sc);
@ -2512,6 +2520,7 @@ bge_detach(dev)
BGE_UNLOCK(sc);
ether_ifdetach(ifp);
if_free(ifp);
if (sc->bge_tbi) {
ifmedia_removeall(&sc->bge_ifmedia);
@ -2708,7 +2717,7 @@ bge_rxeof(sc)
BGE_LOCK_ASSERT(sc);
ifp = &sc->arpcom.ac_if;
ifp = sc->bge_ifp;
bus_dmamap_sync(sc->bge_cdata.bge_rx_return_ring_tag,
sc->bge_cdata.bge_rx_return_ring_map, BUS_DMASYNC_POSTWRITE);
@ -2856,7 +2865,7 @@ bge_txeof(sc)
BGE_LOCK_ASSERT(sc);
ifp = &sc->arpcom.ac_if;
ifp = sc->bge_ifp;
/*
* Go through our tx ring and free mbufs for those
@ -2897,7 +2906,7 @@ bge_intr(xsc)
u_int32_t status, mimode;
sc = xsc;
ifp = &sc->arpcom.ac_if;
ifp = sc->bge_ifp;
BGE_LOCK(sc);
@ -3014,7 +3023,7 @@ bge_tick_locked(sc)
struct ifmedia *ifm = NULL;
struct ifnet *ifp;
ifp = &sc->arpcom.ac_if;
ifp = sc->bge_ifp;
BGE_LOCK_ASSERT(sc);
@ -3084,7 +3093,7 @@ bge_stats_update_regs(sc)
u_int32_t *s;
int i;
ifp = &sc->arpcom.ac_if;
ifp = sc->bge_ifp;
s = (u_int32_t *)&stats;
for (i = 0; i < sizeof(struct bge_mac_stats_regs); i += 4) {
@ -3109,7 +3118,7 @@ bge_stats_update(sc)
struct ifnet *ifp;
struct bge_stats *stats;
ifp = &sc->arpcom.ac_if;
ifp = sc->bge_ifp;
stats = (struct bge_stats *)(sc->bge_vhandle +
BGE_MEMWIN_START + BGE_STATS_BLOCK);
@ -3162,7 +3171,7 @@ bge_encap(sc, m_head, txidx)
csum_flags |= BGE_TXBDFLAG_IP_FRAG;
}
mtag = VLAN_OUTPUT_TAG(&sc->arpcom.ac_if, m_head);
mtag = VLAN_OUTPUT_TAG(sc->bge_ifp, m_head);
ctx.sc = sc;
ctx.bge_idx = *txidx;
@ -3317,7 +3326,7 @@ bge_init_locked(sc)
BGE_LOCK_ASSERT(sc);
ifp = &sc->arpcom.ac_if;
ifp = sc->bge_ifp;
if (ifp->if_flags & IFF_RUNNING)
return;
@ -3336,14 +3345,14 @@ bge_init_locked(sc)
return;
}
ifp = &sc->arpcom.ac_if;
ifp = sc->bge_ifp;
/* Specify MTU. */
CSR_WRITE_4(sc, BGE_RX_MTU, ifp->if_mtu +
ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN);
/* Load our MAC address. */
m = (u_int16_t *)&sc->arpcom.ac_enaddr[0];
m = (u_int16_t *)&IFP2ENADDR(sc->bge_ifp)[0];
CSR_WRITE_4(sc, BGE_MAC_ADDR1_LO, htons(m[0]));
CSR_WRITE_4(sc, BGE_MAC_ADDR1_HI, (htons(m[1]) << 16) | htons(m[2]));
@ -3638,7 +3647,7 @@ bge_stop(sc)
BGE_LOCK_ASSERT(sc);
ifp = &sc->arpcom.ac_if;
ifp = sc->bge_ifp;
if (!sc->bge_tbi)
mii = device_get_softc(sc->bge_miibus);

View File

@ -2313,7 +2313,7 @@ struct bge_bcom_hack {
};
struct bge_softc {
struct arpcom arpcom; /* interface info */
struct ifnet *bge_ifp; /* interface info */
device_t bge_dev;
struct mtx bge_mtx;
device_t bge_miibus;

View File

@ -103,14 +103,15 @@ static int
cm_isa_detach(device_t dev)
{
struct cm_softc *sc = device_get_softc(dev);
struct ifnet *ifp = &sc->sc_arccom.ac_if;
struct ifnet *ifp = sc->sc_ifp;
int s;
cm_stop(sc);
ifp->if_flags &= ~IFF_RUNNING;
s = splimp();
arc_ifdetach(&sc->sc_arccom.ac_if);
arc_ifdetach(ifp);
if_free(ifp);
splx(s);
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);

View File

@ -277,10 +277,15 @@ cm_attach(dev)
device_t dev;
{
struct cm_softc *sc = device_get_softc(dev);
struct ifnet *ifp = &sc->sc_arccom.ac_if;
struct ifnet *ifp;
int s;
u_int8_t linkaddress;
ifp = sc->sc_ifp = if_alloc(IFT_ARCNET);
if (ifp == NULL) {
return (ENOSPC);
}
s = splhigh();
/*
@ -353,7 +358,7 @@ cm_init(xsc)
struct ifnet *ifp;
int s;
ifp = &sc->sc_arccom.ac_if;
ifp = sc->sc_ifp;
if ((ifp->if_flags & IFF_RUNNING) == 0) {
s = splimp();
@ -377,7 +382,7 @@ cm_reset(sc)
struct ifnet *ifp;
int linkaddress;
ifp = &sc->sc_arccom.ac_if;
ifp = sc->sc_ifp;
#ifdef CM_DEBUG
if_printf(ifp, "reset\n");
@ -456,7 +461,7 @@ cm_stop(sc)
GETREG(CMRESET);
/* Stop watchdog timer */
sc->sc_arccom.ac_if.if_timer = 0;
sc->sc_ifp->if_timer = 0;
}
/*
@ -589,7 +594,7 @@ cm_start(ifp)
PUTREG(CMCMD, CM_TX(buffer));
PUTREG(CMSTAT, sc->sc_intmask);
sc->sc_arccom.ac_if.if_timer = ARCTIMEOUT;
ifp->if_timer = ARCTIMEOUT;
}
splx(s);
m_freem(m);
@ -619,7 +624,7 @@ cm_srint(vsc)
struct arc_header *ah;
struct ifnet *ifp;
ifp = &sc->sc_arccom.ac_if;
ifp = sc->sc_ifp;
s = splimp();
buffer = sc->sc_rx_act ^ 1;
@ -733,7 +738,7 @@ cm_tint(sc, isr)
int clknow;
#endif
ifp = &(sc->sc_arccom.ac_if);
ifp = sc->sc_ifp;
buffer = sc->sc_tx_act;
/*
@ -744,7 +749,7 @@ cm_tint(sc, isr)
*/
if (isr & CM_TMA || sc->sc_broadcast[buffer])
sc->sc_arccom.ac_if.if_opackets++;
ifp->if_opackets++;
#ifdef CMRETRANSMIT
else if (ifp->if_flags & IFF_LINK2 && ifp->if_timer > 0
&& --sc->sc_retransmits[buffer] > 0) {
@ -814,7 +819,7 @@ cmintr(arg)
void *arg;
{
struct cm_softc *sc = arg;
struct ifnet *ifp = &sc->sc_arccom.ac_if;
struct ifnet *ifp = sc->sc_ifp;
u_char isr, maskedisr;
int buffer;
@ -835,7 +840,7 @@ cmintr(arg)
/*
* XXX We should never see this. Don't bother to store
* the address.
* sc->sc_arccom.ac_anaddr = GETMEM(CMMACOFF);
* sc->sc_ifp->if_l2com->ac_anaddr = GETMEM(CMMACOFF);
*/
PUTREG(CMCMD, CM_CLR(CLR_POR));
log(LOG_WARNING,
@ -849,7 +854,7 @@ cmintr(arg)
* PUTREG(CMCMD, CM_CONF(CONF_LONG));
*/
PUTREG(CMCMD, CM_CLR(CLR_RECONFIG));
sc->sc_arccom.ac_if.if_collisions++;
ifp->if_collisions++;
/*
* If less than 2 seconds per reconfig:
@ -952,7 +957,7 @@ cm_reconwatch(arg)
void *arg;
{
struct cm_softc *sc = arg;
struct ifnet *ifp = &sc->sc_arccom.ac_if;
struct ifnet *ifp = sc->sc_ifp;
if (sc->sc_reconcount >= ARC_EXCESSIVE_RECONS) {
sc->sc_reconcount = 0;

View File

@ -56,7 +56,7 @@
#include <sys/callout.h>
struct cm_softc {
struct arccom sc_arccom; /* Common arcnet structures */
struct ifnet *sc_ifp; /* Common arcnet structures */
int port_rid; /* resource id for port range */
struct resource *port_res; /* resource for port range */

View File

@ -288,7 +288,7 @@ int cnw_skey = CNW_SCRAMBLEKEY; /* Scramble key */
#endif
struct cnw_softc {
struct arpcom arpcom;
struct ifnet *sc_ifp;
struct ifmedia ifmedia;
device_t dev;
struct cnwstats sc_stats;
@ -510,7 +510,7 @@ cnw_init(sc)
#if !defined(__FreeBSD__)
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
#else /* FreeBSD */
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->sc_ifp;
#endif
const u_int8_t rxmode =
CNW_RXCONF_RXENA | CNW_RXCONF_BCAST | CNW_RXCONF_AMP;
@ -949,7 +949,7 @@ cnw_read(sc)
#if !defined(__FreeBSD__)
m->m_pkthdr.rcvif = &sc->sc_ethercom.ec_if;
#else /* FreeBSD */
m->m_pkthdr.rcvif = &sc->arpcom.ac_if;
m->m_pkthdr.rcvif = sc->sc_ifp;
#endif
m->m_pkthdr.len = totbytes;
mbytes = MHLEN;
@ -1024,7 +1024,7 @@ cnw_recv(sc)
#if !defined(__FreeBSD__)
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
#else
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->sc_ifp;
#endif
struct mbuf *m;
@ -1076,7 +1076,7 @@ cnw_intr(arg)
#if !defined(__FreeBSD__)
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
#else
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->sc_ifp;
#endif
int ret, status, rser, tser;
@ -1498,7 +1498,7 @@ static void cnw_freebsd_init(xsc)
void *xsc;
{
struct cnw_softc *sc = xsc;
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->sc_ifp;
int s;
if (sc->cnw_gone)
@ -1534,7 +1534,7 @@ static void cnw_stop(sc)
cnw_reset(sc);
ifp = &sc->arpcom.ac_if;
ifp = sc->sc_ifp;
ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
return;
@ -1571,7 +1571,7 @@ static int cnw_pccard_detach(dev)
#endif
sc = device_get_softc(dev);
ifp = &sc->arpcom.ac_if;
ifp = sc->sc_ifp;
if (sc->cnw_gone) {
device_printf(dev, "already unloaded\n");
@ -1581,6 +1581,7 @@ static int cnw_pccard_detach(dev)
cnw_stop(sc);
ether_ifdetach(ifp);
if_free(ifp);
cnw_free(dev);
sc->cnw_gone = 1;
@ -1595,9 +1596,15 @@ static int cnw_pccard_attach(device_t dev)
struct cnw_softc *sc;
struct ifnet *ifp;
int i, error;
u_char eaddr[6];
sc = device_get_softc(dev);
ifp = &sc->arpcom.ac_if;
ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "if_alloc() failed\n");
return (ENOSPC);
}
error = cnw_alloc(dev);
if (error) {
@ -1623,8 +1630,7 @@ static int cnw_pccard_attach(device_t dev)
/* Get MAC address */
for (i=0; i< ETHER_ADDR_LEN; i++) {
sc->arpcom.ac_enaddr[i] =
bus_space_read_1(sc->sc_memt, sc->sc_memh,
eaddr[i] = bus_space_read_1(sc->sc_memt, sc->sc_memh,
sc->sc_memoff + CNW_EREG_PA + i);
}
@ -1647,7 +1653,7 @@ static int cnw_pccard_attach(device_t dev)
/*
* Call MI attach routine.
*/
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
ether_ifattach(ifp, eaddr);
/* callout_handle_init(&sc->cnw_stat_ch); */
return(0);

View File

@ -56,6 +56,8 @@ __FBSDID("$FreeBSD$");
# include <dev/cp/ng_cp.h>
#else
# include <net/if_sppp.h>
# include <net/if_types.h>
#include <dev/pci/pcivar.h>
# define PP_CISCO IFF_LINK2
# include <net/bpf.h>
#endif
@ -135,7 +137,7 @@ typedef struct _drv_t {
struct callout timeout_handle;
#else
struct ifqueue queue;
struct sppp pp;
struct ifnet *ifp;
#endif
struct cdev *devt;
} drv_t;
@ -329,7 +331,7 @@ static void cp_intr (void *arg)
IF_DEQUEUE (&d->queue,m);
if (!m)
continue;
sppp_input (&d->pp.pp_if, m);
sppp_input (d->ifp, m);
}
}
#endif
@ -514,25 +516,30 @@ static int cp_attach (device_t dev)
callout_init (&d->timeout_handle,
cp_mpsafenet ? CALLOUT_MPSAFE : 0);
#else /*NETGRAPH*/
d->pp.pp_if.if_softc = d;
if_initname (&d->pp.pp_if, "cp", b->num * NCHAN + c->num);
d->pp.pp_if.if_mtu = PP_MTU;
d->pp.pp_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
d->ifp = if_alloc(IFT_PPP);
if (d->ifp == NULL) {
printf ("%s: cannot if_alloc() interface\n", d->name);
continue;
}
d->ifp->if_softc = d;
if_initname (d->ifp, "cp", b->num * NCHAN + c->num);
d->ifp->if_mtu = PP_MTU;
d->ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
if (!cp_mpsafenet)
d->pp.pp_if.if_flags |= IFF_NEEDSGIANT;
d->pp.pp_if.if_ioctl = cp_sioctl;
d->pp.pp_if.if_start = cp_ifstart;
d->pp.pp_if.if_watchdog = cp_ifwatchdog;
d->pp.pp_if.if_init = cp_initialize;
d->ifp->if_flags |= IFF_NEEDSGIANT;
d->ifp->if_ioctl = cp_sioctl;
d->ifp->if_start = cp_ifstart;
d->ifp->if_watchdog = cp_ifwatchdog;
d->ifp->if_init = cp_initialize;
d->queue.ifq_maxlen = NRBUF;
mtx_init (&d->queue.ifq_mtx, "cp_queue", NULL, MTX_DEF);
sppp_attach (&d->pp.pp_if);
if_attach (&d->pp.pp_if);
d->pp.pp_tlf = cp_tlf;
d->pp.pp_tls = cp_tls;
sppp_attach (d->ifp);
if_attach (d->ifp);
IFP2SP(d->ifp)->pp_tlf = cp_tlf;
IFP2SP(d->ifp)->pp_tls = cp_tls;
/* If BPF is in the kernel, call the attach for it.
* The header size of PPP or Cisco/HDLC is 4 bytes. */
bpfattach (&d->pp.pp_if, DLT_PPP, 4);
bpfattach (d->ifp, DLT_PPP, 4);
#endif /*NETGRAPH*/
cp_start_e1 (c);
cp_start_chan (c, 1, 1, d->dmamem.virt, d->dmamem.phys);
@ -603,13 +610,14 @@ static int cp_detach (device_t dev)
continue;
#ifndef NETGRAPH
/* Detach from the packet filter list of interfaces. */
bpfdetach (&d->pp.pp_if);
bpfdetach (d->ifp);
/* Detach from the sync PPP list. */
sppp_detach (&d->pp.pp_if);
sppp_detach (d->ifp);
/* Detach from the system list of interfaces. */
if_detach (&d->pp.pp_if);
if_detach (d->ifp);
if_free (d->ifp);
IF_DRAIN (&d->queue);
mtx_destroy (&d->queue.ifq_mtx);
#else
@ -677,22 +685,22 @@ static void cp_ifwatchdog (struct ifnet *ifp)
static void cp_tlf (struct sppp *sp)
{
drv_t *d = sp->pp_if.if_softc;
drv_t *d = SP2IFP(sp)->if_softc;
CP_DEBUG2 (d, ("cp_tlf\n"));
/* XXXRIK: Don't forget to protect them by LOCK, or kill them. */
/* cp_set_dtr (d->chan, 0);*/
/* cp_set_rts (d->chan, 0);*/
if (!(d->pp.pp_flags & PP_FR) && !(d->pp.pp_if.if_flags & PP_CISCO))
if (!(sp->pp_flags & PP_FR) && !(d->ifp->if_flags & PP_CISCO))
sp->pp_down (sp);
}
static void cp_tls (struct sppp *sp)
{
drv_t *d = sp->pp_if.if_softc;
drv_t *d = SP2IFP(sp)->if_softc;
CP_DEBUG2 (d, ("cp_tls\n"));
if (!(d->pp.pp_flags & PP_FR) && !(d->pp.pp_if.if_flags & PP_CISCO))
if (!(sp->pp_flags & PP_FR) && !(d->ifp->if_flags & PP_CISCO))
sp->pp_up (sp);
}
@ -734,7 +742,7 @@ static int cp_sioctl (struct ifnet *ifp, u_long cmd, caddr_t data)
cp_start (d);
} else if (was_up && ! should_be_up) {
/* Interface is going down -- stop it. */
/* if ((d->pp.pp_flags & PP_FR) || (ifp->if_flags & PP_CISCO))*/
/* if ((IFP2SP(ifp)->pp_flags & PP_FR) || (ifp->if_flags & PP_CISCO))*/
cp_down (d);
}
CP_DEBUG (d, ("ioctl 0x%lx p4\n", cmd));
@ -807,13 +815,13 @@ static void cp_send (drv_t *d)
if (! m)
IF_DEQUEUE (&d->queue, m);
#else
m = sppp_dequeue (&d->pp.pp_if);
m = sppp_dequeue (d->ifp);
#endif
if (! m)
return;
#ifndef NETGRAPH
if (d->pp.pp_if.if_bpf)
BPF_MTAP (&d->pp.pp_if, m);
if (d->ifp->if_bpf)
BPF_MTAP (d->ifp, m);
#endif
len = m->m_pkthdr.len;
if (len >= BUFSZ)
@ -831,11 +839,11 @@ static void cp_send (drv_t *d)
#ifdef NETGRAPH
d->timeout = 10;
#else
d->pp.pp_if.if_timer = 10;
d->ifp->if_timer = 10;
#endif
}
#ifndef NETGRAPH
d->pp.pp_if.if_flags |= IFF_OACTIVE;
d->ifp->if_flags |= IFF_OACTIVE;
#endif
}
@ -886,9 +894,9 @@ static void cp_transmit (cp_chan_t *c, void *attachment, int len)
#ifdef NETGRAPH
d->timeout = 0;
#else
++d->pp.pp_if.if_opackets;
d->pp.pp_if.if_flags &= ~IFF_OACTIVE;
d->pp.pp_if.if_timer = 0;
++d->ifp->if_opackets;
d->ifp->if_flags &= ~IFF_OACTIVE;
d->ifp->if_timer = 0;
#endif
cp_start (d);
}
@ -908,7 +916,7 @@ static void cp_receive (cp_chan_t *c, unsigned char *data, int len)
if (! m) {
CP_DEBUG (d, ("no memory for packet\n"));
#ifndef NETGRAPH
++d->pp.pp_if.if_iqdrops;
++d->ifp->if_iqdrops;
#endif
return;
}
@ -918,12 +926,12 @@ static void cp_receive (cp_chan_t *c, unsigned char *data, int len)
m->m_pkthdr.rcvif = 0;
NG_SEND_DATA_ONLY (error, d->hook, m);
#else
++d->pp.pp_if.if_ipackets;
m->m_pkthdr.rcvif = &d->pp.pp_if;
++d->ifp->if_ipackets;
m->m_pkthdr.rcvif = d->ifp;
/* Check if there's a BPF listener on this interface.
* If so, hand off the raw packet to bpf. */
if (d->pp.pp_if.if_bpf)
BPF_TAP (&d->pp.pp_if, data, len);
if (d->ifp->if_bpf)
BPF_TAP (d->ifp, data, len);
IF_ENQUEUE (&d->queue, m);
#endif
}
@ -936,26 +944,26 @@ static void cp_error (cp_chan_t *c, int data)
case CP_FRAME:
CP_DEBUG (d, ("frame error\n"));
#ifndef NETGRAPH
++d->pp.pp_if.if_ierrors;
++d->ifp->if_ierrors;
#endif
break;
case CP_CRC:
CP_DEBUG (d, ("crc error\n"));
#ifndef NETGRAPH
++d->pp.pp_if.if_ierrors;
++d->ifp->if_ierrors;
#endif
break;
case CP_OVERRUN:
CP_DEBUG (d, ("overrun error\n"));
#ifndef NETGRAPH
++d->pp.pp_if.if_collisions;
++d->pp.pp_if.if_ierrors;
++d->ifp->if_collisions;
++d->ifp->if_ierrors;
#endif
break;
case CP_OVERFLOW:
CP_DEBUG (d, ("overflow error\n"));
#ifndef NETGRAPH
++d->pp.pp_if.if_ierrors;
++d->ifp->if_ierrors;
#endif
break;
case CP_UNDERRUN:
@ -963,9 +971,9 @@ static void cp_error (cp_chan_t *c, int data)
#ifdef NETGRAPH
d->timeout = 0;
#else
++d->pp.pp_if.if_oerrors;
d->pp.pp_if.if_flags &= ~IFF_OACTIVE;
d->pp.pp_if.if_timer = 0;
++d->ifp->if_oerrors;
d->ifp->if_flags &= ~IFF_OACTIVE;
d->ifp->if_timer = 0;
#endif
cp_start (d);
break;
@ -1044,8 +1052,8 @@ static int cp_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
#ifndef NETGRAPH
case SERIAL_GETPROTO:
CP_DEBUG2 (d, ("ioctl: getproto\n"));
strcpy ((char*)data, (d->pp.pp_flags & PP_FR) ? "fr" :
(d->pp.pp_if.if_flags & PP_CISCO) ? "cisco" : "ppp");
strcpy ((char*)data, (IFP2SP(d->ifp)->pp_flags & PP_FR) ? "fr" :
(d->ifp->if_flags & PP_CISCO) ? "cisco" : "ppp");
return 0;
case SERIAL_SETPROTO:
@ -1054,29 +1062,29 @@ static int cp_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
error = suser (td);
if (error)
return error;
if (d->pp.pp_if.if_flags & IFF_RUNNING)
if (d->ifp->if_flags & IFF_RUNNING)
return EBUSY;
if (! strcmp ("cisco", (char*)data)) {
d->pp.pp_flags &= ~(PP_FR);
d->pp.pp_flags |= PP_KEEPALIVE;
d->pp.pp_if.if_flags |= PP_CISCO;
IFP2SP(d->ifp)->pp_flags &= ~(PP_FR);
IFP2SP(d->ifp)->pp_flags |= PP_KEEPALIVE;
d->ifp->if_flags |= PP_CISCO;
} else if (! strcmp ("fr", (char*)data) && PP_FR) {
d->pp.pp_if.if_flags &= ~(PP_CISCO);
d->pp.pp_flags |= PP_FR | PP_KEEPALIVE;
d->ifp->if_flags &= ~(PP_CISCO);
IFP2SP(d->ifp)->pp_flags |= PP_FR | PP_KEEPALIVE;
} else if (! strcmp ("ppp", (char*)data)) {
d->pp.pp_flags &= ~PP_FR;
d->pp.pp_flags &= ~PP_KEEPALIVE;
d->pp.pp_if.if_flags &= ~(PP_CISCO);
IFP2SP(d->ifp)->pp_flags &= ~PP_FR;
IFP2SP(d->ifp)->pp_flags &= ~PP_KEEPALIVE;
d->ifp->if_flags &= ~(PP_CISCO);
} else
return EINVAL;
return 0;
case SERIAL_GETKEEPALIVE:
CP_DEBUG2 (d, ("ioctl: getkeepalive\n"));
if ((d->pp.pp_flags & PP_FR) ||
(d->pp.pp_if.if_flags & PP_CISCO))
if ((IFP2SP(d->ifp)->pp_flags & PP_FR) ||
(d->ifp->if_flags & PP_CISCO))
return EINVAL;
*(int*)data = (d->pp.pp_flags & PP_KEEPALIVE) ? 1 : 0;
*(int*)data = (IFP2SP(d->ifp)->pp_flags & PP_KEEPALIVE) ? 1 : 0;
return 0;
case SERIAL_SETKEEPALIVE:
@ -1085,15 +1093,15 @@ static int cp_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
error = suser (td);
if (error)
return error;
if ((d->pp.pp_flags & PP_FR) ||
(d->pp.pp_if.if_flags & PP_CISCO))
if ((IFP2SP(d->ifp)->pp_flags & PP_FR) ||
(d->ifp->if_flags & PP_CISCO))
return EINVAL;
s = splimp ();
CP_LOCK (bd);
if (*(int*)data)
d->pp.pp_flags |= PP_KEEPALIVE;
IFP2SP(d->ifp)->pp_flags |= PP_KEEPALIVE;
else
d->pp.pp_flags &= ~PP_KEEPALIVE;
IFP2SP(d->ifp)->pp_flags &= ~PP_KEEPALIVE;
CP_UNLOCK (bd);
splx (s);
return 0;
@ -1334,9 +1342,9 @@ static int cp_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
d->chan->debug = *(int*)data;
#ifndef NETGRAPH
if (d->chan->debug)
d->pp.pp_if.if_flags |= IFF_DEBUG;
d->ifp->if_flags |= IFF_DEBUG;
else
d->pp.pp_if.if_flags &= ~IFF_DEBUG;
d->ifp->if_flags &= ~IFF_DEBUG;
#endif
return 0;

View File

@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$");
#include <net/if.h>
#include <net/if_arp.h>
#include <net/if_media.h>
#include <net/if_types.h>
#include <net/ethernet.h>
#include <net/bpf.h>
@ -196,7 +197,7 @@ cs_duplex_auto(struct cs_softc *sc)
RE_NEG_NOW | ALLOW_FDX | AUTO_NEG_ENABLE);
for (i=0; cs_readreg(sc, PP_AutoNegST) & AUTO_NEG_BUSY; i++) {
if (i > 40000) {
if_printf(&sc->arpcom.ac_if,
if_printf(sc->ifp,
"full/half duplex auto negotiation timeout\n");
error = ETIMEDOUT;
break;
@ -216,7 +217,7 @@ enable_tp(struct cs_softc *sc)
DELAY( 150000 );
if ((cs_readreg(sc, PP_LineST) & LINK_OK)==0) {
if_printf(&sc->arpcom.ac_if, "failed to enable TP\n");
if_printf(sc->ifp, "failed to enable TP\n");
return (EINVAL);
}
@ -237,12 +238,12 @@ send_test_pkt(struct cs_softc *sc)
u_char ether_address_backup[ETHER_ADDR_LEN];
for (i = 0; i < ETHER_ADDR_LEN; i++)
ether_address_backup[i] = sc->arpcom.ac_enaddr[i];
ether_address_backup[i] = sc->enaddr[i];
cs_writereg(sc, PP_LineCTL, cs_readreg(sc, PP_LineCTL) | SERIAL_TX_ON);
bcopy(test_packet, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
bcopy(test_packet, sc->enaddr, ETHER_ADDR_LEN);
bcopy(test_packet+ETHER_ADDR_LEN,
sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
sc->enaddr, ETHER_ADDR_LEN);
cs_outw(sc, TX_CMD_PORT, sc->send_cmd);
cs_outw(sc, TX_LEN_PORT, sizeof(test_packet));
@ -250,7 +251,7 @@ send_test_pkt(struct cs_softc *sc)
DELAY(50000);
if (!(cs_readreg(sc, PP_BusST) & READY_FOR_TX_NOW)) {
for (i = 0; i < ETHER_ADDR_LEN; i++)
sc->arpcom.ac_enaddr[i] = ether_address_backup[i];
sc->enaddr[i] = ether_address_backup[i];
return (0);
}
@ -259,7 +260,7 @@ send_test_pkt(struct cs_softc *sc)
DELAY(30000);
for (i = 0; i < ETHER_ADDR_LEN; i++)
sc->arpcom.ac_enaddr[i] = ether_address_backup[i];
sc->enaddr[i] = ether_address_backup[i];
if ((cs_readreg(sc, PP_TxEvent) & TX_SEND_OK_BITS) == TX_OK)
return (1);
return (0);
@ -277,7 +278,7 @@ enable_aui(struct cs_softc *sc)
(sc->line_ctl & ~AUTO_AUI_10BASET) | AUI_ONLY);
if (!send_test_pkt(sc)) {
if_printf(&sc->arpcom.ac_if, "failed to enable AUI\n");
if_printf(sc->ifp, "failed to enable AUI\n");
return (EINVAL);
}
return (0);
@ -295,7 +296,7 @@ enable_bnc(struct cs_softc *sc)
(sc->line_ctl & ~AUTO_AUI_10BASET) | AUI_ONLY);
if (!send_test_pkt(sc)) {
if_printf(&sc->arpcom.ac_if, "failed to enable BNC\n");
if_printf(sc->ifp, "failed to enable BNC\n");
return (EINVAL);
}
return (0);
@ -390,9 +391,9 @@ cs_cs89x0_probe(device_t dev)
eeprom_buff[ISA_CNF_OFFSET/2];
for (i=0; i<ETHER_ADDR_LEN/2; i++) {
sc->arpcom.ac_enaddr[i*2]=
sc->enaddr[i*2]=
eeprom_buff[i];
sc->arpcom.ac_enaddr[i*2+1]=
sc->enaddr[i*2+1]=
eeprom_buff[i] >> 8;
}
@ -582,7 +583,13 @@ cs_attach(device_t dev)
{
int media=0;
struct cs_softc *sc = device_get_softc(dev);;
struct ifnet *ifp = &(sc->arpcom.ac_if);
struct ifnet *ifp;
ifp = sc->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
return (0);
}
cs_stop( sc );
@ -672,7 +679,7 @@ cs_attach(device_t dev)
ifmedia_set(&sc->media, media);
cs_mediaset(sc, media);
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
ether_ifattach(ifp, sc->enaddr);
return (0);
}
@ -684,11 +691,12 @@ cs_detach(device_t dev)
struct ifnet *ifp;
sc = device_get_softc(dev);
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
cs_stop(sc);
ifp->if_flags &= ~IFF_RUNNING;
ether_ifdetach(ifp);
if_free(ifp);
cs_release_resources(dev);
return (0);
}
@ -700,7 +708,7 @@ static void
cs_init(void *xsc)
{
struct cs_softc *sc=(struct cs_softc *)xsc;
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->ifp;
int i, s, rx_cfg;
/*
@ -742,8 +750,8 @@ cs_init(void *xsc)
/* Write MAC address into IA filter */
for (i=0; i<ETHER_ADDR_LEN/2; i++)
cs_writereg(sc, PP_IA + i * 2,
sc->arpcom.ac_enaddr[i * 2] |
(sc->arpcom.ac_enaddr[i * 2 + 1] << 8) );
sc->enaddr[i * 2] |
(sc->enaddr[i * 2 + 1] << 8) );
/*
* Now enable everything
@ -760,8 +768,8 @@ cs_init(void *xsc)
/*
* Set running and clear output active flags
*/
sc->arpcom.ac_if.if_flags |= IFF_RUNNING;
sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
sc->ifp->if_flags |= IFF_RUNNING;
sc->ifp->if_flags &= ~IFF_OACTIVE;
/*
* Start sending process
@ -777,7 +785,7 @@ cs_init(void *xsc)
static int
cs_get_packet(struct cs_softc *sc)
{
struct ifnet *ifp = &(sc->arpcom.ac_if);
struct ifnet *ifp = sc->ifp;
int iobase = sc->nic_addr, status, length;
struct ether_header *eh;
struct mbuf *m;
@ -851,7 +859,7 @@ void
csintr(void *arg)
{
struct cs_softc *sc = (struct cs_softc*) arg;
struct ifnet *ifp = &(sc->arpcom.ac_if);
struct ifnet *ifp = sc->ifp;
int status;
#ifdef CS_DEBUG
@ -1027,8 +1035,8 @@ cs_stop(struct cs_softc *sc)
cs_writereg(sc, PP_BufCFG, 0);
cs_writereg(sc, PP_BusCTL, 0);
sc->arpcom.ac_if.if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
sc->arpcom.ac_if.if_timer = 0;
sc->ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
sc->ifp->if_timer = 0;
(void) splx(s);
}
@ -1046,7 +1054,7 @@ cs_reset(struct cs_softc *sc)
static void
cs_setmode(struct cs_softc *sc)
{
struct ifnet *ifp = &(sc->arpcom.ac_if);
struct ifnet *ifp = sc->ifp;
int rx_ctl;
/* Stop the receiver while changing filters */
@ -1103,12 +1111,12 @@ cs_ioctl(register struct ifnet *ifp, u_long command, caddr_t data)
* Switch interface state between "running" and
* "stopped", reflecting the UP flag.
*/
if (sc->arpcom.ac_if.if_flags & IFF_UP) {
if ((sc->arpcom.ac_if.if_flags & IFF_RUNNING)==0) {
if (sc->ifp->if_flags & IFF_UP) {
if ((sc->ifp->if_flags & IFF_RUNNING)==0) {
cs_init(sc);
}
} else {
if ((sc->arpcom.ac_if.if_flags & IFF_RUNNING)!=0) {
if ((sc->ifp->if_flags & IFF_RUNNING)!=0) {
cs_stop(sc);
}
}
@ -1220,7 +1228,7 @@ cs_mediaset(struct cs_softc *sc, int media)
~(SERIAL_RX_ON | SERIAL_TX_ON));
#ifdef CS_DEBUG
if_printf(&sc->arpcom.ac_if, "cs_setmedia(%x)\n", media);
if_printf(sc->ifp, "cs_setmedia(%x)\n", media);
#endif
switch (IFM_SUBTYPE(media)) {

View File

@ -36,7 +36,7 @@
*/
struct cs_softc {
/* Ethernet common code */
struct arpcom arpcom;
struct ifnet *ifp;
/* Configuration words from EEPROM */
int auto_neg_cnf; /* AutoNegotitation configuration */
@ -44,6 +44,8 @@ struct cs_softc {
int isa_config; /* ISA configuration */
int chip_type; /* Type of chip */
u_char enaddr[6];
struct ifmedia media; /* Media information */
int port_rid; /* resource id for port range */

View File

@ -137,7 +137,7 @@ typedef struct _drv_t {
struct callout timeout_handle;
#else
struct ifqueue queue;
struct sppp pp;
struct ifnet *ifp;
#endif
struct cdev *devt;
} drv_t;
@ -291,7 +291,7 @@ static void ct_intr (void *arg)
IF_DEQUEUE (&d->queue,m);
if (!m)
continue;
sppp_input (&d->pp.pp_if, m);
sppp_input (d->ifp, m);
}
}
#endif
@ -732,25 +732,34 @@ static int ct_attach (device_t dev)
callout_init (&d->timeout_handle,
ct_mpsafenet ? CALLOUT_MPSAFE : 0);
#else /*NETGRAPH*/
d->pp.pp_if.if_softc = d;
if_initname (&d->pp.pp_if, "ct", b->num * NCHAN + c->num);
d->pp.pp_if.if_mtu = PP_MTU;
d->pp.pp_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
d->ifp = if_alloc(IFT_PPP);
if (d->ifp == NULL) {
printf ("%s: cannot if_alloc common interface\n",
d->name);
channel [b->num*NCHAN + c->num] = 0;
c->sys = 0;
ct_bus_dma_mem_free (&d->dmamem);
continue;
}
d->ifp->if_softc = d;
if_initname (d->ifp, "ct", b->num * NCHAN + c->num);
d->ifp->if_mtu = PP_MTU;
d->ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
if (!ct_mpsafenet)
d->pp.pp_if.if_flags |= IFF_NEEDSGIANT;
d->pp.pp_if.if_ioctl = ct_sioctl;
d->pp.pp_if.if_start = ct_ifstart;
d->pp.pp_if.if_watchdog = ct_ifwatchdog;
d->pp.pp_if.if_init = ct_initialize;
d->ifp->if_flags |= IFF_NEEDSGIANT;
d->ifp->if_ioctl = ct_sioctl;
d->ifp->if_start = ct_ifstart;
d->ifp->if_watchdog = ct_ifwatchdog;
d->ifp->if_init = ct_initialize;
d->queue.ifq_maxlen = NBUF;
mtx_init (&d->queue.ifq_mtx, "ct_queue", NULL, MTX_DEF);
sppp_attach (&d->pp.pp_if);
if_attach (&d->pp.pp_if);
d->pp.pp_tlf = ct_tlf;
d->pp.pp_tls = ct_tls;
sppp_attach (d->ifp);
if_attach (d->ifp);
IFP2SP(d->ifp)->pp_tlf = ct_tlf;
IFP2SP(d->ifp)->pp_tls = ct_tls;
/* If BPF is in the kernel, call the attach for it.
* Header size is 4 bytes. */
bpfattach (&d->pp.pp_if, DLT_PPP, 4);
bpfattach (d->ifp, DLT_PPP, 4);
#endif /*NETGRAPH*/
CT_LOCK (bd);
ct_start_chan (c, d->dmamem.virt, d->dmamem.phys);
@ -827,12 +836,13 @@ static int ct_detach (device_t dev)
mtx_destroy (&d->hi_queue.ifq_mtx);
#else
/* Detach from the packet filter list of interfaces. */
bpfdetach (&d->pp.pp_if);
bpfdetach (d->ifp);
/* Detach from the sync PPP list. */
sppp_detach (&d->pp.pp_if);
sppp_detach (d->ifp);
if_detach (&d->pp.pp_if);
if_detach (d->ifp);
if_free (d->ifp);
IF_DRAIN (&d->queue);
mtx_destroy (&d->queue.ifq_mtx);
#endif
@ -885,21 +895,21 @@ static void ct_ifwatchdog (struct ifnet *ifp)
static void ct_tlf (struct sppp *sp)
{
drv_t *d = sp->pp_if.if_softc;
drv_t *d = SP2IFP(sp)->if_softc;
CT_DEBUG (d, ("ct_tlf\n"));
/* ct_set_dtr (d->chan, 0);*/
/* ct_set_rts (d->chan, 0);*/
if (!(d->pp.pp_flags & PP_FR) && !(d->pp.pp_if.if_flags & PP_CISCO))
if (!(sp->pp_flags & PP_FR) && !(d->ifp->if_flags & PP_CISCO))
sp->pp_down (sp);
}
static void ct_tls (struct sppp *sp)
{
drv_t *d = sp->pp_if.if_softc;
drv_t *d = SP2IFP(sp)->if_softc;
CT_DEBUG (d, ("ct_tls\n"));
if (!(d->pp.pp_flags & PP_FR) && !(d->pp.pp_if.if_flags & PP_CISCO))
if (!(sp->pp_flags & PP_FR) && !(d->ifp->if_flags & PP_CISCO))
sp->pp_up (sp);
}
@ -951,7 +961,7 @@ static int ct_sioctl (struct ifnet *ifp, u_long cmd, caddr_t data)
ct_start (d);
} else if (was_up && ! should_be_up) {
/* Interface is going down -- stop it. */
/* if ((d->pp.pp_flags & PP_FR) || (ifp->if_flags & PP_CISCO))*/
/* if ((IFP2SP(d->ifp)->pp_flags & PP_FR) || (ifp->if_flags & PP_CISCO))*/
ct_down (d);
}
CT_UNLOCK (bd);
@ -1013,13 +1023,13 @@ static void ct_send (drv_t *d)
if (! m)
IF_DEQUEUE (&d->queue, m);
#else
m = sppp_dequeue (&d->pp.pp_if);
m = sppp_dequeue (d->ifp);
#endif
if (! m)
return;
#ifndef NETGRAPH
if (d->pp.pp_if.if_bpf)
BPF_MTAP (&d->pp.pp_if, m);
if (d->ifp->if_bpf)
BPF_MTAP (d->ifp, m);
#endif
len = m->m_pkthdr.len;
if (! m->m_next)
@ -1037,11 +1047,11 @@ static void ct_send (drv_t *d)
#ifdef NETGRAPH
d->timeout = 10;
#else
d->pp.pp_if.if_timer = 10;
d->ifp->if_timer = 10;
#endif
}
#ifndef NETGRAPH
d->pp.pp_if.if_flags |= IFF_OACTIVE;
d->ifp->if_flags |= IFF_OACTIVE;
#endif
}
@ -1100,9 +1110,9 @@ static void ct_transmit (ct_chan_t *c, void *attachment, int len)
#ifdef NETGRAPH
d->timeout = 0;
#else
++d->pp.pp_if.if_opackets;
d->pp.pp_if.if_flags &= ~IFF_OACTIVE;
d->pp.pp_if.if_timer = 0;
++d->ifp->if_opackets;
d->ifp->if_flags &= ~IFF_OACTIVE;
d->ifp->if_timer = 0;
#endif
ct_start (d);
}
@ -1125,7 +1135,7 @@ static void ct_receive (ct_chan_t *c, char *data, int len)
if (! m) {
CT_DEBUG (d, ("no memory for packet\n"));
#ifndef NETGRAPH
++d->pp.pp_if.if_iqdrops;
++d->ifp->if_iqdrops;
#endif
return;
}
@ -1135,12 +1145,12 @@ static void ct_receive (ct_chan_t *c, char *data, int len)
m->m_pkthdr.rcvif = 0;
NG_SEND_DATA_ONLY (error, d->hook, m);
#else
++d->pp.pp_if.if_ipackets;
m->m_pkthdr.rcvif = &d->pp.pp_if;
++d->ifp->if_ipackets;
m->m_pkthdr.rcvif = d->ifp;
/* Check if there's a BPF listener on this interface.
* If so, hand off the raw packet to bpf. */
if (d->pp.pp_if.if_bpf)
BPF_TAP (&d->pp.pp_if, data, len);
if (d->ifp->if_bpf)
BPF_TAP (d->ifp, data, len);
IF_ENQUEUE (&d->queue, m);
#endif
}
@ -1159,26 +1169,26 @@ static void ct_error (ct_chan_t *c, int data)
case CT_FRAME:
CT_DEBUG (d, ("frame error\n"));
#ifndef NETGRAPH
++d->pp.pp_if.if_ierrors;
++d->ifp->if_ierrors;
#endif
break;
case CT_CRC:
CT_DEBUG (d, ("crc error\n"));
#ifndef NETGRAPH
++d->pp.pp_if.if_ierrors;
++d->ifp->if_ierrors;
#endif
break;
case CT_OVERRUN:
CT_DEBUG (d, ("overrun error\n"));
#ifndef NETGRAPH
++d->pp.pp_if.if_collisions;
++d->pp.pp_if.if_ierrors;
++d->ifp->if_collisions;
++d->ifp->if_ierrors;
#endif
break;
case CT_OVERFLOW:
CT_DEBUG (d, ("overflow error\n"));
#ifndef NETGRAPH
++d->pp.pp_if.if_ierrors;
++d->ifp->if_ierrors;
#endif
break;
case CT_UNDERRUN:
@ -1186,9 +1196,9 @@ static void ct_error (ct_chan_t *c, int data)
#ifdef NETGRAPH
d->timeout = 0;
#else
++d->pp.pp_if.if_oerrors;
d->pp.pp_if.if_flags &= ~IFF_OACTIVE;
d->pp.pp_if.if_timer = 0;
++d->ifp->if_oerrors;
d->ifp->if_flags &= ~IFF_OACTIVE;
d->ifp->if_timer = 0;
#endif
ct_start (d);
break;
@ -1273,8 +1283,8 @@ static int ct_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
#ifndef NETGRAPH
case SERIAL_GETPROTO:
strcpy ((char*)data, (d->pp.pp_flags & PP_FR) ? "fr" :
(d->pp.pp_if.if_flags & PP_CISCO) ? "cisco" : "ppp");
strcpy ((char*)data, (IFP2SP(d->ifp)->pp_flags & PP_FR) ? "fr" :
(d->ifp->if_flags & PP_CISCO) ? "cisco" : "ppp");
return 0;
case SERIAL_SETPROTO:
@ -1282,27 +1292,27 @@ static int ct_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
error = suser (td);
if (error)
return error;
if (d->pp.pp_if.if_flags & IFF_RUNNING)
if (d->ifp->if_flags & IFF_RUNNING)
return EBUSY;
if (! strcmp ("cisco", (char*)data)) {
d->pp.pp_flags &= ~(PP_FR);
d->pp.pp_flags |= PP_KEEPALIVE;
d->pp.pp_if.if_flags |= PP_CISCO;
IFP2SP(d->ifp)->pp_flags &= ~(PP_FR);
IFP2SP(d->ifp)->pp_flags |= PP_KEEPALIVE;
d->ifp->if_flags |= PP_CISCO;
} else if (! strcmp ("fr", (char*)data)) {
d->pp.pp_if.if_flags &= ~(PP_CISCO);
d->pp.pp_flags |= PP_FR | PP_KEEPALIVE;
d->ifp->if_flags &= ~(PP_CISCO);
IFP2SP(d->ifp)->pp_flags |= PP_FR | PP_KEEPALIVE;
} else if (! strcmp ("ppp", (char*)data)) {
d->pp.pp_flags &= ~(PP_FR | PP_KEEPALIVE);
d->pp.pp_if.if_flags &= ~(PP_CISCO);
IFP2SP(d->ifp)->pp_flags &= ~(PP_FR | PP_KEEPALIVE);
d->ifp->if_flags &= ~(PP_CISCO);
} else
return EINVAL;
return 0;
case SERIAL_GETKEEPALIVE:
if ((d->pp.pp_flags & PP_FR) ||
(d->pp.pp_if.if_flags & PP_CISCO))
if ((IFP2SP(d->ifp)->pp_flags & PP_FR) ||
(d->ifp->if_flags & PP_CISCO))
return EINVAL;
*(int*)data = (d->pp.pp_flags & PP_KEEPALIVE) ? 1 : 0;
*(int*)data = (IFP2SP(d->ifp)->pp_flags & PP_KEEPALIVE) ? 1 : 0;
return 0;
case SERIAL_SETKEEPALIVE:
@ -1310,13 +1320,13 @@ static int ct_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
error = suser (td);
if (error)
return error;
if ((d->pp.pp_flags & PP_FR) ||
(d->pp.pp_if.if_flags & PP_CISCO))
if ((IFP2SP(d->ifp)->pp_flags & PP_FR) ||
(d->ifp->if_flags & PP_CISCO))
return EINVAL;
if (*(int*)data)
d->pp.pp_flags |= PP_KEEPALIVE;
IFP2SP(d->ifp)->pp_flags |= PP_KEEPALIVE;
else
d->pp.pp_flags &= ~PP_KEEPALIVE;
IFP2SP(d->ifp)->pp_flags &= ~PP_KEEPALIVE;
return 0;
#endif /*NETGRAPH*/
@ -1515,9 +1525,9 @@ static int ct_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
c->debug = *(int*)data;
#ifndef NETGRAPH
if (d->chan->debug)
d->pp.pp_if.if_flags |= IFF_DEBUG;
d->ifp->if_flags |= IFF_DEBUG;
else
d->pp.pp_if.if_flags &= (~IFF_DEBUG);
d->ifp->if_flags &= (~IFF_DEBUG);
#endif
return 0;

View File

@ -162,7 +162,7 @@ typedef struct _drv_t {
struct callout timeout_handle;
#else
struct ifqueue queue;
struct sppp pp;
struct ifnet *ifp;
#endif
struct cdev *devt;
async_q aqueue;
@ -378,7 +378,7 @@ static void cx_intr (void *arg)
IF_DEQUEUE (&d->queue,m);
if (!m)
continue;
sppp_input (&d->pp.pp_if, m);
sppp_input (d->ifp, m);
}
}
#endif
@ -839,24 +839,33 @@ static int cx_attach (device_t dev)
callout_init (&d->timeout_handle,
cx_mpsafenet ? CALLOUT_MPSAFE : 0);
#else /*NETGRAPH*/
d->pp.pp_if.if_softc = d;
if_initname (&d->pp.pp_if, "cx", b->num * NCHAN + c->num);
d->pp.pp_if.if_mtu = PP_MTU;
d->pp.pp_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST |
d->ifp = if_alloc(IFT_PPP);
if (d->ifp == NULL) {
printf ("%s: cannot if_alloc() common interface\n",
d->name);
channel [b->num*NCHAN + c->num] = 0;
c->sys = 0;
cx_bus_dma_mem_free (&d->dmamem);
continue;
}
d->ifp->if_softc = d;
if_initname (d->ifp, "cx", b->num * NCHAN + c->num);
d->ifp->if_mtu = PP_MTU;
d->ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST |
IFF_NEEDSGIANT;
d->pp.pp_if.if_ioctl = cx_sioctl;
d->pp.pp_if.if_start = cx_ifstart;
d->pp.pp_if.if_watchdog = cx_ifwatchdog;
d->pp.pp_if.if_init = cx_initialize;
d->ifp->if_ioctl = cx_sioctl;
d->ifp->if_start = cx_ifstart;
d->ifp->if_watchdog = cx_ifwatchdog;
d->ifp->if_init = cx_initialize;
d->queue.ifq_maxlen = 2;
mtx_init (&d->queue.ifq_mtx, "cx_queue", NULL, MTX_DEF);
sppp_attach (&d->pp.pp_if);
if_attach (&d->pp.pp_if);
d->pp.pp_tlf = cx_tlf;
d->pp.pp_tls = cx_tls;
sppp_attach (d->ifp);
if_attach (d->ifp);
IFP2SP(d->ifp)->pp_tlf = cx_tlf;
IFP2SP(d->ifp)->pp_tls = cx_tls;
/* If BPF is in the kernel, call the attach for it.
* Size of PPP header is 4 bytes. */
bpfattach (&d->pp.pp_if, DLT_PPP, 4);
bpfattach (d->ifp, DLT_PPP, 4);
#endif /*NETGRAPH*/
}
d->tty = ttyalloc ();
@ -968,11 +977,12 @@ static int cx_detach (device_t dev)
mtx_destroy (&d->hi_queue.ifq_mtx);
#else
/* Detach from the packet filter list of interfaces. */
bpfdetach (&d->pp.pp_if);
bpfdetach (d->ifp);
/* Detach from the sync PPP list. */
sppp_detach (&d->pp.pp_if);
sppp_detach (d->ifp);
if_detach (&d->pp.pp_if);
if_detach (d->ifp);
if_free(d->ifp);
/* XXXRIK: check interconnection with irq handler */
IF_DRAIN (&d->queue);
mtx_destroy (&d->queue.ifq_mtx);
@ -1033,21 +1043,21 @@ static void cx_ifwatchdog (struct ifnet *ifp)
static void cx_tlf (struct sppp *sp)
{
drv_t *d = sp->pp_if.if_softc;
drv_t *d = SP2IFP(sp)->if_softc;
CX_DEBUG (d, ("cx_tlf\n"));
/* cx_set_dtr (d->chan, 0);*/
/* cx_set_rts (d->chan, 0);*/
if (!(d->pp.pp_flags & PP_FR) && !(d->pp.pp_if.if_flags & PP_CISCO))
if (!(IFP2SP(d->ifp)->pp_flags & PP_FR) && !(d->ifp->if_flags & PP_CISCO))
sp->pp_down (sp);
}
static void cx_tls (struct sppp *sp)
{
drv_t *d = sp->pp_if.if_softc;
drv_t *d = SP2IFP(sp)->if_softc;
CX_DEBUG (d, ("cx_tls\n"));
if (!(d->pp.pp_flags & PP_FR) && !(d->pp.pp_if.if_flags & PP_CISCO))
if (!(IFP2SP(d->ifp)->pp_flags & PP_FR) && !(d->ifp->if_flags & PP_CISCO))
sp->pp_up (sp);
}
@ -1104,7 +1114,7 @@ static int cx_sioctl (struct ifnet *ifp, u_long cmd, caddr_t data)
cx_start (d);
} else if (was_up && !should_be_up) {
/* Interface is going down -- stop it. */
/* if ((d->pp.pp_flags & PP_FR) || (ifp->if_flags & PP_CISCO))*/
/* if ((IFP2SP(d->ifp)->pp_flags & PP_FR) || (ifp->if_flags & PP_CISCO))*/
cx_down (d);
}
CX_UNLOCK (bd);
@ -1166,13 +1176,13 @@ static void cx_send (drv_t *d)
if (! m)
IF_DEQUEUE (&d->lo_queue, m);
#else
m = sppp_dequeue (&d->pp.pp_if);
m = sppp_dequeue (d->ifp);
#endif
if (! m)
return;
#ifndef NETGRAPH
if (d->pp.pp_if.if_bpf)
BPF_MTAP (&d->pp.pp_if, m);
if (d->ifp->if_bpf)
BPF_MTAP (d->ifp, m);
#endif
len = m->m_pkthdr.len;
if (! m->m_next)
@ -1189,11 +1199,11 @@ static void cx_send (drv_t *d)
#ifdef NETGRAPH
d->timeout = 10;
#else
d->pp.pp_if.if_timer = 10;
d->ifp->if_timer = 10;
#endif
}
#ifndef NETGRAPH
d->pp.pp_if.if_flags |= IFF_OACTIVE;
d->ifp->if_flags |= IFF_OACTIVE;
#endif
}
@ -1260,9 +1270,9 @@ static void cx_transmit (cx_chan_t *c, void *attachment, int len)
#ifdef NETGRAPH
d->timeout = 0;
#else
++d->pp.pp_if.if_opackets;
d->pp.pp_if.if_flags &= ~IFF_OACTIVE;
d->pp.pp_if.if_timer = 0;
++d->ifp->if_opackets;
d->ifp->if_flags &= ~IFF_OACTIVE;
d->ifp->if_timer = 0;
#endif
cx_start (d);
}
@ -1314,7 +1324,7 @@ static void cx_receive (cx_chan_t *c, char *data, int len)
if (! m) {
CX_DEBUG (d, ("no memory for packet\n"));
#ifndef NETGRAPH
++d->pp.pp_if.if_iqdrops;
++d->ifp->if_iqdrops;
#endif
return;
}
@ -1324,12 +1334,12 @@ static void cx_receive (cx_chan_t *c, char *data, int len)
m->m_pkthdr.rcvif = 0;
NG_SEND_DATA_ONLY (error, d->hook, m);
#else
++d->pp.pp_if.if_ipackets;
m->m_pkthdr.rcvif = &d->pp.pp_if;
++d->ifp->if_ipackets;
m->m_pkthdr.rcvif = d->ifp;
/* Check if there's a BPF listener on this interface.
* If so, hand off the raw packet to bpf. */
if (d->pp.pp_if.if_bpf)
BPF_TAP (&d->pp.pp_if, data, len);
if (d->ifp->if_bpf)
BPF_TAP (d->ifp, data, len);
IF_ENQUEUE (&d->queue, m);
#endif
}
@ -1368,7 +1378,7 @@ static void cx_error (cx_chan_t *c, int data)
}
#ifndef NETGRAPH
else
++d->pp.pp_if.if_ierrors;
++d->ifp->if_ierrors;
#endif
break;
case CX_CRC:
@ -1385,7 +1395,7 @@ static void cx_error (cx_chan_t *c, int data)
}
#ifndef NETGRAPH
else
++d->pp.pp_if.if_ierrors;
++d->ifp->if_ierrors;
#endif
break;
case CX_OVERRUN:
@ -1402,8 +1412,8 @@ static void cx_error (cx_chan_t *c, int data)
#endif
#ifndef NETGRAPH
else {
++d->pp.pp_if.if_collisions;
++d->pp.pp_if.if_ierrors;
++d->ifp->if_collisions;
++d->ifp->if_ierrors;
}
#endif
break;
@ -1411,7 +1421,7 @@ static void cx_error (cx_chan_t *c, int data)
CX_DEBUG (d, ("overflow error\n"));
#ifndef NETGRAPH
if (c->mode != M_ASYNC)
++d->pp.pp_if.if_ierrors;
++d->ifp->if_ierrors;
#endif
break;
case CX_UNDERRUN:
@ -1420,9 +1430,9 @@ static void cx_error (cx_chan_t *c, int data)
#ifdef NETGRAPH
d->timeout = 0;
#else
++d->pp.pp_if.if_oerrors;
d->pp.pp_if.if_flags &= ~IFF_OACTIVE;
d->pp.pp_if.if_timer = 0;
++d->ifp->if_oerrors;
d->ifp->if_flags &= ~IFF_OACTIVE;
d->ifp->if_timer = 0;
cx_start (d);
#endif
}
@ -1440,7 +1450,7 @@ static void cx_error (cx_chan_t *c, int data)
}
#ifndef NETGRAPH
else
++d->pp.pp_if.if_ierrors;
++d->ifp->if_ierrors;
#endif
break;
default:
@ -1625,8 +1635,8 @@ static int cx_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
s = splhigh ();
CX_LOCK (bd);
strcpy ((char*)data, (c->mode == M_ASYNC) ? "async" :
(d->pp.pp_flags & PP_FR) ? "fr" :
(d->pp.pp_if.if_flags & PP_CISCO) ? "cisco" : "ppp");
(IFP2SP(d->ifp)->pp_flags & PP_FR) ? "fr" :
(d->ifp->if_flags & PP_CISCO) ? "cisco" : "ppp");
CX_UNLOCK (bd);
splx (s);
return 0;
@ -1639,31 +1649,31 @@ static int cx_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
return error;
if (c->mode == M_ASYNC)
return EBUSY;
if (d->pp.pp_if.if_flags & IFF_RUNNING)
if (d->ifp->if_flags & IFF_RUNNING)
return EBUSY;
if (! strcmp ("cisco", (char*)data)) {
d->pp.pp_flags &= ~(PP_FR);
d->pp.pp_flags |= PP_KEEPALIVE;
d->pp.pp_if.if_flags |= PP_CISCO;
IFP2SP(d->ifp)->pp_flags &= ~(PP_FR);
IFP2SP(d->ifp)->pp_flags |= PP_KEEPALIVE;
d->ifp->if_flags |= PP_CISCO;
} else if (! strcmp ("fr", (char*)data)) {
d->pp.pp_if.if_flags &= ~(PP_CISCO);
d->pp.pp_flags |= PP_FR | PP_KEEPALIVE;
d->ifp->if_flags &= ~(PP_CISCO);
IFP2SP(d->ifp)->pp_flags |= PP_FR | PP_KEEPALIVE;
} else if (! strcmp ("ppp", (char*)data)) {
d->pp.pp_flags &= ~(PP_FR | PP_KEEPALIVE);
d->pp.pp_if.if_flags &= ~(PP_CISCO);
IFP2SP(d->ifp)->pp_flags &= ~(PP_FR | PP_KEEPALIVE);
d->ifp->if_flags &= ~(PP_CISCO);
} else
return EINVAL;
return 0;
case SERIAL_GETKEEPALIVE:
CX_DEBUG2 (d, ("ioctl: getkeepalive\n"));
if ((d->pp.pp_flags & PP_FR) ||
(d->pp.pp_if.if_flags & PP_CISCO) ||
if ((IFP2SP(d->ifp)->pp_flags & PP_FR) ||
(d->ifp->if_flags & PP_CISCO) ||
(c->mode == M_ASYNC))
return EINVAL;
s = splhigh ();
CX_LOCK (bd);
*(int*)data = (d->pp.pp_flags & PP_KEEPALIVE) ? 1 : 0;
*(int*)data = (IFP2SP(d->ifp)->pp_flags & PP_KEEPALIVE) ? 1 : 0;
CX_UNLOCK (bd);
splx (s);
return 0;
@ -1674,15 +1684,15 @@ static int cx_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
error = suser (td);
if (error)
return error;
if ((d->pp.pp_flags & PP_FR) ||
(d->pp.pp_if.if_flags & PP_CISCO))
if ((IFP2SP(d->ifp)->pp_flags & PP_FR) ||
(d->ifp->if_flags & PP_CISCO))
return EINVAL;
s = splhigh ();
CX_LOCK (bd);
if (*(int*)data)
d->pp.pp_flags |= PP_KEEPALIVE;
IFP2SP(d->ifp)->pp_flags |= PP_KEEPALIVE;
else
d->pp.pp_flags &= ~PP_KEEPALIVE;
IFP2SP(d->ifp)->pp_flags &= ~PP_KEEPALIVE;
CX_UNLOCK (bd);
splx (s);
return 0;
@ -1898,9 +1908,9 @@ static int cx_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
splx (s);
#ifndef NETGRAPH
if (d->chan->debug)
d->pp.pp_if.if_flags |= IFF_DEBUG;
d->ifp->if_flags |= IFF_DEBUG;
else
d->pp.pp_if.if_flags &= (~IFF_DEBUG);
d->ifp->if_flags &= (~IFF_DEBUG);
#endif
return 0;
}

View File

@ -1084,7 +1084,7 @@ dc_setfilt_21143(struct dc_softc *sc)
struct ifnet *ifp;
int i;
ifp = &sc->arpcom.ac_if;
ifp = sc->dc_ifp;
i = sc->dc_cdata.dc_tx_prod;
DC_INC(sc->dc_cdata.dc_tx_prod, DC_TX_LIST_CNT);
@ -1124,9 +1124,9 @@ dc_setfilt_21143(struct dc_softc *sc)
}
/* Set our MAC address */
sp[39] = DC_SP_MAC(((u_int16_t *)sc->arpcom.ac_enaddr)[0]);
sp[40] = DC_SP_MAC(((u_int16_t *)sc->arpcom.ac_enaddr)[1]);
sp[41] = DC_SP_MAC(((u_int16_t *)sc->arpcom.ac_enaddr)[2]);
sp[39] = DC_SP_MAC(((u_int16_t *)IFP2ENADDR(sc->dc_ifp))[0]);
sp[40] = DC_SP_MAC(((u_int16_t *)IFP2ENADDR(sc->dc_ifp))[1]);
sp[41] = DC_SP_MAC(((u_int16_t *)IFP2ENADDR(sc->dc_ifp))[2]);
sframe->dc_status = htole32(DC_TXSTAT_OWN);
CSR_WRITE_4(sc, DC_TXSTART, 0xFFFFFFFF);
@ -1150,11 +1150,11 @@ dc_setfilt_admtek(struct dc_softc *sc)
int h = 0;
u_int32_t hashes[2] = { 0, 0 };
ifp = &sc->arpcom.ac_if;
ifp = sc->dc_ifp;
/* Init our MAC address. */
CSR_WRITE_4(sc, DC_AL_PAR0, *(u_int32_t *)(&sc->arpcom.ac_enaddr[0]));
CSR_WRITE_4(sc, DC_AL_PAR1, *(u_int32_t *)(&sc->arpcom.ac_enaddr[4]));
CSR_WRITE_4(sc, DC_AL_PAR0, *(u_int32_t *)(&IFP2ENADDR(sc->dc_ifp)[0]));
CSR_WRITE_4(sc, DC_AL_PAR1, *(u_int32_t *)(&IFP2ENADDR(sc->dc_ifp)[4]));
/* If we want promiscuous mode, set the allframes bit. */
if (ifp->if_flags & IFF_PROMISC)
@ -1206,15 +1206,15 @@ dc_setfilt_asix(struct dc_softc *sc)
int h = 0;
u_int32_t hashes[2] = { 0, 0 };
ifp = &sc->arpcom.ac_if;
ifp = sc->dc_ifp;
/* Init our MAC address */
CSR_WRITE_4(sc, DC_AX_FILTIDX, DC_AX_FILTIDX_PAR0);
CSR_WRITE_4(sc, DC_AX_FILTDATA,
*(u_int32_t *)(&sc->arpcom.ac_enaddr[0]));
*(u_int32_t *)(&IFP2ENADDR(sc->dc_ifp)[0]));
CSR_WRITE_4(sc, DC_AX_FILTIDX, DC_AX_FILTIDX_PAR1);
CSR_WRITE_4(sc, DC_AX_FILTDATA,
*(u_int32_t *)(&sc->arpcom.ac_enaddr[4]));
*(u_int32_t *)(&IFP2ENADDR(sc->dc_ifp)[4]));
/* If we want promiscuous mode, set the allframes bit. */
if (ifp->if_flags & IFF_PROMISC)
@ -1275,7 +1275,7 @@ dc_setfilt_xircom(struct dc_softc *sc)
u_int32_t h, *sp;
int i;
ifp = &sc->arpcom.ac_if;
ifp = sc->dc_ifp;
DC_CLRBIT(sc, DC_NETCFG, (DC_NETCFG_TX_ON | DC_NETCFG_RX_ON));
i = sc->dc_cdata.dc_tx_prod;
@ -1316,9 +1316,9 @@ dc_setfilt_xircom(struct dc_softc *sc)
}
/* Set our MAC address */
sp[0] = DC_SP_MAC(((u_int16_t *)sc->arpcom.ac_enaddr)[0]);
sp[1] = DC_SP_MAC(((u_int16_t *)sc->arpcom.ac_enaddr)[1]);
sp[2] = DC_SP_MAC(((u_int16_t *)sc->arpcom.ac_enaddr)[2]);
sp[0] = DC_SP_MAC(((u_int16_t *)IFP2ENADDR(sc->dc_ifp))[0]);
sp[1] = DC_SP_MAC(((u_int16_t *)IFP2ENADDR(sc->dc_ifp))[1]);
sp[2] = DC_SP_MAC(((u_int16_t *)IFP2ENADDR(sc->dc_ifp))[2]);
DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON);
DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_ON);
@ -2090,7 +2090,6 @@ dc_attach(device_t dev)
}
sc->dc_unit = unit;
bcopy(eaddr, &sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
/* Allocate a busdma tag and DMA safe memory for TX/RX descriptors. */
error = bus_dma_tag_create(NULL, PAGE_SIZE, 0, BUS_SPACE_MAXADDR_32BIT,
@ -2180,7 +2179,12 @@ dc_attach(device_t dev)
goto fail;
}
ifp = &sc->arpcom.ac_if;
ifp = sc->dc_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
printf("dc%d: can not if_alloc()\n", unit);
error = ENOSPC;
goto fail;
}
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
/* XXX: bleah, MTU gets overwritten in ether_ifattach() */
@ -2309,6 +2313,7 @@ dc_attach(device_t dev)
if (error) {
printf("dc%d: couldn't set up irq\n", unit);
ether_ifdetach(ifp);
if_free(ifp);
goto fail;
}
@ -2337,12 +2342,13 @@ dc_detach(device_t dev)
KASSERT(mtx_initialized(&sc->dc_mtx), ("dc mutex not initialized"));
DC_LOCK(sc);
ifp = &sc->arpcom.ac_if;
ifp = sc->dc_ifp;
/* These should only be active if attach succeeded */
if (device_is_attached(dev)) {
dc_stop(sc);
ether_ifdetach(ifp);
if_free(ifp);
}
if (sc->dc_miibus)
device_delete_child(dev, sc->dc_miibus);
@ -2687,7 +2693,7 @@ dc_rxeof(struct dc_softc *sc)
DC_LOCK_ASSERT(sc);
ifp = &sc->arpcom.ac_if;
ifp = sc->dc_ifp;
i = sc->dc_cdata.dc_rx_prod;
bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, BUS_DMASYNC_POSTREAD);
@ -2801,7 +2807,7 @@ dc_txeof(struct dc_softc *sc)
int idx;
u_int32_t ctl, txstat;
ifp = &sc->arpcom.ac_if;
ifp = sc->dc_ifp;
/*
* Go through our tx list and free mbufs for those
@ -2909,7 +2915,7 @@ dc_tick(void *xsc)
sc = xsc;
DC_LOCK(sc);
ifp = &sc->arpcom.ac_if;
ifp = sc->dc_ifp;
mii = device_get_softc(sc->dc_miibus);
if (sc->dc_flags & DC_REDUCED_MII_POLL) {
@ -3100,7 +3106,7 @@ dc_intr(void *arg)
return;
DC_LOCK(sc);
ifp = &sc->arpcom.ac_if;
ifp = sc->dc_ifp;
#ifdef DEVICE_POLLING
if (ifp->if_flags & IFF_POLLING)
goto done;
@ -3377,7 +3383,7 @@ static void
dc_init(void *xsc)
{
struct dc_softc *sc = xsc;
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->dc_ifp;
struct mii_data *mii;
DC_LOCK(sc);
@ -3705,7 +3711,7 @@ dc_stop(struct dc_softc *sc)
DC_LOCK(sc);
ifp = &sc->arpcom.ac_if;
ifp = sc->dc_ifp;
ifp->if_timer = 0;
ld = sc->dc_ldata;
cd = &sc->dc_cdata;
@ -3791,7 +3797,7 @@ dc_resume(device_t dev)
s = splimp();
sc = device_get_softc(dev);
ifp = &sc->arpcom.ac_if;
ifp = sc->dc_ifp;
/* reinitialize interface if necessary */
if (ifp->if_flags & IFF_UP)

View File

@ -716,7 +716,7 @@ struct dc_mii_frame {
struct dc_softc {
struct arpcom arpcom; /* interface info */
struct ifnet *dc_ifp; /* interface info */
bus_space_handle_t dc_bhandle; /* bus space handle */
bus_space_tag_t dc_btag; /* bus space tag */
bus_dma_tag_t dc_ltag; /* tag for descriptor ring */

View File

@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_media.h>
#include <net/if_types.h>
#include <net/if_dl.h>
#ifdef TULIP_USE_SOFTINTR
#include <net/netisr.h>
@ -207,8 +208,8 @@ tulip_txprobe(
/*
* Construct a LLC TEST message which will point to ourselves.
*/
bcopy(sc->tulip_enaddr, mtod(m, struct ether_header *)->ether_dhost, 6);
bcopy(sc->tulip_enaddr, mtod(m, struct ether_header *)->ether_shost, 6);
bcopy(IFP2ENADDR(sc->tulip_ifp), mtod(m, struct ether_header *)->ether_dhost, 6);
bcopy(IFP2ENADDR(sc->tulip_ifp), mtod(m, struct ether_header *)->ether_shost, 6);
mtod(m, struct ether_header *)->ether_type = htons(3);
mtod(m, unsigned char *)[14] = 0;
mtod(m, unsigned char *)[15] = 0;
@ -229,7 +230,7 @@ tulip_txprobe(
}
#ifdef BIG_PACKET
#define TULIP_SIAGEN_WATCHDOG (sc->tulip_if.if_mtu > ETHERMTU ? TULIP_WATCHDOG_RXDISABLE|TULIP_WATCHDOG_TXDISABLE : 0)
#define TULIP_SIAGEN_WATCHDOG (sc->tulip_ifp->if_mtu > ETHERMTU ? TULIP_WATCHDOG_RXDISABLE|TULIP_WATCHDOG_TXDISABLE : 0)
#else
#define TULIP_SIAGEN_WATCHDOG 0
#endif
@ -336,10 +337,10 @@ tulip_linkup(
if ((sc->tulip_flags & TULIP_LINKUP) == 0)
sc->tulip_flags |= TULIP_PRINTLINKUP;
sc->tulip_flags |= TULIP_LINKUP;
sc->tulip_if.if_flags &= ~IFF_OACTIVE;
sc->tulip_ifp->if_flags &= ~IFF_OACTIVE;
#if 0 /* XXX how does with work with ifmedia? */
if ((sc->tulip_flags & TULIP_DIDNWAY) == 0) {
if (sc->tulip_if.if_flags & IFF_FULLDUPLEX) {
if (sc->tulip_ifp->if_flags & IFF_FULLDUPLEX) {
if (TULIP_CAN_MEDIA_FD(media)
&& sc->tulip_mediums[TULIP_FD_MEDIA_OF(media)] != NULL)
media = TULIP_FD_MEDIA_OF(media);
@ -386,15 +387,16 @@ static void
tulip_media_print(
tulip_softc_t * const sc)
{
struct ifnet *ifp = sc->tulip_ifp;
if ((sc->tulip_flags & TULIP_LINKUP) == 0)
return;
if (sc->tulip_flags & TULIP_PRINTMEDIA) {
printf("%s: enabling %s port\n",
sc->tulip_xname,
if_printf(ifp, "enabling %s port\n",
tulip_mediums[sc->tulip_media]);
sc->tulip_flags &= ~(TULIP_PRINTMEDIA|TULIP_PRINTLINKUP);
} else if (sc->tulip_flags & TULIP_PRINTLINKUP) {
printf("%s: link up\n", sc->tulip_xname);
if_printf(ifp, "link up\n");
sc->tulip_flags &= ~TULIP_PRINTLINKUP;
}
}
@ -404,6 +406,7 @@ static tulip_media_t
tulip_21140_gpr_media_sense(
tulip_softc_t * const sc)
{
struct ifnet *ifp sc->tulip_ifp;
tulip_media_t maybe_media = TULIP_MEDIA_UNKNOWN;
tulip_media_t last_media = TULIP_MEDIA_UNKNOWN;
tulip_media_t media;
@ -441,8 +444,8 @@ tulip_21140_gpr_media_sense(
continue;
#if defined(TULIP_DEBUG)
printf("%s: gpr_media_sense: %s: 0x%02x & 0x%02x == 0x%02x\n",
sc->tulip_xname, tulip_mediums[media],
if_printf(ifp, "gpr_media_sense: %s: 0x%02x & 0x%02x == 0x%02x\n",
tulip_mediums[media],
TULIP_CSR_READ(sc, csr_gp) & 0xFF,
mi->mi_actmask, mi->mi_actdata);
#endif
@ -466,6 +469,7 @@ static tulip_link_status_t
tulip_media_link_monitor(
tulip_softc_t * const sc)
{
struct ifnet *ifp = sc->tulip_ifp;
const tulip_media_info_t * const mi = sc->tulip_mediums[sc->tulip_media];
tulip_link_status_t linkup = TULIP_LINK_DOWN;
@ -506,7 +510,7 @@ tulip_media_link_monitor(
if (abilities != sc->tulip_abilities) {
#if defined(TULIP_DEBUG)
loudprintf("%s(phy%d): autonegotiation changed: 0x%04x -> 0x%04x\n",
sc->tulip_xname, sc->tulip_phyaddr,
ifp->if_xname, sc->tulip_phyaddr,
sc->tulip_abilities, abilities);
#endif
if (tulip_mii_map_abilities(sc, abilities)) {
@ -548,7 +552,7 @@ tulip_media_link_monitor(
linkup = TULIP_LINK_UP;
#if defined(TULIP_DEBUG)
if (sc->tulip_probe_timeout <= 0)
printf("%s: sia status = 0x%08x\n", sc->tulip_xname,
if_printf(ifp, "sia status = 0x%08x\n",
TULIP_CSR_READ(sc, csr_sia_status));
#endif
} else if (mi->mi_type == TULIP_MEDIAINFO_SYM) {
@ -564,7 +568,7 @@ tulip_media_link_monitor(
return TULIP_LINK_UP;
sc->tulip_flags &= ~TULIP_LINKUP;
printf("%s: link down: cable problem?\n", sc->tulip_xname);
if_printf(ifp, "link down: cable problem?\n");
}
#if defined(TULIP_DEBUG)
sc->tulip_dbg.dbg_link_downed++;
@ -577,6 +581,8 @@ tulip_media_poll(
tulip_softc_t * const sc,
tulip_mediapoll_event_t event)
{
struct ifnet *ifp = sc->tulip_ifp;
#if defined(TULIP_DEBUG)
sc->tulip_dbg.dbg_events[event]++;
#endif
@ -613,7 +619,7 @@ tulip_media_poll(
sc->tulip_dbg.dbg_link_failures++;
#endif
sc->tulip_media = TULIP_MEDIA_UNKNOWN;
if (sc->tulip_if.if_flags & IFF_UP)
if (sc->tulip_ifp->if_flags & IFF_UP)
tulip_reset(sc); /* restart probe */
}
return;
@ -624,7 +630,7 @@ tulip_media_poll(
}
if (event == TULIP_MEDIAPOLL_START) {
sc->tulip_if.if_flags |= IFF_OACTIVE;
sc->tulip_ifp->if_flags |= IFF_OACTIVE;
if (sc->tulip_probe_state != TULIP_PROBE_INACTIVE)
return;
sc->tulip_probe_mediamask = 0;
@ -695,8 +701,8 @@ tulip_media_poll(
if (sc->tulip_probe_timeout > 0) {
tulip_media_t new_probe_media = tulip_21140_gpr_media_sense(sc);
#if defined(TULIP_DEBUG)
printf("%s: media_poll: gpr sensing = %s\n",
sc->tulip_xname, tulip_mediums[new_probe_media]);
if_printf(ifp, "media_poll: gpr sensing = %s\n",
tulip_mediums[new_probe_media]);
#endif
if (new_probe_media != TULIP_MEDIA_UNKNOWN) {
if (new_probe_media == sc->tulip_probe_media) {
@ -782,8 +788,7 @@ tulip_media_poll(
if (/* event == TULIP_MEDIAPOLL_TXPROBE_FAILED || */ sc->tulip_probe_timeout <= 0) {
#if defined(TULIP_DEBUG)
if (sc->tulip_probe_media == TULIP_MEDIA_UNKNOWN) {
printf("%s: poll media unknown!\n",
sc->tulip_xname);
if_printf(ifp, "poll media unknown!\n");
sc->tulip_probe_media = TULIP_MEDIA_MAX;
}
#endif
@ -795,10 +800,9 @@ tulip_media_poll(
sc->tulip_probe_media -= 1;
if (sc->tulip_probe_media == TULIP_MEDIA_UNKNOWN) {
if (++sc->tulip_probe_passes == 3) {
printf("%s: autosense failed: cable problem?\n",
sc->tulip_xname);
if ((sc->tulip_if.if_flags & IFF_UP) == 0) {
sc->tulip_if.if_flags &= ~IFF_RUNNING;
if_printf(ifp, "autosense failed: cable problem?\n");
if ((sc->tulip_ifp->if_flags & IFF_UP) == 0) {
sc->tulip_ifp->if_flags &= ~IFF_RUNNING;
sc->tulip_probe_state = TULIP_PROBE_INACTIVE;
return;
}
@ -812,7 +816,7 @@ tulip_media_poll(
|| TULIP_IS_MEDIA_FD(sc->tulip_probe_media));
#if defined(TULIP_DEBUG)
printf("%s: %s: probing %s\n", sc->tulip_xname,
if_printf(ifp, "%s: probing %s\n",
event == TULIP_MEDIAPOLL_TXPROBE_FAILED ? "txprobe failed" : "timeout",
tulip_mediums[sc->tulip_probe_media]);
#endif
@ -892,7 +896,7 @@ tulip_21040_mediainfo_init(
{
sc->tulip_cmdmode |= TULIP_CMD_CAPTREFFCT|TULIP_CMD_THRSHLD160
|TULIP_CMD_BACKOFFCTR;
sc->tulip_if.if_baudrate = 10000000;
sc->tulip_ifp->if_baudrate = 10000000;
if (media == TULIP_MEDIA_10BASET || media == TULIP_MEDIA_UNKNOWN) {
TULIP_MEDIAINFO_SIA_INIT(sc, &sc->tulip_mediainfo[0], 21040, 10BASET);
@ -1005,7 +1009,7 @@ static void
tulip_21041_media_probe(
tulip_softc_t * const sc)
{
sc->tulip_if.if_baudrate = 10000000;
sc->tulip_ifp->if_baudrate = 10000000;
sc->tulip_cmdmode |= TULIP_CMD_CAPTREFFCT|TULIP_CMD_ENHCAPTEFFCT
|TULIP_CMD_THRSHLD160|TULIP_CMD_BACKOFFCTR;
sc->tulip_intrmask |= TULIP_STS_LINKPASS|TULIP_STS_LINKFAIL;
@ -1037,7 +1041,7 @@ tulip_21041_media_poll(
* restart the probe (and reset the tulip to a known state).
*/
if (event == TULIP_MEDIAPOLL_START) {
sc->tulip_if.if_flags |= IFF_OACTIVE;
sc->tulip_ifp->if_flags |= IFF_OACTIVE;
sc->tulip_cmdmode &= ~(TULIP_CMD_FULLDUPLEX|TULIP_CMD_RXRUN);
#ifdef notyet
if (sc->tulip_revinfo >= 0x20) {
@ -1141,10 +1145,10 @@ tulip_21041_media_poll(
sc->tulip_flags &= ~TULIP_WANTRXACT;
sc->tulip_probe_timeout = TULIP_21041_PROBE_AUIBNC_TIMEOUT;
} else {
printf("%s: autosense failed: cable problem?\n",
sc->tulip_xname);
if ((sc->tulip_if.if_flags & IFF_UP) == 0) {
sc->tulip_if.if_flags &= ~IFF_RUNNING;
if_printf(sc->tulip_ifp,
"autosense failed: cable problem?\n");
if ((sc->tulip_ifp->if_flags & IFF_UP) == 0) {
sc->tulip_ifp->if_flags &= ~IFF_RUNNING;
sc->tulip_probe_state = TULIP_PROBE_INACTIVE;
return;
}
@ -1335,6 +1339,8 @@ tulip_mii_autonegotiate(
tulip_softc_t * const sc,
const unsigned phyaddr)
{
struct ifnet *ifp = sc->tulip_ifp;
switch (sc->tulip_probe_state) {
case TULIP_PROBE_MEDIATEST:
case TULIP_PROBE_INACTIVE: {
@ -1354,17 +1360,17 @@ tulip_mii_autonegotiate(
return;
}
printf("%s(phy%d): error: reset of PHY never completed!\n",
sc->tulip_xname, phyaddr);
ifp->if_xname, phyaddr);
sc->tulip_flags &= ~TULIP_TXPROBE_ACTIVE;
sc->tulip_probe_state = TULIP_PROBE_FAILED;
sc->tulip_if.if_flags &= ~(IFF_UP|IFF_RUNNING);
sc->tulip_ifp->if_flags &= ~(IFF_UP|IFF_RUNNING);
return;
}
status = tulip_mii_readreg(sc, phyaddr, PHYREG_STATUS);
if ((status & PHYSTS_CAN_AUTONEG) == 0) {
#if defined(TULIP_DEBUG)
loudprintf("%s(phy%d): autonegotiation disabled\n",
sc->tulip_xname, phyaddr);
ifp->if_xname, phyaddr);
#endif
sc->tulip_flags &= ~TULIP_DIDNWAY;
sc->tulip_probe_state = TULIP_PROBE_MEDIATEST;
@ -1377,10 +1383,10 @@ tulip_mii_autonegotiate(
#if defined(TULIP_DEBUG)
if ((data & PHYCTL_AUTONEG_ENABLE) == 0)
loudprintf("%s(phy%d): oops: enable autonegotiation failed: 0x%04x\n",
sc->tulip_xname, phyaddr, data);
ifp->if_xname, phyaddr, data);
else
loudprintf("%s(phy%d): autonegotiation restarted: 0x%04x\n",
sc->tulip_xname, phyaddr, data);
ifp->if_xname, phyaddr, data);
sc->tulip_dbg.dbg_nway_starts++;
#endif
sc->tulip_probe_state = TULIP_PROBE_PHYAUTONEG;
@ -1397,7 +1403,7 @@ tulip_mii_autonegotiate(
}
#if defined(TULIP_DEBUG)
loudprintf("%s(phy%d): autonegotiation timeout: sts=0x%04x, ctl=0x%04x\n",
sc->tulip_xname, phyaddr, status,
ifp->if_xname, phyaddr, status,
tulip_mii_readreg(sc, phyaddr, PHYREG_CONTROL));
#endif
sc->tulip_flags &= ~TULIP_DIDNWAY;
@ -1407,7 +1413,7 @@ tulip_mii_autonegotiate(
data = tulip_mii_readreg(sc, phyaddr, PHYREG_AUTONEG_ABILITIES);
#if defined(TULIP_DEBUG)
loudprintf("%s(phy%d): autonegotiation complete: 0x%04x\n",
sc->tulip_xname, phyaddr, data);
ifp->if_xname, phyaddr, data);
#endif
data = (data << 6) & status;
if (!tulip_mii_map_abilities(sc, data))
@ -1423,7 +1429,7 @@ tulip_mii_autonegotiate(
}
#if defined(TULIP_DEBUG)
loudprintf("%s(phy%d): autonegotiation failure: state = %d\n",
sc->tulip_xname, phyaddr, sc->tulip_probe_state);
ifp->if_xname, phyaddr, sc->tulip_probe_state);
sc->tulip_dbg.dbg_nway_failures++;
#endif
}
@ -1458,8 +1464,7 @@ tulip_2114x_media_preset(
}
#if defined(TULIP_DEBUG)
} else {
printf("%s: preset: bad media %d!\n",
sc->tulip_xname, media);
if_printf(sc->tulip_ifp, "preset: bad media %d!\n", media);
}
#endif
}
@ -1469,13 +1474,13 @@ tulip_2114x_media_preset(
case TULIP_MEDIA_10BASET: {
sc->tulip_cmdmode &= ~TULIP_CMD_FULLDUPLEX;
sc->tulip_cmdmode |= TULIP_CMD_TXTHRSHLDCTL;
sc->tulip_if.if_baudrate = 10000000;
sc->tulip_ifp->if_baudrate = 10000000;
sc->tulip_flags |= TULIP_SQETEST;
break;
}
case TULIP_MEDIA_10BASET_FD: {
sc->tulip_cmdmode |= TULIP_CMD_FULLDUPLEX|TULIP_CMD_TXTHRSHLDCTL;
sc->tulip_if.if_baudrate = 10000000;
sc->tulip_ifp->if_baudrate = 10000000;
break;
}
case TULIP_MEDIA_100BASEFX:
@ -1483,14 +1488,14 @@ tulip_2114x_media_preset(
case TULIP_MEDIA_100BASETX: {
sc->tulip_cmdmode &= ~(TULIP_CMD_FULLDUPLEX|TULIP_CMD_TXTHRSHLDCTL);
sc->tulip_cmdmode |= TULIP_CMD_PORTSELECT;
sc->tulip_if.if_baudrate = 100000000;
sc->tulip_ifp->if_baudrate = 100000000;
break;
}
case TULIP_MEDIA_100BASEFX_FD:
case TULIP_MEDIA_100BASETX_FD: {
sc->tulip_cmdmode |= TULIP_CMD_FULLDUPLEX|TULIP_CMD_PORTSELECT;
sc->tulip_cmdmode &= ~TULIP_CMD_TXTHRSHLDCTL;
sc->tulip_if.if_baudrate = 100000000;
sc->tulip_ifp->if_baudrate = 100000000;
break;
}
default: {
@ -1514,8 +1519,7 @@ tulip_null_media_poll(
sc->tulip_dbg.dbg_events[event]++;
#endif
#if defined(DIAGNOSTIC)
printf("%s: botch(media_poll) at line %d\n",
sc->tulip_xname, __LINE__);
if_printf(sc->tulip_ifp, "botch(media_poll) at line %d\n", __LINE__);
#endif
}
@ -2261,7 +2265,7 @@ tulip_identify_asante_nic(
mi->mi_phyaddr = tulip_mii_get_phyaddr(sc, 0);
}
if (mi->mi_phyaddr == TULIP_MII_NOPHY) {
printf("%s: can't find phy 0\n", sc->tulip_xname);
if_printf(sc->tulip_ifp, "can't find phy 0\n");
return;
}
@ -2312,7 +2316,7 @@ tulip_identify_compex_nic(
root_sc->tulip_slaves = sc;
} else if(sc->tulip_features & TULIP_HAVE_SLAVEDINTR) {
printf("\nCannot find master device for %s interrupts",
sc->tulip_xname);
sc->tulip_ifp->if_xname);
}
} else {
strcat(sc->tulip_boardid, "unknown ");
@ -2514,8 +2518,8 @@ tulip_srom_decode(
}
if (mi->mi_phyaddr == TULIP_MII_NOPHY) {
#if defined(TULIP_DEBUG)
printf("%s: can't find phy %d\n",
sc->tulip_xname, phyno);
if_printf(sc->tulip_ifp, "can't find phy %d\n",
phyno);
#endif
break;
}
@ -2615,8 +2619,8 @@ tulip_srom_decode(
}
if (mi->mi_phyaddr == TULIP_MII_NOPHY) {
#if defined(TULIP_DEBUG)
printf("%s: can't find phy %d\n",
sc->tulip_xname, phyno);
if_printf(sc->tulip_ifp, "can't find phy %d\n",
phyno);
#endif
break;
}
@ -2994,18 +2998,18 @@ tulip_addr_filter(
sc->tulip_cmdmode &= ~TULIP_CMD_RXRUN;
sc->tulip_intrmask &= ~TULIP_STS_RXSTOPPED;
#if defined(IFF_ALLMULTI)
if (sc->tulip_if.if_flags & IFF_ALLMULTI)
if (sc->tulip_ifp->if_flags & IFF_ALLMULTI)
sc->tulip_flags |= TULIP_ALLMULTI ;
#endif
multicnt = 0;
TAILQ_FOREACH(ifma, &sc->tulip_if.if_multiaddrs, ifma_link) {
TAILQ_FOREACH(ifma, &sc->tulip_ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family == AF_LINK)
multicnt++;
}
sc->tulip_if.if_start = tulip_ifstart; /* so the setup packet gets queued */
sc->tulip_ifp->if_start = tulip_ifstart; /* so the setup packet gets queued */
if (multicnt > 14) {
u_int32_t *sp = sc->tulip_setupdata;
unsigned hash;
@ -3027,7 +3031,7 @@ tulip_addr_filter(
*/
bzero(sc->tulip_setupdata, sizeof(sc->tulip_setupdata));
TAILQ_FOREACH(ifma, &sc->tulip_if.if_multiaddrs, ifma_link) {
TAILQ_FOREACH(ifma, &sc->tulip_ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
@ -3044,14 +3048,14 @@ tulip_addr_filter(
* receiving every multicast.
*/
if ((sc->tulip_flags & TULIP_ALLMULTI) == 0) {
hash = tulip_mchash(sc->tulip_if.if_broadcastaddr);
hash = tulip_mchash(sc->tulip_ifp->if_broadcastaddr);
#if BYTE_ORDER == BIG_ENDIAN
sp[hash >> 4] |= bswap32(1 << (hash & 0xF));
#else
sp[hash >> 4] |= 1 << (hash & 0xF);
#endif
if (sc->tulip_flags & TULIP_WANTHASHONLY) {
hash = tulip_mchash(sc->tulip_enaddr);
hash = tulip_mchash(IFP2ENADDR(sc->tulip_ifp));
#if BYTE_ORDER == BIG_ENDIAN
sp[hash >> 4] |= bswap32(1 << (hash & 0xF));
#else
@ -3059,13 +3063,13 @@ tulip_addr_filter(
#endif
} else {
#if BYTE_ORDER == BIG_ENDIAN
sp[39] = ((u_int16_t *) sc->tulip_enaddr)[0] << 16;
sp[40] = ((u_int16_t *) sc->tulip_enaddr)[1] << 16;
sp[41] = ((u_int16_t *) sc->tulip_enaddr)[2] << 16;
sp[39] = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[0] << 16;
sp[40] = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[1] << 16;
sp[41] = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[2] << 16;
#else
sp[39] = ((u_int16_t *) sc->tulip_enaddr)[0];
sp[40] = ((u_int16_t *) sc->tulip_enaddr)[1];
sp[41] = ((u_int16_t *) sc->tulip_enaddr)[2];
sp[39] = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[0];
sp[40] = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[1];
sp[41] = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[2];
#endif
}
}
@ -3077,7 +3081,7 @@ tulip_addr_filter(
/*
* Else can get perfect filtering for 16 addresses.
*/
TAILQ_FOREACH(ifma, &sc->tulip_if.if_multiaddrs, ifma_link) {
TAILQ_FOREACH(ifma, &sc->tulip_ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
addrp = LLADDR((struct sockaddr_dl *)ifma->ifma_addr);
@ -3111,19 +3115,19 @@ tulip_addr_filter(
*/
for (; idx < 16; idx++) {
#if BYTE_ORDER == BIG_ENDIAN
*sp++ = ((u_int16_t *) sc->tulip_enaddr)[0] << 16;
*sp++ = ((u_int16_t *) sc->tulip_enaddr)[1] << 16;
*sp++ = ((u_int16_t *) sc->tulip_enaddr)[2] << 16;
*sp++ = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[0] << 16;
*sp++ = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[1] << 16;
*sp++ = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[2] << 16;
#else
*sp++ = ((u_int16_t *) sc->tulip_enaddr)[0];
*sp++ = ((u_int16_t *) sc->tulip_enaddr)[1];
*sp++ = ((u_int16_t *) sc->tulip_enaddr)[2];
*sp++ = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[0];
*sp++ = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[1];
*sp++ = ((u_int16_t *) IFP2ENADDR(sc->tulip_ifp))[2];
#endif
}
}
#if defined(IFF_ALLMULTI)
if (sc->tulip_flags & TULIP_ALLMULTI)
sc->tulip_if.if_flags |= IFF_ALLMULTI;
sc->tulip_ifp->if_flags |= IFF_ALLMULTI;
#endif
}
@ -3154,8 +3158,8 @@ tulip_reset(
if (!inreset) {
sc->tulip_flags |= TULIP_INRESET;
sc->tulip_flags &= ~(TULIP_NEEDRESET|TULIP_RXBUFSLOW);
sc->tulip_if.if_flags &= ~IFF_OACTIVE;
sc->tulip_if.if_start = tulip_ifstart;
sc->tulip_ifp->if_flags &= ~IFF_OACTIVE;
sc->tulip_ifp->if_start = tulip_ifstart;
}
#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NOTX)
@ -3259,8 +3263,8 @@ tulip_reset(
(*sc->tulip_boardsw->bd_media_select)(sc);
#if defined(TULIP_DEBUG)
if ((sc->tulip_flags & TULIP_NEEDRESET) == TULIP_NEEDRESET)
printf("%s: tulip_reset: additional reset needed?!?\n",
sc->tulip_xname);
if_printf(sc->tulip_ifp,
"tulip_reset: additional reset needed?!?\n");
#endif
if (bootverbose)
tulip_media_print(sc);
@ -3284,13 +3288,13 @@ static void
tulip_init(
tulip_softc_t * const sc)
{
if (sc->tulip_if.if_flags & IFF_UP) {
if ((sc->tulip_if.if_flags & IFF_RUNNING) == 0) {
if (sc->tulip_ifp->if_flags & IFF_UP) {
if ((sc->tulip_ifp->if_flags & IFF_RUNNING) == 0) {
/* initialize the media */
tulip_reset(sc);
}
sc->tulip_if.if_flags |= IFF_RUNNING;
if (sc->tulip_if.if_flags & IFF_PROMISC) {
sc->tulip_ifp->if_flags |= IFF_RUNNING;
if (sc->tulip_ifp->if_flags & IFF_PROMISC) {
sc->tulip_flags |= TULIP_PROMISC;
sc->tulip_cmdmode |= TULIP_CMD_PROMISCUOUS;
sc->tulip_intrmask |= TULIP_STS_TXINTR;
@ -3309,7 +3313,7 @@ tulip_init(
sc->tulip_cmdmode |= TULIP_CMD_RXRUN;
sc->tulip_intrmask |= TULIP_STS_RXSTOPPED;
} else {
sc->tulip_if.if_flags |= IFF_OACTIVE;
sc->tulip_ifp->if_flags |= IFF_OACTIVE;
sc->tulip_cmdmode &= ~TULIP_CMD_RXRUN;
sc->tulip_intrmask &= ~TULIP_STS_RXSTOPPED;
}
@ -3318,7 +3322,7 @@ tulip_init(
if ((sc->tulip_flags & (TULIP_WANTSETUP|TULIP_TXPROBE_ACTIVE)) == TULIP_WANTSETUP)
tulip_txput_setup(sc);
} else {
sc->tulip_if.if_flags &= ~IFF_RUNNING;
sc->tulip_ifp->if_flags &= ~IFF_RUNNING;
tulip_reset(sc);
}
}
@ -3329,7 +3333,7 @@ tulip_rx_intr(
{
TULIP_PERFSTART(rxintr)
tulip_ringinfo_t * const ri = &sc->tulip_rxinfo;
struct ifnet * const ifp = &sc->tulip_if;
struct ifnet * const ifp = sc->tulip_ifp;
int fillok = 1;
#if defined(TULIP_DEBUG)
int cnt = 0;
@ -3431,7 +3435,7 @@ tulip_rx_intr(
if ((sc->tulip_flags & TULIP_RXIGNORE) == 0
&& ((eop->d_status & TULIP_DSTS_ERRSUM) == 0
#ifdef BIG_PACKET
|| (total_len <= sc->tulip_if.if_mtu + sizeof(struct ether_header) &&
|| (total_len <= sc->tulip_ifp->if_mtu + sizeof(struct ether_header) &&
(eop->d_status & (TULIP_DSTS_RxBADLENGTH|TULIP_DSTS_RxRUNT|
TULIP_DSTS_RxCOLLSEEN|TULIP_DSTS_RxBADCRC|
TULIP_DSTS_RxOVERFLOW)) == 0)
@ -3451,7 +3455,7 @@ tulip_rx_intr(
#endif /* TULIP_BUS_DMA */
#ifndef __FreeBSD__
if (sc->tulip_if.if_bpf != NULL) {
if (sc->tulip_ifp->if_bpf != NULL) {
if (me == ms)
bpf_tap(&sc->tulip_if, mtod(ms, caddr_t), total_len);
else
@ -3489,8 +3493,7 @@ tulip_rx_intr(
}
#if defined(TULIP_VERBOSE)
if (error != NULL && (sc->tulip_flags & TULIP_NOMESSAGES) == 0) {
printf("%s: receive: %6D: %s\n",
sc->tulip_xname,
if_printf(sc->tulip_ifp, "receive: %6D: %s\n",
mtod(ms, u_char *) + 6, ":",
error);
sc->tulip_flags |= TULIP_NOMESSAGES;
@ -3601,8 +3604,8 @@ tulip_rx_intr(
error = bus_dmamap_load(sc->tulip_dmatag, map, mtod(ms, void *),
TULIP_RX_BUFLEN, NULL, BUS_DMA_NOWAIT);
if (error) {
printf("%s: unable to load rx map, "
"error = %d\n", sc->tulip_xname, error);
if_printf(sc->tulip_ifp,
"unable to load rx map, error = %d\n", error);
panic("tulip_rx_intr"); /* XXX */
}
nextout->d_addr1 = map->dm_segs[0].ds_addr;
@ -3693,8 +3696,8 @@ tulip_tx_intr(
m_freem(m);
#if defined(TULIP_DEBUG)
} else {
printf("%s: tx_intr: failed to dequeue mbuf?!?\n",
sc->tulip_xname);
if_printf(sc->tulip_ifp,
"tx_intr: failed to dequeue mbuf?!?\n");
#endif
}
if (sc->tulip_flags & TULIP_TXPROBE_ACTIVE) {
@ -3716,7 +3719,7 @@ tulip_tx_intr(
} else {
xmits++;
if (d_status & TULIP_DSTS_ERRSUM) {
sc->tulip_if.if_oerrors++;
sc->tulip_ifp->if_oerrors++;
if (d_status & TULIP_DSTS_TxEXCCOLL)
sc->tulip_dot3stats.dot3StatsExcessiveCollisions++;
if (d_status & TULIP_DSTS_TxLATECOLL)
@ -3733,7 +3736,7 @@ tulip_tx_intr(
u_int32_t collisions =
(d_status & TULIP_DSTS_TxCOLLMASK)
>> TULIP_DSTS_V_TxCOLLCNT;
sc->tulip_if.if_collisions += collisions;
sc->tulip_ifp->if_collisions += collisions;
if (collisions == 1)
sc->tulip_dot3stats.dot3StatsSingleCollisionFrames++;
else if (collisions > 1)
@ -3757,7 +3760,7 @@ tulip_tx_intr(
ri->ri_nextin = ri->ri_first;
if ((sc->tulip_flags & TULIP_TXPROBE_ACTIVE) == 0)
sc->tulip_if.if_flags &= ~IFF_OACTIVE;
sc->tulip_ifp->if_flags &= ~IFF_OACTIVE;
}
/*
* If nothing left to transmit, disable the timer.
@ -3767,7 +3770,7 @@ tulip_tx_intr(
sc->tulip_txtimer = 0;
else if (xmits > 0)
sc->tulip_txtimer = TULIP_TXTIMER;
sc->tulip_if.if_opackets += xmits;
sc->tulip_ifp->if_opackets += xmits;
TULIP_PERFEND(txintr);
return descs;
}
@ -3783,7 +3786,7 @@ tulip_print_abnormal_interrupt(
const char thrsh[] = "72|128\0\0\0" "96|256\0\0\0" "128|512\0\0" "160|1024";
csr &= (1 << (sizeof(tulip_status_bits)/sizeof(tulip_status_bits[0]))) - 1;
printf("%s: abnormal interrupt:", sc->tulip_xname);
if_printf(sc->tulip_ifp, "abnormal interrupt:");
for (sep = " ", mask = 1; mask <= csr; mask <<= 1, msgp++) {
if ((csr & mask) && *msgp != NULL) {
printf("%s%s", sep, *msgp);
@ -3819,8 +3822,7 @@ tulip_intr_handler(
if (sc->tulip_flags & TULIP_NOMESSAGES) {
sc->tulip_flags |= TULIP_SYSTEMERROR;
} else {
printf("%s: system error: %s\n",
sc->tulip_xname,
if_printf(sc->tulip_ifp, "system error: %s\n",
tulip_system_errors[sc->tulip_last_system_error]);
}
sc->tulip_flags |= TULIP_NEEDRESET;
@ -3891,7 +3893,7 @@ tulip_intr_handler(
if (sc->tulip_flags & (TULIP_WANTTXSTART|TULIP_TXPROBE_ACTIVE|TULIP_DOINGSETUP|TULIP_PROMISC)) {
tulip_tx_intr(sc);
if ((sc->tulip_flags & TULIP_TXPROBE_ACTIVE) == 0)
tulip_ifstart(&sc->tulip_if);
tulip_ifstart(sc->tulip_ifp);
}
}
if (sc->tulip_flags & TULIP_NEEDRESET) {
@ -4116,8 +4118,7 @@ tulip_txput(
#if defined(TULIP_DEBUG)
if ((sc->tulip_cmdmode & TULIP_CMD_TXRUN) == 0) {
printf("%s: txput%s: tx not running\n",
sc->tulip_xname,
if_printf(sc->tulip_ifp, "txput%s: tx not running\n",
(sc->tulip_flags & TULIP_TXPROBE_ACTIVE) ? "(probe)" : "");
sc->tulip_flags |= TULIP_WANTTXSTART;
sc->tulip_dbg.dbg_txput_finishes[0]++;
@ -4188,8 +4189,8 @@ tulip_txput(
error = bus_dmamap_load_mbuf(sc->tulip_dmatag, map, m, BUS_DMA_NOWAIT);
}
if (error != 0) {
printf("%s: unable to load tx map, "
"error = %d\n", sc->tulip_xname, error);
if_printf(sc->tulip_ifp,
"unable to load tx map, error = %d\n", error);
#if defined(TULIP_DEBUG)
sc->tulip_dbg.dbg_txput_finishes[3]++;
#endif
@ -4317,7 +4318,7 @@ tulip_txput(
/*
* bounce a copy to the bpf listener, if any.
*/
BPF_MTAP(&sc->tulip_if, m);
BPF_MTAP(sc->tulip_ifp, m);
/*
* The descriptors have been filled in. Now get ready
@ -4381,8 +4382,8 @@ tulip_txput(
if (sc->tulip_flags & TULIP_TXPROBE_ACTIVE) {
TULIP_CSR_WRITE(sc, csr_txpoll, 1);
sc->tulip_if.if_flags |= IFF_OACTIVE;
sc->tulip_if.if_start = tulip_ifstart;
sc->tulip_ifp->if_flags |= IFF_OACTIVE;
sc->tulip_ifp->if_start = tulip_ifstart;
TULIP_PERFEND(txput);
return NULL;
}
@ -4411,8 +4412,8 @@ tulip_txput(
sc->tulip_dbg.dbg_txput_finishes[6]++;
#endif
if (sc->tulip_flags & (TULIP_WANTTXSTART|TULIP_DOINGSETUP)) {
sc->tulip_if.if_flags |= IFF_OACTIVE;
sc->tulip_if.if_start = tulip_ifstart;
sc->tulip_ifp->if_flags |= IFF_OACTIVE;
sc->tulip_ifp->if_start = tulip_ifstart;
if ((sc->tulip_intrmask & TULIP_STS_TXINTR) == 0) {
sc->tulip_intrmask |= TULIP_STS_TXINTR;
TULIP_CSR_WRITE(sc, csr_intr, sc->tulip_intrmask);
@ -4441,10 +4442,9 @@ tulip_txput_setup(
#if defined(TULIP_DEBUG)
if ((sc->tulip_cmdmode & TULIP_CMD_TXRUN) == 0) {
printf("%s: txput_setup: tx not running\n",
sc->tulip_xname);
if_printf(sc->tulip_ifp, "txput_setup: tx not running\n");
sc->tulip_flags |= TULIP_WANTTXSTART;
sc->tulip_if.if_start = tulip_ifstart;
sc->tulip_ifp->if_start = tulip_ifstart;
return;
}
#endif
@ -4455,7 +4455,7 @@ tulip_txput_setup(
tulip_tx_intr(sc);
if ((sc->tulip_flags & TULIP_DOINGSETUP) || ri->ri_free == 1) {
sc->tulip_flags |= TULIP_WANTTXSTART;
sc->tulip_if.if_start = tulip_ifstart;
sc->tulip_ifp->if_start = tulip_ifstart;
return;
}
bcopy(sc->tulip_setupdata, sc->tulip_setupbuf,
@ -4620,18 +4620,18 @@ tulip_ifstart(
TULIP_PERFSTART(ifstart)
tulip_softc_t * const sc = (tulip_softc_t *)ifp->if_softc;
if (sc->tulip_if.if_flags & IFF_RUNNING) {
if (sc->tulip_ifp->if_flags & IFF_RUNNING) {
if ((sc->tulip_flags & (TULIP_WANTSETUP|TULIP_TXPROBE_ACTIVE)) == TULIP_WANTSETUP)
tulip_txput_setup(sc);
while (!IFQ_DRV_IS_EMPTY(&sc->tulip_if.if_snd)) {
while (!IFQ_DRV_IS_EMPTY(&sc->tulip_ifp->if_snd)) {
struct mbuf *m;
IFQ_DRV_DEQUEUE(&sc->tulip_if.if_snd, m);
IFQ_DRV_DEQUEUE(&sc->tulip_ifp->if_snd, m);
if(m == NULL)
break;
if ((m = tulip_txput(sc, m)) != NULL) {
IFQ_DRV_PREPEND(&sc->tulip_if.if_snd, m);
IFQ_DRV_PREPEND(&sc->tulip_ifp->if_snd, m);
break;
}
}
@ -4661,7 +4661,7 @@ tulip_ifwatchdog(
sc->tulip_dbg.dbg_last_rxintrs = sc->tulip_dbg.dbg_rxintrs;
#endif /* TULIP_DEBUG */
sc->tulip_if.if_timer = 1;
sc->tulip_ifp->if_timer = 1;
/*
* These should be rare so do a bulk test up front so we can just skip
* them if needed.
@ -4674,8 +4674,8 @@ tulip_ifwatchdog(
tulip_rx_intr(sc);
if (sc->tulip_flags & TULIP_SYSTEMERROR) {
printf("%s: %d system errors: last was %s\n",
sc->tulip_xname, sc->tulip_system_errors,
if_printf(sc->tulip_ifp, "%d system errors: last was %s\n",
sc->tulip_system_errors,
tulip_system_errors[sc->tulip_last_system_error]);
}
if (sc->tulip_statusbits) {
@ -4689,7 +4689,7 @@ tulip_ifwatchdog(
if (sc->tulip_txtimer)
tulip_tx_intr(sc);
if (sc->tulip_txtimer && --sc->tulip_txtimer == 0) {
printf("%s: transmission timeout\n", sc->tulip_xname);
if_printf(sc->tulip_ifp, "transmission timeout\n");
if (TULIP_DO_AUTOSENSE(sc)) {
sc->tulip_media = TULIP_MEDIA_UNKNOWN;
sc->tulip_probe_state = TULIP_PROBE_INACTIVE;
@ -4733,11 +4733,13 @@ static void
tulip_attach(
tulip_softc_t * const sc)
{
struct ifnet * const ifp = &sc->tulip_if;
struct ifnet *ifp;
ifp = sc->tulip_ifp = if_alloc(IFT_ETHER);
/* XXX: driver name/unit should be set some other way */
ifp->if_dname = "de";
ifp->if_dunit = sc->tulip_unit;
if_initname(ifp, "de", sc->tulip_unit);
ifp->if_softc = sc;
ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST|IFF_NEEDSGIANT;
ifp->if_ioctl = tulip_ifioctl;
ifp->if_start = tulip_ifstart;
@ -4745,8 +4747,7 @@ tulip_attach(
ifp->if_timer = 1;
ifp->if_init = tulip_ifinit;
printf("%s: %s%s pass %d.%d%s\n",
sc->tulip_xname,
if_printf(ifp, "%s%s pass %d.%d%s\n",
sc->tulip_boardid,
tulip_chipdescs[sc->tulip_chipid],
(sc->tulip_revinfo & 0xF0) >> 4,
@ -4754,8 +4755,7 @@ tulip_attach(
(sc->tulip_features & (TULIP_HAVE_ISVSROM|TULIP_HAVE_OKSROM))
== TULIP_HAVE_ISVSROM ? " (invalid EESPROM checksum)" : "");
#ifndef __FreeBSD__
printf("%s: address %6D\n",
sc->tulip_xname, sc->tulip_enaddr, ":");
if_printf(ifp, "address %6D\n", sc->tulip_enaddr, ":");
#endif
#if defined(__alpha__)
@ -4776,7 +4776,7 @@ tulip_attach(
tulip_reset(sc);
ether_ifattach(&(sc)->tulip_if, sc->tulip_enaddr);
ether_ifattach(sc->tulip_ifp, sc->tulip_enaddr);
IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
ifp->if_snd.ifq_drv_maxlen = ifqmaxlen;
IFQ_SET_READY(&ifp->if_snd);
@ -5029,8 +5029,7 @@ tulip_pci_attach(device_t dev)
unit = device_get_unit(dev);
if (unit >= TULIP_MAX_DEVICES) {
printf("de%d", unit);
printf(": not configured; limit of %d reached or exceeded\n",
device_printf(dev, "not configured; limit of %d reached or exceeded\n",
TULIP_MAX_DEVICES);
return ENXIO;
}
@ -5059,13 +5058,14 @@ tulip_pci_attach(device_t dev)
return ENXIO;
if (chipid == TULIP_21040 && revinfo < 0x20) {
printf("de%d", unit);
printf(": not configured; 21040 pass 2.0 required (%d.%d found)\n",
revinfo >> 4, revinfo & 0x0f);
device_printf(dev,
"not configured; 21040 pass 2.0 required (%d.%d found)\n",
revinfo >> 4, revinfo & 0x0f);
return ENXIO;
} else if (chipid == TULIP_21140 && revinfo < 0x11) {
printf("de%d: not configured; 21140 pass 1.1 required (%d.%d found)\n",
unit, revinfo >> 4, revinfo & 0x0f);
device_printf(dev,
"not configured; 21140 pass 1.1 required (%d.%d found)\n",
revinfo >> 4, revinfo & 0x0f);
return ENXIO;
}
@ -5117,9 +5117,7 @@ tulip_pci_attach(device_t dev)
#endif
sc->tulip_unit = unit;
snprintf(sc->tulip_xname, IFNAMSIZ, "de%d", sc->tulip_unit);
sc->tulip_revinfo = revinfo;
sc->tulip_if.if_softc = sc;
#if defined(TULIP_IOMAPPED)
rid = PCI_CBIO;
res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE);
@ -5146,7 +5144,7 @@ tulip_pci_attach(device_t dev)
sc->tulip_rxdescs = (tulip_desc_t *) malloc(sizeof(tulip_desc_t) * TULIP_RXDESCS, M_DEVBUF, M_NOWAIT);
sc->tulip_txdescs = (tulip_desc_t *) malloc(sizeof(tulip_desc_t) * TULIP_TXDESCS, M_DEVBUF, M_NOWAIT);
if (sc->tulip_rxdescs == NULL || sc->tulip_txdescs == NULL) {
printf("malloc failed\n");
device_printf(dev, "malloc failed\n");
if (sc->tulip_rxdescs)
free((caddr_t) sc->tulip_rxdescs, M_DEVBUF);
if (sc->tulip_txdescs)
@ -5167,16 +5165,14 @@ tulip_pci_attach(device_t dev)
bit longer anyways) */
if ((retval = tulip_read_macaddr(sc)) < 0) {
printf("%s", sc->tulip_xname);
printf(": can't read ENET ROM (why=%d) (", retval);
device_printf(dev, "can't read ENET ROM (why=%d) (", retval);
for (idx = 0; idx < 32; idx++)
printf("%02x", sc->tulip_rombuf[idx]);
printf("\n");
printf("%s: %s%s pass %d.%d\n",
sc->tulip_xname,
device_printf(dev, "%s%s pass %d.%d\n",
sc->tulip_boardid, tulip_chipdescs[sc->tulip_chipid],
(sc->tulip_revinfo & 0xF0) >> 4, sc->tulip_revinfo & 0x0F);
printf("%s: address unknown\n", sc->tulip_xname);
device_printf(dev, "address unknown\n");
} else {
int s;
void (*intr_rtn)(void *) = tulip_intr_normal;
@ -5192,8 +5188,7 @@ tulip_pci_attach(device_t dev)
RF_SHAREABLE | RF_ACTIVE);
if (res == 0 || bus_setup_intr(dev, res, INTR_TYPE_NET,
intr_rtn, sc, &ih)) {
printf("%s: couldn't map interrupt\n",
sc->tulip_xname);
device_printf(dev, "couldn't map interrupt\n");
free((caddr_t) sc->tulip_rxdescs, M_DEVBUF);
free((caddr_t) sc->tulip_txdescs, M_DEVBUF);
return ENXIO;

View File

@ -521,7 +521,8 @@ struct tulip_softc {
unsigned int tulip_rxmaps_free;
#endif
#endif
struct arpcom tulip_ac; /* XXX should be at start */
struct ifnet *tulip_ifp;
u_char tulip_enaddr[6];
bus_space_tag_t tulip_csrs_bst;
bus_space_handle_t tulip_csrs_bsh;
tulip_regfile_t tulip_csrs;
@ -584,9 +585,6 @@ struct tulip_softc {
tulip_desc_t *tulip_rxdescs;
tulip_desc_t *tulip_txdescs;
};
#define tulip_if tulip_ac.ac_if
#define tulip_xname tulip_if.if_xname
#define tulip_enaddr tulip_ac.ac_enaddr
#define tulip_curperfstats tulip_perfstats[TULIP_PERF_CURRENT]
#define tulip_probe_count tulip_probe.probe_count

View File

@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_dl.h>
#include <net/if_mib.h>
#include <net/if_media.h>
#include <net/if_types.h>
#ifndef ED_NO_MIIBUS
#include <dev/mii/mii.h>
@ -254,7 +255,13 @@ int
ed_attach(device_t dev)
{
struct ed_softc *sc = device_get_softc(dev);
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp;
ifp = sc->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
return (ENOSPC);
}
callout_handle_init(&sc->tick_ch);
/*
@ -304,7 +311,7 @@ ed_attach(device_t dev)
/*
* Attach the interface
*/
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
ether_ifattach(ifp, sc->enaddr);
/* device attach does transition from UNCONFIGURED to IDLE state */
if (bootverbose || 1) {
@ -341,13 +348,14 @@ int
ed_detach(device_t dev)
{
struct ed_softc *sc = device_get_softc(dev);
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->ifp;
if (sc->gone)
return (0);
ed_stop(sc);
ifp->if_flags &= ~IFF_RUNNING;
ether_ifdetach(ifp);
if_free(ifp);
sc->gone = 1;
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
ed_release_resources(dev);
@ -451,7 +459,7 @@ static void
ed_init(void *xsc)
{
struct ed_softc *sc = xsc;
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->ifp;
int i, s;
if (sc->gone)
@ -547,7 +555,7 @@ ed_init(void *xsc)
* Copy out our station address
*/
for (i = 0; i < ETHER_ADDR_LEN; ++i)
ed_nic_outb(sc, ED_P1_PAR(i), sc->arpcom.ac_enaddr[i]);
ed_nic_outb(sc, ED_P1_PAR(i), IFP2ENADDR(sc->ifp)[i]);
/*
* Set Current Page pointer to next_packet (initialized above)
@ -820,7 +828,7 @@ ed_start(struct ifnet *ifp)
static __inline void
ed_rint(struct ed_softc *sc)
{
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->ifp;
u_char boundry;
u_short len;
struct ed_ring packet_hdr;
@ -1329,7 +1337,7 @@ ed_ring_copy(struct ed_softc *sc, char *src, char *dst, u_short amount)
static void
ed_get_packet(struct ed_softc *sc, char *buf, u_short len)
{
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->ifp;
struct ether_header *eh;
struct mbuf *m;
@ -1770,7 +1778,7 @@ ed_ds_getmcaf(struct ed_softc *sc, uint32_t *mcaf)
mcaf[0] = 0;
mcaf[1] = 0;
TAILQ_FOREACH(ifma, &sc->arpcom.ac_if.if_multiaddrs, ifma_link) {
TAILQ_FOREACH(ifma, &sc->ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
index = ether_crc32_be(LLADDR((struct sockaddr_dl *)

View File

@ -198,7 +198,7 @@ ed_probe_3Com(device_t dev, int port_rid, int flags)
ed_asic_outb(sc, ED_3COM_CR, ED_3COM_CR_EALO | ED_3COM_CR_XSEL);
for (i = 0; i < ETHER_ADDR_LEN; ++i)
sc->arpcom.ac_enaddr[i] = ed_nic_inb(sc, i);
sc->enaddr[i] = ed_nic_inb(sc, i);
/*
* Unmap PROM - select NIC registers. The proper setting of the

View File

@ -774,15 +774,13 @@ ed98_probe_Novell(device_t dev, int port_rid, int flags)
switch (sc->type) {
case ED_TYPE98_NC5098:
for (n = 0; n < ETHER_ADDR_LEN; n++)
sc->arpcom.ac_enaddr[n] =
ed_asic_inb(sc, ED_NC5098_ENADDR + n);
sc->enaddr[n] = ed_asic_inb(sc, ED_NC5098_ENADDR + n);
break;
default:
ed_pio_readmem(sc, 0, romdata, sizeof(romdata));
for (n = 0; n < ETHER_ADDR_LEN; n++)
sc->arpcom.ac_enaddr[n] =
romdata[n * (sc->isa16bit + 1)];
sc->enaddr[n] = romdata[n * (sc->isa16bit + 1)];
break;
}
@ -843,15 +841,14 @@ ed_probe_SIC98(device_t dev, int port_rid, int flags)
*/
sum = sc->mem_start[6 * 2];
for (i = 0; i < ETHER_ADDR_LEN; i++)
sum ^= (sc->arpcom.ac_enaddr[i] = sc->mem_start[i * 2]);
sum ^= (sc->enaddr[i] = sc->mem_start[i * 2]);
#ifdef ED_DEBUG
device_printf(dev, "ed_probe_sic98: got address %6D\n",
sc->arpcom.ac_enaddr, ":");
sc->enaddr, ":");
#endif
if (sum != 0)
return (ENXIO);
if ((sc->arpcom.ac_enaddr[0] | sc->arpcom.ac_enaddr[1] |
sc->arpcom.ac_enaddr[2]) == 0)
if ((sc->enaddr[0] | sc->enaddr[1] | sc->enaddr[2]) == 0)
return (ENXIO);
sc->vendor = ED_VENDOR_SIC;
@ -1067,7 +1064,7 @@ ed_probe_CNET98(device_t dev, int port_rid, int flags)
/*
* Get station address from on-board ROM
*/
bcopy(sc->mem_start, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
bcopy(sc->mem_start, sc->enaddr, ETHER_ADDR_LEN);
sc->vendor = ED_VENDOR_MISC;
sc->type_str = "CNET98";
@ -1226,7 +1223,7 @@ ed_probe_CNET98EL(device_t dev, int port_rid, int flags)
/* Get station address from on-board ROM */
ed_pio_readmem(sc, 16384, romdata, sizeof(romdata));
for (i = 0; i < ETHER_ADDR_LEN; i++)
sc->arpcom.ac_enaddr[i] = romdata[i * 2];
sc->enaddr[i] = romdata[i * 2];
/* clear any pending interrupts that might have occurred above */
ed_nic_outb(sc, ED_P0_ISR, 0xff);
@ -1391,7 +1388,7 @@ ed_get_SB98(struct ed_softc *sc)
val |= (ed_asic_inb(sc, ED_SB98_EEP) & ED_SB98_EEP_SDA);
DELAY(ED_SB98_EEP_DELAY);
}
sc->arpcom.ac_enaddr[i] = val;
sc->enaddr[i] = val;
}
/* output Last ACK */

View File

@ -149,7 +149,7 @@ ed_probe_HP_pclanp(device_t dev, int port_rid, int flags)
ed_asic_outw(sc, ED_HPP_PAGING, ED_HPP_PAGE_MAC);
for (n = 0, checksum = 0; n < ETHER_ADDR_LEN; n++)
checksum += (sc->arpcom.ac_enaddr[n] =
checksum += (sc->enaddr[n] =
ed_asic_inb(sc, ED_HPP_MAC_ADDR + n));
checksum += ed_asic_inb(sc, ED_HPP_MAC_ADDR + ETHER_ADDR_LEN);
@ -365,7 +365,7 @@ ed_probe_HP_pclanp(device_t dev, int port_rid, int flags)
void
ed_hpp_set_physical_link(struct ed_softc *sc)
{
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->ifp;
int lan_page;
ed_asic_outw(sc, ED_HPP_PAGING, ED_HPP_PAGE_LAN);

View File

@ -81,7 +81,7 @@ ed_isa_probe_Novell(device_t dev)
* believing that they really are Gateway AT.
*/
if ((ED_FLAGS_GETTYPE(flags) == ED_FLAGS_GWETHER) &&
(sc->arpcom.ac_enaddr[2] == 0x86)) {
(sc->enaddr[2] == 0x86)) {
sc->type_str = "Gateway AT";
}

View File

@ -293,5 +293,5 @@ ed_Novell_read_mac(struct ed_softc *sc)
*/
ed_pio_readmem(sc, 0, romdata, 16);
for (n = 0; n < ETHER_ADDR_LEN; n++)
sc->arpcom.ac_enaddr[n] = romdata[n * (sc->isa16bit + 1)];
sc->enaddr[n] = romdata[n * (sc->isa16bit + 1)];
}

View File

@ -337,7 +337,7 @@ ed_pccard_attach(device_t dev)
ed_release_resources(dev);
return (ENXIO);
}
bcopy(enaddr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
bcopy(enaddr, sc->enaddr, ETHER_ADDR_LEN);
}
error = ed_attach(dev);
@ -392,12 +392,12 @@ ax88x90_geteprom(struct ed_softc *sc)
/* Get Data */
for (i = 0; i < 16; i++)
prom[i] = ed_asic_inb(sc, 0);
sc->arpcom.ac_enaddr[0] = prom[0] & 0xff;
sc->arpcom.ac_enaddr[1] = prom[0] >> 8;
sc->arpcom.ac_enaddr[2] = prom[1] & 0xff;
sc->arpcom.ac_enaddr[3] = prom[1] >> 8;
sc->arpcom.ac_enaddr[4] = prom[2] & 0xff;
sc->arpcom.ac_enaddr[5] = prom[2] >> 8;
sc->enaddr[0] = prom[0] & 0xff;
sc->enaddr[1] = prom[0] >> 8;
sc->enaddr[2] = prom[1] & 0xff;
sc->enaddr[3] = prom[1] >> 8;
sc->enaddr[4] = prom[2] & 0xff;
sc->enaddr[5] = prom[2] >> 8;
}
static int
@ -474,7 +474,7 @@ ed_pccard_Linksys(device_t dev)
if (sum != 0xff)
return (ENXIO); /* invalid DL10019C */
for (i = 0; i < ETHER_ADDR_LEN; i++)
sc->arpcom.ac_enaddr[i] = ed_asic_inb(sc, 0x04 + i);
sc->enaddr[i] = ed_asic_inb(sc, 0x04 + i);
ed_nic_outb(sc, ED_P0_DCR, ED_DCR_WTS | ED_DCR_FT1 | ED_DCR_LS);
id = ed_asic_inb(sc, 0xf);
sc->isa16bit = 1;

View File

@ -107,15 +107,14 @@ ed_probe_SIC(device_t dev, int port_rid, int flags)
sum = sc->mem_start[6];
for (i = 0; i < ETHER_ADDR_LEN; i++)
sum ^= (sc->arpcom.ac_enaddr[i] = sc->mem_start[i]);
sum ^= (sc->enaddr[i] = sc->mem_start[i]);
#ifdef ED_DEBUG
device_printf(dev, "ed_probe_sic: got address %6D\n",
sc->arpcom.ac_enaddr, ":");
sc->enaddr, ":");
#endif
if (sum != 0)
return (ENXIO);
if ((sc->arpcom.ac_enaddr[0] | sc->arpcom.ac_enaddr[1] |
sc->arpcom.ac_enaddr[2]) == 0)
if ((sc->enaddr[0] | sc->enaddr[1] | sc->enaddr[2]) == 0)
return (ENXIO);
sc->vendor = ED_VENDOR_SIC;

View File

@ -363,7 +363,7 @@ ed_probe_WD80x3_generic(device_t dev, int flags, uint16_t *intr_vals[])
* Get station address from on-board ROM
*/
for (i = 0; i < ETHER_ADDR_LEN; ++i)
sc->arpcom.ac_enaddr[i] = ed_asic_inb(sc, ED_WD_PROM + i);
sc->enaddr[i] = ed_asic_inb(sc, ED_WD_PROM + i);
/*
* Set upper address bits and 8/16 bit access to shared memory.

View File

@ -33,7 +33,7 @@
* ed_softc: per line info and status
*/
struct ed_softc {
struct arpcom arpcom; /* ethernet common */
struct ifnet *ifp;
char *type_str; /* pointer to type string */
u_char vendor; /* interface vendor */
@ -43,6 +43,7 @@ struct ed_softc {
u_char isa16bit; /* width of access to card 0=8 or 1=16 */
u_char mem_shared; /* NIC memory is shared with host */
u_char xmit_busy; /* transmitter is busy */
u_char enaddr[6];
int port_rid; /* resource id for port range */
int port_used; /* nonzero if ports used */

View File

@ -464,9 +464,6 @@ em_attach(device_t dev)
goto err_mac_addr;
}
bcopy(adapter->hw.mac_addr, adapter->interface_data.ac_enaddr,
ETHER_ADDR_LEN);
/* Setup OS specific network interface */
em_setup_interface(dev, adapter);
@ -525,7 +522,7 @@ static int
em_detach(device_t dev)
{
struct adapter * adapter = device_get_softc(dev);
struct ifnet *ifp = &adapter->interface_data.ac_if;
struct ifnet *ifp = adapter->ifp;
INIT_DEBUGOUT("em_detach: begin");
@ -535,9 +532,10 @@ em_detach(device_t dev)
em_phy_hw_reset(&adapter->hw);
EM_UNLOCK(adapter);
#if __FreeBSD_version < 500000
ether_ifdetach(&adapter->interface_data.ac_if, ETHER_BPF_SUPPORTED);
ether_ifdetach(adapter->ifp, ETHER_BPF_SUPPORTED);
#else
ether_ifdetach(&adapter->interface_data.ac_if);
ether_ifdetach(adapter->ifp);
if_free(ifp);
#endif
em_free_pci_resources(adapter);
bus_generic_detach(dev);
@ -804,7 +802,7 @@ em_init_locked(struct adapter * adapter)
struct ifnet *ifp;
uint32_t pba;
ifp = &adapter->interface_data.ac_if;
ifp = adapter->ifp;
INIT_DEBUGOUT("em_init: begin");
@ -843,7 +841,7 @@ em_init_locked(struct adapter * adapter)
E1000_WRITE_REG(&adapter->hw, PBA, pba);
/* Get the latest mac address, User can use a LAA */
bcopy(adapter->interface_data.ac_enaddr, adapter->hw.mac_addr,
bcopy(IFP2ENADDR(adapter->ifp), adapter->hw.mac_addr,
ETHER_ADDR_LEN);
/* Initialize the hardware */
@ -985,7 +983,7 @@ em_intr(void *arg)
EM_LOCK(adapter);
ifp = &adapter->interface_data.ac_if;
ifp = adapter->ifp;
#ifdef DEVICE_POLLING
if (ifp->if_flags & IFF_POLLING) {
@ -1193,7 +1191,7 @@ em_encap(struct adapter *adapter, struct mbuf **m_headp)
int nsegs;
struct em_buffer *tx_buffer = NULL;
struct em_tx_desc *current_tx_desc = NULL;
struct ifnet *ifp = &adapter->interface_data.ac_if;
struct ifnet *ifp = adapter->ifp;
m_head = *m_headp;
@ -1526,7 +1524,7 @@ em_set_promisc(struct adapter * adapter)
{
u_int32_t reg_rctl;
struct ifnet *ifp = &adapter->interface_data.ac_if;
struct ifnet *ifp = adapter->ifp;
reg_rctl = E1000_READ_REG(&adapter->hw, RCTL);
@ -1555,7 +1553,7 @@ static void
em_disable_promisc(struct adapter * adapter)
{
u_int32_t reg_rctl;
struct ifnet *ifp = &adapter->interface_data.ac_if;
struct ifnet *ifp = adapter->ifp;
reg_rctl = E1000_READ_REG(&adapter->hw, RCTL);
@ -1585,7 +1583,7 @@ em_set_multi(struct adapter * adapter)
u_int8_t mta[MAX_NUM_MULTICAST_ADDRESSES * ETH_LENGTH_OF_ADDRESS];
struct ifmultiaddr *ifma;
int mcnt = 0;
struct ifnet *ifp = &adapter->interface_data.ac_if;
struct ifnet *ifp = adapter->ifp;
IOCTL_DEBUGOUT("em_set_multi: begin");
@ -1647,7 +1645,7 @@ em_local_timer(void *arg)
{
struct ifnet *ifp;
struct adapter * adapter = arg;
ifp = &adapter->interface_data.ac_if;
ifp = adapter->ifp;
EM_LOCK(adapter);
@ -1668,7 +1666,7 @@ em_local_timer(void *arg)
static void
em_print_link_status(struct adapter * adapter)
{
struct ifnet *ifp = &adapter->interface_data.ac_if;
struct ifnet *ifp = adapter->ifp;
if (E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU) {
if (adapter->link_active == 0) {
@ -1711,7 +1709,7 @@ em_stop(void *arg)
{
struct ifnet *ifp;
struct adapter * adapter = arg;
ifp = &adapter->interface_data.ac_if;
ifp = adapter->ifp;
mtx_assert(&adapter->mtx, MA_OWNED);
@ -1931,7 +1929,9 @@ em_setup_interface(device_t dev, struct adapter * adapter)
struct ifnet *ifp;
INIT_DEBUGOUT("em_setup_interface: begin");
ifp = &adapter->interface_data.ac_if;
ifp = adapter->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL)
panic("%s: can not if_alloc()", device_get_nameunit(dev));
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
ifp->if_baudrate = 1000000000;
@ -1948,7 +1948,7 @@ em_setup_interface(device_t dev, struct adapter * adapter)
#if __FreeBSD_version < 500000
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
#else
ether_ifattach(ifp, adapter->interface_data.ac_enaddr);
ether_ifattach(ifp, adapter->hw.mac_addr);
#endif
ifp->if_capabilities = ifp->if_capenable = 0;
@ -2425,7 +2425,7 @@ em_clean_transmit_interrupts(struct adapter * adapter)
int i, num_avail;
struct em_buffer *tx_buffer;
struct em_tx_desc *tx_desc;
struct ifnet *ifp = &adapter->interface_data.ac_if;
struct ifnet *ifp = adapter->ifp;
mtx_assert(&adapter->mtx, MA_OWNED);
@ -2497,7 +2497,7 @@ em_get_buf(int i, struct adapter *adapter,
bus_addr_t paddr;
int error;
ifp = &adapter->interface_data.ac_if;
ifp = adapter->ifp;
if (mp == NULL) {
mp = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
@ -2648,7 +2648,7 @@ em_initialize_receive_unit(struct adapter * adapter)
u_int64_t bus_addr;
INIT_DEBUGOUT("em_initialize_receive_unit: begin");
ifp = &adapter->interface_data.ac_if;
ifp = adapter->ifp;
/* Make sure receives are disabled while setting up the descriptor ring */
E1000_WRITE_REG(&adapter->hw, RCTL, 0);
@ -2785,7 +2785,7 @@ em_process_receive_interrupts(struct adapter * adapter, int count)
mtx_assert(&adapter->mtx, MA_OWNED);
ifp = &adapter->interface_data.ac_if;
ifp = adapter->ifp;
i = adapter->next_rx_desc_to_check;
current_desc = &adapter->rx_desc_base[i];
bus_dmamap_sync(adapter->rxdma.dma_tag, adapter->rxdma.dma_map,
@ -3237,7 +3237,7 @@ em_update_stats_counters(struct adapter *adapter)
adapter->stats.tsctfc +=
E1000_READ_REG(&adapter->hw, TSCTFC);
}
ifp = &adapter->interface_data.ac_if;
ifp = adapter->ifp;
/* Fill out the OS statistics structure */
ifp->if_ibytes = adapter->stats.gorcl;

View File

@ -322,7 +322,7 @@ typedef struct _DESCRIPTOR_PAIR
/* Our adapter structure */
struct adapter {
struct arpcom interface_data;
struct ifnet *ifp;
struct adapter *next;
struct adapter *prev;
struct em_hw hw;

View File

@ -65,6 +65,7 @@ __FBSDID("$FreeBSD$");
#include <net/if.h>
#include <net/if_atm.h>
#include <net/if_media.h>
#include <net/if_types.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
@ -149,7 +150,7 @@ adp_busreset(void *v)
dummy = bus_space_read_4(sc->en_memt, sc->en_base, ADP_PCIREG);
if ((dummy & (ADP_PCIREG_SWAP_WORD | ADP_PCIREG_SWAP_DMA)) !=
ADP_PCIREG_SWAP_DMA)
if_printf(&sc->ifatm.ifnet, "adp_busreset: Adaptec ATM did "
if_printf(sc->ifp, "adp_busreset: Adaptec ATM did "
"NOT reset!\n");
}
@ -197,8 +198,11 @@ en_pci_attach(device_t dev)
sc = device_get_softc(dev);
scp = (struct en_pci_softc *)sc;
sc->ifp = if_alloc(IFT_ATM);
if (sc->ifp == NULL)
return (ENOSPC);
if_initname(&(sc->ifatm.ifnet), device_get_name(dev),
if_initname(sc->ifp, device_get_name(dev),
device_get_unit(dev));
/*
@ -273,7 +277,8 @@ en_pci_attach(device_t dev)
en_intr, sc, &scp->ih);
if (error) {
en_reset(sc);
atm_ifdetach(&sc->ifatm.ifnet);
atm_ifdetach(sc->ifp);
if_free(sc->ifp);
device_printf(dev, "could not setup irq\n");
bus_release_resource(dev, SYS_RES_IRQ, 0, scp->irq);
bus_release_resource(dev, SYS_RES_MEMORY, PCI_CBMA, scp->res);
@ -299,16 +304,17 @@ en_pci_detach(device_t dev)
/*
* Stop DMA and drop transmit queue.
*/
if ((sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
if_printf(&sc->ifatm.ifnet, "still running\n");
sc->ifatm.ifnet.if_flags &= ~IFF_RUNNING;
if ((sc->ifp->if_flags & IFF_RUNNING)) {
if_printf(sc->ifp, "still running\n");
sc->ifp->if_flags &= ~IFF_RUNNING;
}
/*
* Close down routes etc.
*/
en_reset(sc);
atm_ifdetach(&sc->ifatm.ifnet);
atm_ifdetach(sc->ifp);
if_free(sc->ifp);
/*
* Deallocate resources.
@ -347,8 +353,8 @@ adp_get_macaddr(struct en_pci_softc *scp)
struct en_softc * sc = (struct en_softc *)scp;
int lcv;
for (lcv = 0; lcv < sizeof(sc->ifatm.mib.esi); lcv++)
sc->ifatm.mib.esi[lcv] = bus_space_read_1(sc->en_memt,
for (lcv = 0; lcv < sizeof(IFP2IFATM(sc->ifp)->mib.esi); lcv++)
IFP2IFATM(sc->ifp)->mib.esi[lcv] = bus_space_read_1(sc->en_memt,
sc->en_base, MID_ADPMACOFF + lcv);
}
@ -447,13 +453,13 @@ eni_get_macaddr(device_t dev, struct en_pci_softc *scp)
data = EN_PROM_MAGIC | EN_PROM_DATA | EN_PROM_CLK;
pci_write_config(dev, EN_TONGA, data, 4);
for (i = 0; i < sizeof(sc->ifatm.mib.esi); i ++)
sc->ifatm.mib.esi[i] = eni_get_byte(dev, &data, i + EN_ESI);
for (i = 0; i < sizeof(IFP2IFATM(sc->ifp)->mib.esi); i ++)
IFP2IFATM(sc->ifp)->mib.esi[i] = eni_get_byte(dev, &data, i + EN_ESI);
sc->ifatm.mib.serial = 0;
IFP2IFATM(sc->ifp)->mib.serial = 0;
for (i = 0; i < 4; i++) {
sc->ifatm.mib.serial <<= 8;
sc->ifatm.mib.serial |= eni_get_byte(dev, &data, i + EN_SERIAL);
IFP2IFATM(sc->ifp)->mib.serial <<= 8;
IFP2IFATM(sc->ifp)->mib.serial |= eni_get_byte(dev, &data, i + EN_SERIAL);
}
/* stop operation */
data &= ~EN_PROM_DATA;

View File

@ -90,7 +90,7 @@ __FBSDID("$FreeBSD$");
*/
#define DBG(SC, FL, PRINT) do { \
if ((SC)->debug & DBG_##FL) { \
if_printf(&(SC)->ifatm.ifnet, "%s: "#FL": ", __func__); \
if_printf((SC)->ifp, "%s: "#FL": ", __func__); \
printf PRINT; \
printf("\n"); \
} \
@ -395,7 +395,7 @@ en_dump_packet(struct en_softc *sc, struct mbuf *m)
int len;
u_char *ptr;
if_printf(&sc->ifatm.ifnet, "packet len=%d", plen);
if_printf(sc->ifp, "packet len=%d", plen);
while (m != NULL) {
totlen += m->m_len;
ptr = mtod(m, u_char *);
@ -445,7 +445,7 @@ en_map_ctor(void *mem, int size, void *arg, int flags)
err = bus_dmamap_create(sc->txtag, 0, &map->map);
if (err != 0) {
if_printf(&sc->ifatm.ifnet, "cannot create DMA map %d\n", err);
if_printf(sc->ifp, "cannot create DMA map %d\n", err);
return (err);
}
map->flags = ENMAP_ALLOC;
@ -754,7 +754,7 @@ en_txdma(struct en_softc *sc, struct en_txslot *slot)
lastm->m_next = NULL;
if (error != 0) {
if_printf(&sc->ifatm.ifnet, "loading TX map failed %d\n",
if_printf(sc->ifp, "loading TX map failed %d\n",
error);
goto dequeue_drop;
}
@ -770,13 +770,13 @@ en_txdma(struct en_softc *sc, struct en_txslot *slot)
}
EN_COUNT(sc->stats.launch);
sc->ifatm.ifnet.if_opackets++;
sc->ifp->if_opackets++;
sc->vccs[tx.vci]->opackets++;
sc->vccs[tx.vci]->obytes += tx.datalen;
#ifdef ENABLE_BPF
if (sc->ifatm.ifnet.if_bpf != NULL) {
if (sc->ifp->if_bpf != NULL) {
/*
* adjust the top of the mbuf to skip the TBD if present
* before passing the packet to bpf.
@ -794,7 +794,7 @@ en_txdma(struct en_softc *sc, struct en_txslot *slot)
tx.m->m_pkthdr.len = tx.datalen;
}
BPF_MTAP(&sc->ifatm.ifnet, tx.m);
BPF_MTAP(sc->ifp, tx.m);
}
#endif
@ -1314,12 +1314,12 @@ en_close_vcc(struct en_softc *sc, struct atmio_closevcc *cl)
goto done;
vc->vflags |= VCC_CLOSE_RX;
while ((sc->ifatm.ifnet.if_flags & IFF_RUNNING) &&
while ((sc->ifp->if_flags & IFF_RUNNING) &&
(vc->vflags & VCC_DRAIN))
cv_wait(&sc->cv_close, &sc->en_mtx);
en_close_finish(sc, vc);
if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
if (!(sc->ifp->if_flags & IFF_RUNNING)) {
error = EIO;
goto done;
}
@ -1349,8 +1349,8 @@ en_reset_ul(struct en_softc *sc)
struct en_rxslot *rx;
int lcv;
if_printf(&sc->ifatm.ifnet, "reset\n");
sc->ifatm.ifnet.if_flags &= ~IFF_RUNNING;
if_printf(sc->ifp, "reset\n");
sc->ifp->if_flags &= ~IFF_RUNNING;
if (sc->en_busreset)
sc->en_busreset(sc);
@ -1439,14 +1439,14 @@ en_init(struct en_softc *sc)
int vc, slot;
uint32_t loc;
if ((sc->ifatm.ifnet.if_flags & IFF_UP) == 0) {
if ((sc->ifp->if_flags & IFF_UP) == 0) {
DBG(sc, INIT, ("going down"));
en_reset(sc); /* to be safe */
return;
}
DBG(sc, INIT, ("going up"));
sc->ifatm.ifnet.if_flags |= IFF_RUNNING; /* enable */
sc->ifp->if_flags |= IFF_RUNNING; /* enable */
if (sc->en_busreset)
sc->en_busreset(sc);
@ -1820,7 +1820,7 @@ en_rx_drain(struct en_softc *sc, u_int drq)
if (EN_DQ_LEN(drq) != 0) {
_IF_DEQUEUE(&slot->indma, m);
KASSERT(m != NULL, ("drqsync: %s: lost mbuf in slot %zu!",
sc->ifatm.ifnet.if_xname, slot - sc->rxslot));
sc->ifp->if_xname, slot - sc->rxslot));
uma_zfree(sc->map_zone, (struct en_map *)m->m_pkthdr.rcvif);
}
if ((vc = slot->vcc) == NULL) {
@ -1856,8 +1856,8 @@ en_rx_drain(struct en_softc *sc, u_int drq)
"hand %p", slot - sc->rxslot, vc->vcc.vci, m,
EN_DQ_LEN(drq), vc->rxhand));
m->m_pkthdr.rcvif = &sc->ifatm.ifnet;
sc->ifatm.ifnet.if_ipackets++;
m->m_pkthdr.rcvif = sc->ifp;
sc->ifp->if_ipackets++;
vc->ipackets++;
vc->ibytes += m->m_pkthdr.len;
@ -1867,9 +1867,9 @@ en_rx_drain(struct en_softc *sc, u_int drq)
en_dump_packet(sc, m);
#endif
#ifdef ENABLE_BPF
BPF_MTAP(&sc->ifatm.ifnet, m);
BPF_MTAP(sc->ifp, m);
#endif
atm_input(&sc->ifatm.ifnet, &ah, m, vc->rxhand);
atm_input(sc->ifp, &ah, m, vc->rxhand);
}
}
@ -2250,16 +2250,16 @@ en_service(struct en_softc *sc)
if (MID_RBD_CNT(rbd) * MID_ATMDATASZ <
MID_PDU_LEN(pdu)) {
if_printf(&sc->ifatm.ifnet, "invalid AAL5 length\n");
if_printf(sc->ifp, "invalid AAL5 length\n");
rx.post_skip = MID_RBD_CNT(rbd) * MID_ATMDATASZ;
mlen = 0;
sc->ifatm.ifnet.if_ierrors++;
sc->ifp->if_ierrors++;
} else if (rbd & MID_RBD_CRCERR) {
if_printf(&sc->ifatm.ifnet, "CRC error\n");
if_printf(sc->ifp, "CRC error\n");
rx.post_skip = MID_RBD_CNT(rbd) * MID_ATMDATASZ;
mlen = 0;
sc->ifatm.ifnet.if_ierrors++;
sc->ifp->if_ierrors++;
} else {
mlen = MID_PDU_LEN(pdu);
@ -2334,7 +2334,7 @@ en_service(struct en_softc *sc)
en_rxdma_load, &rx, BUS_DMA_NOWAIT);
if (error != 0) {
if_printf(&sc->ifatm.ifnet, "loading RX map failed "
if_printf(sc->ifp, "loading RX map failed "
"%d\n", error);
uma_zfree(sc->map_zone, map);
m_freem(m);
@ -2430,11 +2430,11 @@ en_intr(void *arg)
* unexpected errors that need a reset
*/
if ((reg & (MID_INT_IDENT | MID_INT_LERR | MID_INT_DMA_ERR)) != 0) {
if_printf(&sc->ifatm.ifnet, "unexpected interrupt=0x%b, "
if_printf(sc->ifp, "unexpected interrupt=0x%b, "
"resetting\n", reg, MID_INTBITS);
#ifdef EN_DEBUG
kdb_enter("en: unexpected error");
sc->ifatm.ifnet.if_flags &= ~IFF_RUNNING; /* FREEZE! */
sc->ifp->if_flags &= ~IFF_RUNNING; /* FREEZE! */
#else
en_reset_ul(sc);
en_init(sc);
@ -2493,7 +2493,7 @@ en_intr(void *arg)
static int
en_utopia_readregs(struct ifatm *ifatm, u_int reg, uint8_t *val, u_int *n)
{
struct en_softc *sc = ifatm->ifnet.if_softc;
struct en_softc *sc = ifatm->ifp->if_softc;
u_int i;
EN_CHECKLOCK(sc);
@ -2514,7 +2514,7 @@ en_utopia_readregs(struct ifatm *ifatm, u_int reg, uint8_t *val, u_int *n)
static int
en_utopia_writereg(struct ifatm *ifatm, u_int reg, u_int mask, u_int val)
{
struct en_softc *sc = ifatm->ifnet.if_softc;
struct en_softc *sc = ifatm->ifp->if_softc;
uint32_t regval;
EN_CHECKLOCK(sc);
@ -2797,13 +2797,14 @@ en_dmaprobe(struct en_softc *sc)
int
en_attach(struct en_softc *sc)
{
struct ifnet *ifp = &sc->ifatm.ifnet;
struct ifnet *ifp = sc->ifp;
int sz;
uint32_t reg, lcv, check, ptr, sav, midvloc;
#ifdef EN_DEBUG
sc->debug = EN_DEBUG;
#endif
/*
* Probe card to determine memory size.
*
@ -2852,7 +2853,7 @@ en_attach(struct en_softc *sc)
reg = en_read(sc, MID_RESID);
if_printf(&sc->ifatm.ifnet, "ATM midway v%d, board IDs %d.%d, %s%s%s, "
if_printf(sc->ifp, "ATM midway v%d, board IDs %d.%d, %s%s%s, "
"%ldKB on-board RAM\n", MID_VER(reg), MID_MID(reg), MID_DID(reg),
(MID_IS_SABRE(reg)) ? "sabre controller, " : "",
(MID_IS_SUNI(reg)) ? "SUNI" : "Utopia",
@ -2862,31 +2863,31 @@ en_attach(struct en_softc *sc)
/*
* fill in common ATM interface stuff
*/
sc->ifatm.mib.hw_version = (MID_VER(reg) << 16) |
IFP2IFATM(sc->ifp)->mib.hw_version = (MID_VER(reg) << 16) |
(MID_MID(reg) << 8) | MID_DID(reg);
if (MID_DID(reg) & 0x4)
sc->ifatm.mib.media = IFM_ATM_UTP_155;
IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_UTP_155;
else
sc->ifatm.mib.media = IFM_ATM_MM_155;
IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_MM_155;
sc->ifatm.mib.pcr = ATM_RATE_155M;
sc->ifatm.mib.vpi_bits = 0;
sc->ifatm.mib.vci_bits = MID_VCI_BITS;
sc->ifatm.mib.max_vccs = MID_N_VC;
sc->ifatm.mib.max_vpcs = 0;
IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_155M;
IFP2IFATM(sc->ifp)->mib.vpi_bits = 0;
IFP2IFATM(sc->ifp)->mib.vci_bits = MID_VCI_BITS;
IFP2IFATM(sc->ifp)->mib.max_vccs = MID_N_VC;
IFP2IFATM(sc->ifp)->mib.max_vpcs = 0;
if (sc->is_adaptec) {
sc->ifatm.mib.device = ATM_DEVICE_ADP155P;
IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_ADP155P;
if (sc->bestburstlen == 64 && sc->alburst == 0)
if_printf(&sc->ifatm.ifnet,
if_printf(sc->ifp,
"passed 64 byte DMA test\n");
else
if_printf(&sc->ifatm.ifnet, "FAILED DMA TEST: "
if_printf(sc->ifp, "FAILED DMA TEST: "
"burst=%d, alburst=%d\n", sc->bestburstlen,
sc->alburst);
} else {
sc->ifatm.mib.device = ATM_DEVICE_ENI155P;
if_printf(&sc->ifatm.ifnet, "maximum DMA burst length = %d "
IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_ENI155P;
if_printf(sc->ifp, "maximum DMA burst length = %d "
"bytes%s\n", sc->bestburstlen, sc->alburst ?
sc->noalbursts ? " (no large bursts)" : " (must align)" :
"");
@ -2895,7 +2896,7 @@ en_attach(struct en_softc *sc)
/*
* link into network subsystem and prepare card
*/
sc->ifatm.ifnet.if_softc = sc;
sc->ifp->if_softc = sc;
ifp->if_flags = IFF_SIMPLEX;
ifp->if_ioctl = en_ioctl;
ifp->if_start = en_start;
@ -2925,8 +2926,8 @@ en_attach(struct en_softc *sc)
goto fail;
#endif
sc->ifatm.phy = &sc->utopia;
utopia_attach(&sc->utopia, &sc->ifatm, &sc->media, &sc->en_mtx,
IFP2IFATM(sc->ifp)->phy = &sc->utopia;
utopia_attach(&sc->utopia, IFP2IFATM(sc->ifp), &sc->media, &sc->en_mtx,
&sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree),
&en_utopia_methods);
utopia_init_media(&sc->utopia);
@ -2960,7 +2961,7 @@ en_attach(struct en_softc *sc)
ptr = roundup(ptr, EN_TXSZ * 1024); /* align */
sz = sz - (ptr - sav);
if (EN_TXSZ*1024 * EN_NTX > sz) {
if_printf(&sc->ifatm.ifnet, "EN_NTX/EN_TXSZ too big\n");
if_printf(sc->ifp, "EN_NTX/EN_TXSZ too big\n");
goto fail;
}
for (lcv = 0 ;lcv < EN_NTX ;lcv++) {
@ -2979,7 +2980,7 @@ en_attach(struct en_softc *sc)
sz = sz - (ptr - sav);
sc->en_nrx = sz / (EN_RXSZ * 1024);
if (sc->en_nrx <= 0) {
if_printf(&sc->ifatm.ifnet, "EN_NTX/EN_TXSZ/EN_RXSZ too big\n");
if_printf(sc->ifp, "EN_NTX/EN_TXSZ/EN_RXSZ too big\n");
goto fail;
}
@ -3010,10 +3011,10 @@ en_attach(struct en_softc *sc)
sc->rxslot[lcv].mode));
}
if_printf(&sc->ifatm.ifnet, "%d %dKB receive buffers, %d %dKB transmit "
if_printf(sc->ifp, "%d %dKB receive buffers, %d %dKB transmit "
"buffers\n", sc->en_nrx, EN_RXSZ, EN_NTX, EN_TXSZ);
if_printf(&sc->ifatm.ifnet, "end station identifier (mac address) "
"%6D\n", sc->ifatm.mib.esi, ":");
if_printf(sc->ifp, "end station identifier (mac address) "
"%6D\n", IFP2IFATM(sc->ifp)->mib.esi, ":");
/*
* Start SUNI stuff. This will call our readregs/writeregs
@ -3302,7 +3303,7 @@ en_dump(int unit, int level)
if (unit != -1 && unit != lcv)
continue;
if_printf(&sc->ifatm.ifnet, "dumping device at level 0x%b\n",
if_printf(sc->ifp, "dumping device at level 0x%b\n",
level, END_BITS);
if (sc->dtq_us == 0) {

View File

@ -153,8 +153,7 @@ struct en_vcc {
* softc
*/
struct en_softc {
/* bsd glue */
struct ifatm ifatm; /* ATM network ifnet handle */
struct ifnet *ifp;
device_t dev;
/* bus glue */

View File

@ -74,6 +74,7 @@ __FBSDID("$FreeBSD$");
#include <net/if.h>
#include <net/if_arp.h>
#include <net/if_media.h>
#include <net/if_types.h>
#include <net/ethernet.h>
#include <net/bpf.h>
@ -262,14 +263,14 @@ ep_attach(struct ep_softc *sc)
{
struct ifnet *ifp = NULL;
struct ifmedia *ifm = NULL;
u_char eaddr[6];
u_short *p;
int i;
int attached;
int error;
sc->gone = 0;
EP_LOCK_INIT(sc);
error = ep_get_macaddr(sc, (u_char *)&sc->arpcom.ac_enaddr);
error = ep_get_macaddr(sc, eaddr);
if (error) {
device_printf(sc->dev, "Unable to get Ethernet address!\n");
EP_LOCK_DESTORY(sc);
@ -278,13 +279,17 @@ ep_attach(struct ep_softc *sc)
/*
* Setup the station address
*/
p = (u_short *)&sc->arpcom.ac_enaddr;
p = (u_short *)eaddr;
GO_WINDOW(sc, 2);
for (i = 0; i < 3; i++)
CSR_WRITE_2(sc, EP_W2_ADDR_0 + (i * 2), ntohs(p[i]));
ifp = &sc->arpcom.ac_if;
attached = (ifp->if_softc != 0);
ifp = sc->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(sc->dev, "can not if_alloc()\n");
EP_LOCK_DESTORY(sc);
return (ENOSPC);
}
ifp->if_softc = sc;
if_initname(ifp, device_get_name(sc->dev), device_get_unit(sc->dev));
@ -319,8 +324,7 @@ ep_attach(struct ep_softc *sc)
ifm->ifm_media = ifm->ifm_cur->ifm_media;
ep_ifmedia_upd(ifp);
}
if (!attached)
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
ether_ifattach(ifp, eaddr);
#ifdef EP_LOCAL_STATS
sc->rx_no_first = sc->rx_no_mbuf = sc->rx_bpf_disc =
@ -342,7 +346,7 @@ ep_detach(device_t dev)
sc = device_get_softc(dev);
EP_ASSERT_UNLOCKED(sc);
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
if (sc->gone) {
device_printf(dev, "already unloaded\n");
@ -353,6 +357,7 @@ ep_detach(device_t dev)
ifp->if_flags &= ~IFF_RUNNING;
ether_ifdetach(ifp);
if_free(ifp);
sc->gone = 1;
ep_free(dev);
@ -377,7 +382,7 @@ epinit(void *xsc)
static void
epinit_locked(struct ep_softc *sc)
{
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->ifp;
int i;
if (sc->gone)
@ -402,7 +407,7 @@ epinit_locked(struct ep_softc *sc)
/* Reload the ether_addr. */
for (i = 0; i < 6; i++)
CSR_WRITE_1(sc, EP_W2_ADDR_0 + i, sc->arpcom.ac_enaddr[i]);
CSR_WRITE_1(sc, EP_W2_ADDR_0 + i, IFP2ENADDR(sc->ifp)[i]);
CSR_WRITE_2(sc, EP_COMMAND, RX_RESET);
CSR_WRITE_2(sc, EP_COMMAND, TX_RESET);
@ -592,7 +597,7 @@ ep_intr(void *arg)
EP_UNLOCK(sc);
return;
}
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
CSR_WRITE_2(sc, EP_COMMAND, SET_INTR_MASK); /* disable all Ints */
@ -710,7 +715,7 @@ epread(struct ep_softc *sc)
/* XXX Must be called with sc locked */
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
status = CSR_READ_2(sc, EP_W1_RX_STATUS);
read_again:
@ -816,7 +821,7 @@ epread(struct ep_softc *sc)
CSR_WRITE_2(sc, EP_COMMAND, RX_DISCARD_TOP_PACK);
++ifp->if_ipackets;
EP_FSET(sc, F_RX_FIRST);
top->m_pkthdr.rcvif = &sc->arpcom.ac_if;
top->m_pkthdr.rcvif = sc->ifp;
top->m_pkthdr.len = sc->cur_len;
/*

View File

@ -120,7 +120,7 @@ ep_pccard_probe(device_t dev)
* Newer cards supported by this device need to have their
* MAC address set.
*/
error = ep_get_macaddr(sc, (u_char *)&sc->arpcom.ac_enaddr);
error = ep_get_macaddr(sc, (u_char *)&IFP2ENADDR(sc->ifp));
ep_free(dev);
return (0);

View File

@ -33,7 +33,7 @@ struct ep_board {
* Ethernet software status per interface.
*/
struct ep_softc {
struct arpcom arpcom; /* Ethernet common part */
struct ifnet *ifp;
struct ifmedia ifmedia; /* media info */
device_t dev;

View File

@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_arp.h>
#include <net/if_dl.h>
#include <net/if_media.h>
#include <net/if_types.h>
#include <net/ethernet.h>
#include <net/bpf.h>
@ -202,12 +203,17 @@ int
ex_attach(device_t dev)
{
struct ex_softc * sc = device_get_softc(dev);
struct ifnet * ifp = &sc->arpcom.ac_if;
struct ifnet * ifp;
struct ifmedia * ifm;
uint16_t temp;
ifp = sc->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
return (ENOSPC);
}
/* work out which set of irq <-> internal tables to use */
if (ex_card_type(sc->arpcom.ac_enaddr) == CARD_TYPE_EX_10_PLUS) {
if (ex_card_type(sc->enaddr) == CARD_TYPE_EX_10_PLUS) {
sc->irq2ee = plus_irq2eemap;
sc->ee2irq = plus_ee2irqmap;
} else {
@ -252,7 +258,7 @@ ex_attach(device_t dev)
/*
* Attach the interface.
*/
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
ether_ifattach(ifp, sc->enaddr);
return(0);
}
@ -264,12 +270,13 @@ ex_detach(device_t dev)
struct ifnet *ifp;
sc = device_get_softc(dev);
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
ex_stop(sc);
ifp->if_flags &= ~IFF_RUNNING;
ether_ifdetach(ifp);
if_free(ifp);
ex_release_resources(dev);
@ -280,7 +287,7 @@ static void
ex_init(void *xsc)
{
struct ex_softc * sc = (struct ex_softc *) xsc;
struct ifnet * ifp = &sc->arpcom.ac_if;
struct ifnet * ifp = sc->ifp;
int s;
int i;
unsigned short temp_reg;
@ -299,7 +306,7 @@ ex_init(void *xsc)
CSR_WRITE_1(sc, EEPROM_REG, temp_reg & ~Trnoff_Enable);
}
for (i = 0; i < ETHER_ADDR_LEN; i++) {
CSR_WRITE_1(sc, I_ADDR_REG0 + i, sc->arpcom.ac_enaddr[i]);
CSR_WRITE_1(sc, I_ADDR_REG0 + i, IFP2ENADDR(sc->ifp)[i]);
}
/*
* - Setup transmit chaining and discard bad received frames.
@ -574,7 +581,7 @@ void
ex_intr(void *arg)
{
struct ex_softc *sc = (struct ex_softc *)arg;
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->ifp;
int int_status, send_pkts;
int loops = 100;
@ -613,7 +620,7 @@ ex_intr(void *arg)
static void
ex_tx_intr(struct ex_softc *sc)
{
struct ifnet * ifp = &sc->arpcom.ac_if;
struct ifnet * ifp = sc->ifp;
int tx_status;
DODEBUG(Start_End, printf("ex_tx_intr%d: start\n", unit););
@ -660,7 +667,7 @@ ex_tx_intr(struct ex_softc *sc)
static void
ex_rx_intr(struct ex_softc *sc)
{
struct ifnet * ifp = &sc->arpcom.ac_if;
struct ifnet * ifp = sc->ifp;
int rx_status;
int pkt_len;
int QQQ;
@ -830,7 +837,7 @@ ex_setmulti(struct ex_softc *sc)
int count;
int timeout, status;
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
count = 0;
TAILQ_FOREACH(maddr, &ifp->if_multiaddrs, ifma_link) {
@ -879,7 +886,7 @@ ex_setmulti(struct ex_softc *sc)
/* Program our MAC address as well */
/* XXX: Is this necessary? The Linux driver does this
* but the NetBSD driver does not */
addr = (uint16_t*)(&sc->arpcom.ac_enaddr);
addr = (uint16_t*)(&IFP2ENADDR(sc->ifp));
CSR_WRITE_2(sc, IO_PORT_REG, *addr++);
CSR_WRITE_2(sc, IO_PORT_REG, *addr++);
CSR_WRITE_2(sc, IO_PORT_REG, *addr++);

View File

@ -296,7 +296,7 @@ ex_isa_attach(device_t dev)
*/
sc->irq_no = rman_get_start(sc->irq);
ex_get_address(sc, sc->arpcom.ac_enaddr);
ex_get_address(sc, sc->enaddr);
temp = ex_eeprom_read(sc, EE_W0);
device_printf(sc->dev, "%s config, %s bus, ",

View File

@ -231,7 +231,7 @@ ex_pccard_attach(device_t dev)
error = ENXIO;
goto bad;
}
bcopy(ether_addr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
bcopy(ether_addr, sc->enaddr, ETHER_ADDR_LEN);
if ((error = ex_attach(dev)) != 0) {
device_printf(dev, "ex_attach() failed!\n");

View File

@ -30,8 +30,9 @@
*/
struct ex_softc {
struct arpcom arpcom; /* Ethernet common data */
struct ifnet *ifp;
struct ifmedia ifmedia;
u_char enaddr[6];
device_t dev;
struct resource *ioport;

View File

@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
#include <net/if.h>
#include <net/if_media.h>
#include <net/if_types.h>
#include <net/if_atm.h>
#include <net/route.h>
#ifdef INET
@ -111,8 +112,8 @@ static const struct utopia_methods fatm_utopia_methods = {
};
#define VC_OK(SC, VPI, VCI) \
(((VPI) & ~((1 << (SC)->ifatm.mib.vpi_bits) - 1)) == 0 && \
(VCI) != 0 && ((VCI) & ~((1 << (SC)->ifatm.mib.vci_bits) - 1)) == 0)
(((VPI) & ~((1 << IFP2IFATM((SC)->ifp)->mib.vpi_bits) - 1)) == 0 && \
(VCI) != 0 && ((VCI) & ~((1 << IFP2IFATM((SC)->ifp)->mib.vci_bits) - 1)) == 0)
static int fatm_load_vc(struct fatm_softc *sc, struct card_vcc *vc);
@ -165,9 +166,9 @@ fatm_utopia_writereg(struct ifatm *ifatm, u_int reg, u_int mask, u_int val)
struct cmdqueue *q;
struct fatm_softc *sc;
sc = ifatm->ifnet.if_softc;
sc = ifatm->ifp->if_softc;
FATM_CHECKLOCK(sc);
if (!(ifatm->ifnet.if_flags & IFF_RUNNING))
if (!(ifatm->ifp->if_flags & IFF_RUNNING))
return (EIO);
/* get queue element and fill it */
@ -250,7 +251,7 @@ fatm_utopia_readregs_internal(struct fatm_softc *sc)
/* get the buffer */
for (;;) {
if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING))
if (!(sc->ifp->if_flags & IFF_RUNNING))
return (EIO);
if (!(sc->flags & FATM_REGS_INUSE))
break;
@ -334,7 +335,7 @@ fatm_utopia_readregs(struct ifatm *ifatm, u_int reg, uint8_t *valp, u_int *np)
return (EINVAL);
if (reg + *np > FATM_NREGS)
*np = FATM_NREGS - reg;
sc = ifatm->ifnet.if_softc;
sc = ifatm->ifp->if_softc;
FATM_CHECKLOCK(sc);
err = fatm_utopia_readregs_internal(sc);
@ -470,11 +471,11 @@ fatm_stop(struct fatm_softc *sc)
(void)fatm_reset(sc);
/* stop watchdog */
sc->ifatm.ifnet.if_timer = 0;
sc->ifp->if_timer = 0;
if (sc->ifatm.ifnet.if_flags & IFF_RUNNING) {
sc->ifatm.ifnet.if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
ATMEV_SEND_IFSTATE_CHANGED(&sc->ifatm,
if (sc->ifp->if_flags & IFF_RUNNING) {
sc->ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
ATMEV_SEND_IFSTATE_CHANGED(IFP2IFATM(sc->ifp),
sc->utopia.carrier == UTP_CARR_OK);
/*
@ -876,12 +877,12 @@ fatm_getprom(struct fatm_softc *sc)
DELAY(1000);
}
if (i == 1000) {
if_printf(&sc->ifatm.ifnet, "getprom timeout\n");
if_printf(sc->ifp, "getprom timeout\n");
return (EIO);
}
H_SYNCSTAT_POSTREAD(sc, q->q.statp);
if (H_GETSTAT(q->q.statp) & FATM_STAT_ERROR) {
if_printf(&sc->ifatm.ifnet, "getprom error\n");
if_printf(sc->ifp, "getprom error\n");
return (EIO);
}
H_SETSTAT(q->q.statp, FATM_STAT_FREE);
@ -906,16 +907,16 @@ fatm_getprom(struct fatm_softc *sc)
prom = (struct prom *)sc->prom_mem.mem;
bcopy(prom->mac + 2, sc->ifatm.mib.esi, 6);
sc->ifatm.mib.serial = le32toh(prom->serial);
sc->ifatm.mib.hw_version = le32toh(prom->version);
sc->ifatm.mib.sw_version = READ4(sc, FATMO_FIRMWARE_RELEASE);
bcopy(prom->mac + 2, IFP2IFATM(sc->ifp)->mib.esi, 6);
IFP2IFATM(sc->ifp)->mib.serial = le32toh(prom->serial);
IFP2IFATM(sc->ifp)->mib.hw_version = le32toh(prom->version);
IFP2IFATM(sc->ifp)->mib.sw_version = READ4(sc, FATMO_FIRMWARE_RELEASE);
if_printf(&sc->ifatm.ifnet, "ESI=%02x:%02x:%02x:%02x:%02x:%02x "
"serial=%u hw=0x%x sw=0x%x\n", sc->ifatm.mib.esi[0],
sc->ifatm.mib.esi[1], sc->ifatm.mib.esi[2], sc->ifatm.mib.esi[3],
sc->ifatm.mib.esi[4], sc->ifatm.mib.esi[5], sc->ifatm.mib.serial,
sc->ifatm.mib.hw_version, sc->ifatm.mib.sw_version);
if_printf(sc->ifp, "ESI=%02x:%02x:%02x:%02x:%02x:%02x "
"serial=%u hw=0x%x sw=0x%x\n", IFP2IFATM(sc->ifp)->mib.esi[0],
IFP2IFATM(sc->ifp)->mib.esi[1], IFP2IFATM(sc->ifp)->mib.esi[2], IFP2IFATM(sc->ifp)->mib.esi[3],
IFP2IFATM(sc->ifp)->mib.esi[4], IFP2IFATM(sc->ifp)->mib.esi[5], IFP2IFATM(sc->ifp)->mib.serial,
IFP2IFATM(sc->ifp)->mib.hw_version, IFP2IFATM(sc->ifp)->mib.sw_version);
return (0);
}
@ -954,14 +955,14 @@ alloc_dma_memory(struct fatm_softc *sc, const char *nm, struct fatm_mem *mem)
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
NULL, NULL, mem->size, 1, BUS_SPACE_MAXSIZE_32BIT,
BUS_DMA_ALLOCNOW, NULL, NULL, &mem->dmat)) {
if_printf(&sc->ifatm.ifnet, "could not allocate %s DMA tag\n",
if_printf(sc->ifp, "could not allocate %s DMA tag\n",
nm);
return (ENOMEM);
}
error = bus_dmamem_alloc(mem->dmat, &mem->mem, 0, &mem->map);
if (error) {
if_printf(&sc->ifatm.ifnet, "could not allocate %s DMA memory: "
if_printf(sc->ifp, "could not allocate %s DMA memory: "
"%d\n", nm, error);
bus_dma_tag_destroy(mem->dmat);
mem->mem = NULL;
@ -971,7 +972,7 @@ alloc_dma_memory(struct fatm_softc *sc, const char *nm, struct fatm_mem *mem)
error = bus_dmamap_load(mem->dmat, mem->map, mem->mem, mem->size,
dmaload_helper, &mem->paddr, BUS_DMA_NOWAIT);
if (error) {
if_printf(&sc->ifatm.ifnet, "could not load %s DMA memory: "
if_printf(sc->ifp, "could not load %s DMA memory: "
"%d\n", nm, error);
bus_dmamem_free(mem->dmat, mem->mem, mem->map);
bus_dma_tag_destroy(mem->dmat);
@ -997,7 +998,7 @@ alloc_dma_memoryX(struct fatm_softc *sc, const char *nm, struct fatm_mem *mem)
BUS_SPACE_MAXADDR_24BIT, BUS_SPACE_MAXADDR,
NULL, NULL, mem->size, 1, mem->size,
BUS_DMA_ALLOCNOW, NULL, NULL, &mem->dmat)) {
if_printf(&sc->ifatm.ifnet, "could not allocate %s DMA tag\n",
if_printf(sc->ifp, "could not allocate %s DMA tag\n",
nm);
return (ENOMEM);
}
@ -1007,7 +1008,7 @@ alloc_dma_memoryX(struct fatm_softc *sc, const char *nm, struct fatm_mem *mem)
error = bus_dmamap_create(mem->dmat, 0, &mem->map);
if (error) {
if_printf(&sc->ifatm.ifnet, "could not allocate %s DMA map: "
if_printf(sc->ifp, "could not allocate %s DMA map: "
"%d\n", nm, error);
contigfree(mem->mem, mem->size, M_DEVBUF);
bus_dma_tag_destroy(mem->dmat);
@ -1018,7 +1019,7 @@ alloc_dma_memoryX(struct fatm_softc *sc, const char *nm, struct fatm_mem *mem)
error = bus_dmamap_load(mem->dmat, mem->map, mem->mem, mem->size,
dmaload_helper, &mem->paddr, BUS_DMA_NOWAIT);
if (error) {
if_printf(&sc->ifatm.ifnet, "could not load %s DMA memory: "
if_printf(sc->ifp, "could not load %s DMA memory: "
"%d\n", nm, error);
bus_dmamap_destroy(mem->dmat, mem->map);
contigfree(mem->mem, mem->size, M_DEVBUF);
@ -1094,7 +1095,7 @@ fatm_supply_small_buffers(struct fatm_softc *sc)
for (i = 0; i < SMALL_SUPPLY_BLKSIZE; i++) {
if ((rb = LIST_FIRST(&sc->rbuf_free)) == NULL) {
if_printf(&sc->ifatm.ifnet, "out of rbufs\n");
if_printf(sc->ifp, "out of rbufs\n");
break;
}
MGETHDR(m, M_DONTWAIT, MT_DATA);
@ -1107,7 +1108,7 @@ fatm_supply_small_buffers(struct fatm_softc *sc)
m->m_data, SMALL_BUFFER_LEN, dmaload_helper,
&phys, BUS_DMA_NOWAIT);
if (error) {
if_printf(&sc->ifatm.ifnet,
if_printf(sc->ifp,
"dmamap_load mbuf failed %d", error);
m_freem(m);
LIST_INSERT_HEAD(&sc->rbuf_free, rb, link);
@ -1184,7 +1185,7 @@ fatm_supply_large_buffers(struct fatm_softc *sc)
for (i = 0; i < LARGE_SUPPLY_BLKSIZE; i++) {
if ((rb = LIST_FIRST(&sc->rbuf_free)) == NULL) {
if_printf(&sc->ifatm.ifnet, "out of rbufs\n");
if_printf(sc->ifp, "out of rbufs\n");
break;
}
if ((m = m_getcl(M_DONTWAIT, MT_DATA,
@ -1198,7 +1199,7 @@ fatm_supply_large_buffers(struct fatm_softc *sc)
m->m_data, LARGE_BUFFER_LEN, dmaload_helper,
&phys, BUS_DMA_NOWAIT);
if (error) {
if_printf(&sc->ifatm.ifnet,
if_printf(sc->ifp,
"dmamap_load mbuf failed %d", error);
m_freem(m);
LIST_INSERT_HEAD(&sc->rbuf_free, rb, link);
@ -1256,7 +1257,7 @@ fatm_init_locked(struct fatm_softc *sc)
uint32_t start;
DBG(sc, INIT, ("initialize"));
if (sc->ifatm.ifnet.if_flags & IFF_RUNNING)
if (sc->ifp->if_flags & IFF_RUNNING)
fatm_stop(sc);
/*
@ -1279,39 +1280,39 @@ fatm_init_locked(struct fatm_softc *sc)
switch (c) {
case FORE_MT_TAXI_100:
sc->ifatm.mib.media = IFM_ATM_TAXI_100;
sc->ifatm.mib.pcr = 227273;
IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_TAXI_100;
IFP2IFATM(sc->ifp)->mib.pcr = 227273;
break;
case FORE_MT_TAXI_140:
sc->ifatm.mib.media = IFM_ATM_TAXI_140;
sc->ifatm.mib.pcr = 318181;
IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_TAXI_140;
IFP2IFATM(sc->ifp)->mib.pcr = 318181;
break;
case FORE_MT_UTP_SONET:
sc->ifatm.mib.media = IFM_ATM_UTP_155;
sc->ifatm.mib.pcr = 353207;
IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_UTP_155;
IFP2IFATM(sc->ifp)->mib.pcr = 353207;
break;
case FORE_MT_MM_OC3_ST:
case FORE_MT_MM_OC3_SC:
sc->ifatm.mib.media = IFM_ATM_MM_155;
sc->ifatm.mib.pcr = 353207;
IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_MM_155;
IFP2IFATM(sc->ifp)->mib.pcr = 353207;
break;
case FORE_MT_SM_OC3_ST:
case FORE_MT_SM_OC3_SC:
sc->ifatm.mib.media = IFM_ATM_SM_155;
sc->ifatm.mib.pcr = 353207;
IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_SM_155;
IFP2IFATM(sc->ifp)->mib.pcr = 353207;
break;
default:
log(LOG_ERR, "fatm: unknown media type %d\n", c);
sc->ifatm.mib.media = IFM_ATM_UNKNOWN;
sc->ifatm.mib.pcr = 353207;
IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_UNKNOWN;
IFP2IFATM(sc->ifp)->mib.pcr = 353207;
break;
}
sc->ifatm.ifnet.if_baudrate = 53 * 8 * sc->ifatm.mib.pcr;
sc->ifp->if_baudrate = 53 * 8 * IFP2IFATM(sc->ifp)->mib.pcr;
utopia_init_media(&sc->utopia);
/*
@ -1332,17 +1333,17 @@ fatm_init_locked(struct fatm_softc *sc)
/*
* Now set flags, that we are ready
*/
sc->ifatm.ifnet.if_flags |= IFF_RUNNING;
sc->ifp->if_flags |= IFF_RUNNING;
/*
* Start the watchdog timer
*/
sc->ifatm.ifnet.if_timer = 5;
sc->ifp->if_timer = 5;
/* start SUNI */
utopia_start(&sc->utopia);
ATMEV_SEND_IFSTATE_CHANGED(&sc->ifatm,
ATMEV_SEND_IFSTATE_CHANGED(IFP2IFATM(sc->ifp),
sc->utopia.carrier == UTP_CARR_OK);
/* start all channels */
@ -1351,7 +1352,7 @@ fatm_init_locked(struct fatm_softc *sc)
sc->vccs[i]->vflags |= FATM_VCC_REOPEN;
error = fatm_load_vc(sc, sc->vccs[i]);
if (error != 0) {
if_printf(&sc->ifatm.ifnet, "reopening %u "
if_printf(sc->ifp, "reopening %u "
"failed: %d\n", i, error);
sc->vccs[i]->vflags &= ~FATM_VCC_REOPEN;
}
@ -1525,7 +1526,7 @@ fatm_intr_drain_rx(struct fatm_softc *sc)
}
m0->m_pkthdr.len = mlen;
m0->m_pkthdr.rcvif = &sc->ifatm.ifnet;
m0->m_pkthdr.rcvif = sc->ifp;
h = le32toh(rpd->atm_header);
vpi = (h >> 20) & 0xff;
@ -1553,7 +1554,7 @@ fatm_intr_drain_rx(struct fatm_softc *sc)
ATM_PH_VPI(&aph) = vpi;
ATM_PH_SETVCI(&aph, vci);
ifp = &sc->ifatm.ifnet;
ifp = sc->ifp;
ifp->if_ipackets++;
vc->ipackets++;
@ -1624,7 +1625,7 @@ fatm_intr(void *p)
}
WRITE4(sc, FATMO_HCR, FATM_HCR_CLRIRQ);
if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
if (!(sc->ifp->if_flags & IFF_RUNNING)) {
FATM_UNLOCK(sc);
return;
}
@ -1638,8 +1639,8 @@ fatm_intr(void *p)
FATM_UNLOCK(sc);
if (sc->retry_tx && _IF_QLEN(&sc->ifatm.ifnet.if_snd))
(*sc->ifatm.ifnet.if_start)(&sc->ifatm.ifnet);
if (sc->retry_tx && _IF_QLEN(&sc->ifp->if_snd))
(*sc->ifp->if_start)(sc->ifp);
}
/*
@ -1679,7 +1680,7 @@ fatm_getstat(struct fatm_softc *sc)
* statistics buffer
*/
for (;;) {
if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING))
if (!(sc->ifp->if_flags & IFF_RUNNING))
return (EIO);
if (!(sc->flags & FATM_STAT_INUSE))
break;
@ -1948,7 +1949,7 @@ fatm_tx(struct fatm_softc *sc, struct mbuf *m, struct card_vcc *vc, u_int mlen)
if (H_GETSTAT(q->q.statp) != FATM_STAT_FREE) {
if (sc->retry_tx) {
sc->istats.tx_retry++;
IF_PREPEND(&sc->ifatm.ifnet.if_snd, m);
IF_PREPEND(&sc->ifp->if_snd, m);
return (1);
}
sc->istats.tx_queue_full++;
@ -1967,8 +1968,8 @@ fatm_tx(struct fatm_softc *sc, struct mbuf *m, struct card_vcc *vc, u_int mlen)
error = bus_dmamap_load_mbuf(sc->tx_tag, q->map, m,
fatm_tpd_load, tpd, BUS_DMA_NOWAIT);
if(error) {
sc->ifatm.ifnet.if_oerrors++;
if_printf(&sc->ifatm.ifnet, "mbuf loaded error=%d\n", error);
sc->ifp->if_oerrors++;
if_printf(sc->ifp, "mbuf loaded error=%d\n", error);
m_freem(m);
return (0);
}
@ -2018,7 +2019,7 @@ fatm_tx(struct fatm_softc *sc, struct mbuf *m, struct card_vcc *vc, u_int mlen)
BARRIER_W(sc);
sc->txcnt++;
sc->ifatm.ifnet.if_opackets++;
sc->ifp->if_opackets++;
vc->obytes += m->m_pkthdr.len;
vc->opackets++;
@ -2175,7 +2176,7 @@ fatm_open_finish(struct fatm_softc *sc, struct card_vcc *vc)
* VCC or it's an NG PVC. */
if (!(vc->param.flags & ATMIO_FLAG_NG) ||
(vc->param.flags & ATMIO_FLAG_PVC))
ATMEV_SEND_VCC_CHANGED(&sc->ifatm, 0, vc->param.vci, 1);
ATMEV_SEND_VCC_CHANGED(IFP2IFATM(sc->ifp), 0, vc->param.vci, 1);
}
/*
@ -2194,7 +2195,7 @@ fatm_open_complete(struct fatm_softc *sc, struct cmdqueue *q)
sc->istats.get_stat_errors++;
sc->vccs[vci] = NULL;
uma_zfree(sc->vcc_zone, vc);
if_printf(&sc->ifatm.ifnet, "opening VCI %u failed\n", vci);
if_printf(sc->ifp, "opening VCI %u failed\n", vci);
return;
}
fatm_open_finish(sc, vc);
@ -2246,7 +2247,7 @@ fatm_open_vcc(struct fatm_softc *sc, struct atmio_openvcc *op)
error = 0;
FATM_LOCK(sc);
if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
if (!(sc->ifp->if_flags & IFF_RUNNING)) {
error = EIO;
goto done;
}
@ -2264,7 +2265,7 @@ fatm_open_vcc(struct fatm_softc *sc, struct atmio_openvcc *op)
case ATMIO_TRAFFIC_CBR:
if (op->param.tparam.pcr == 0 ||
op->param.tparam.pcr > sc->ifatm.mib.pcr) {
op->param.tparam.pcr > IFP2IFATM(sc->ifp)->mib.pcr) {
error = EINVAL;
goto done;
}
@ -2340,7 +2341,7 @@ fatm_close_finish(struct fatm_softc *sc, struct card_vcc *vc)
* VCC or it's an NG PVC. */
if (!(vc->param.flags & ATMIO_FLAG_NG) ||
(vc->param.flags & ATMIO_FLAG_PVC))
ATMEV_SEND_VCC_CHANGED(&sc->ifatm, 0, vc->param.vci, 0);
ATMEV_SEND_VCC_CHANGED(IFP2IFATM(sc->ifp), 0, vc->param.vci, 0);
sc->vccs[vc->param.vci] = NULL;
sc->open_vccs--;
@ -2363,7 +2364,7 @@ fatm_close_complete(struct fatm_softc *sc, struct cmdqueue *q)
if (H_GETSTAT(q->q.statp) & FATM_STAT_ERROR) {
sc->istats.get_stat_errors++;
/* keep the VCC in that state */
if_printf(&sc->ifatm.ifnet, "closing VCI %u failed\n", vci);
if_printf(sc->ifp, "closing VCI %u failed\n", vci);
return;
}
@ -2386,7 +2387,7 @@ fatm_close_vcc(struct fatm_softc *sc, struct atmio_closevcc *cl)
error = 0;
FATM_LOCK(sc);
if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
if (!(sc->ifp->if_flags & IFF_RUNNING)) {
error = EIO;
goto done;
}
@ -2533,14 +2534,14 @@ fatm_detach(device_t dev)
fatm_stop(sc);
utopia_detach(&sc->utopia);
FATM_UNLOCK(sc);
atm_ifdetach(&sc->ifatm.ifnet); /* XXX race */
atm_ifdetach(sc->ifp); /* XXX race */
}
if (sc->ih != NULL)
bus_teardown_intr(dev, sc->irqres, sc->ih);
while ((rb = LIST_FIRST(&sc->rbuf_used)) != NULL) {
if_printf(&sc->ifatm.ifnet, "rbuf %p still in use!\n", rb);
if_printf(sc->ifp, "rbuf %p still in use!\n", rb);
bus_dmamap_unload(sc->rbuf_tag, rb->map);
m_freem(rb->m);
LIST_REMOVE(rb, link);
@ -2744,16 +2745,22 @@ fatm_attach(device_t dev)
sc = device_get_softc(dev);
unit = device_get_unit(dev);
sc->ifatm.mib.device = ATM_DEVICE_PCA200E;
sc->ifatm.mib.serial = 0;
sc->ifatm.mib.hw_version = 0;
sc->ifatm.mib.sw_version = 0;
sc->ifatm.mib.vpi_bits = 0;
sc->ifatm.mib.vci_bits = FORE_VCIBITS;
sc->ifatm.mib.max_vpcs = 0;
sc->ifatm.mib.max_vccs = FORE_MAX_VCC;
sc->ifatm.mib.media = IFM_ATM_UNKNOWN;
sc->ifatm.phy = &sc->utopia;
ifp = sc->ifp = if_alloc(IFT_ATM);
if (ifp == NULL) {
error = ENOSPC;
goto fail;
}
IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_PCA200E;
IFP2IFATM(sc->ifp)->mib.serial = 0;
IFP2IFATM(sc->ifp)->mib.hw_version = 0;
IFP2IFATM(sc->ifp)->mib.sw_version = 0;
IFP2IFATM(sc->ifp)->mib.vpi_bits = 0;
IFP2IFATM(sc->ifp)->mib.vci_bits = FORE_VCIBITS;
IFP2IFATM(sc->ifp)->mib.max_vpcs = 0;
IFP2IFATM(sc->ifp)->mib.max_vccs = FORE_MAX_VCC;
IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_UNKNOWN;
IFP2IFATM(sc->ifp)->phy = &sc->utopia;
LIST_INIT(&sc->rbuf_free);
LIST_INIT(&sc->rbuf_used);
@ -2803,7 +2810,6 @@ fatm_attach(device_t dev)
/*
* Network subsystem stuff
*/
ifp = &sc->ifatm.ifnet;
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_SIMPLEX;
@ -2811,8 +2817,8 @@ fatm_attach(device_t dev)
ifp->if_start = fatm_start;
ifp->if_watchdog = fatm_watchdog;
ifp->if_init = fatm_init;
ifp->if_linkmib = &sc->ifatm.mib;
ifp->if_linkmiblen = sizeof(sc->ifatm.mib);
ifp->if_linkmib = &IFP2IFATM(sc->ifp)->mib;
ifp->if_linkmiblen = sizeof(IFP2IFATM(sc->ifp)->mib);
/*
* Enable memory and bustmaster
@ -2991,7 +2997,7 @@ fatm_attach(device_t dev)
*/
for (rb = sc->rbufs, i = 0; i < sc->rbuf_total; i++, rb++) {
if ((error = bus_dmamap_create(sc->rbuf_tag, 0, &rb->map))) {
if_printf(&sc->ifatm.ifnet, "creating rx map: %d\n",
if_printf(sc->ifp, "creating rx map: %d\n",
error);
goto fail;
}
@ -3007,7 +3013,7 @@ fatm_attach(device_t dev)
for (i = 0; i < FATM_TX_QLEN; i++) {
tx = GET_QUEUE(sc->txqueue, struct txqueue, i);
if ((error = bus_dmamap_create(sc->tx_tag, 0, &tx->map))) {
if_printf(&sc->ifatm.ifnet, "creating tx map: %d\n",
if_printf(sc->ifp, "creating tx map: %d\n",
error);
while (i > 0) {
tx = GET_QUEUE(sc->txqueue, struct txqueue,
@ -3019,7 +3025,7 @@ fatm_attach(device_t dev)
}
}
utopia_attach(&sc->utopia, &sc->ifatm, &sc->media, &sc->mtx,
utopia_attach(&sc->utopia, IFP2IFATM(sc->ifp), &sc->media, &sc->mtx,
&sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree),
&fatm_utopia_methods);
sc->utopia.flags |= UTP_FL_NORESET | UTP_FL_POLL_CARRIER;

View File

@ -185,7 +185,7 @@ struct card_vcc {
* Finally the softc structure
*/
struct fatm_softc {
struct ifatm ifatm; /* common part */
struct ifnet *ifp; /* common part */
struct mtx mtx; /* lock this structure */
struct ifmedia media; /* media */

View File

@ -86,6 +86,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_dl.h>
#include <net/if_mib.h>
#include <net/if_media.h>
#include <net/if_types.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
@ -427,8 +428,8 @@ fe_read_eeprom_jli (struct fe_softc * sc, u_char * data)
int i;
data -= JLI_EEPROM_SIZE;
for (i = 0; i < JLI_EEPROM_SIZE; i += 16) {
printf("%s: EEPROM(JLI):%3x: %16D\n",
sc->sc_xname, i, data + i, " ");
if_printf(sc->ifp,
"EEPROM(JLI):%3x: %16D\n", i, data + i, " ");
}
}
#endif
@ -543,8 +544,8 @@ fe_read_eeprom_ssi (struct fe_softc *sc, u_char *data)
int i;
data -= SSI_EEPROM_SIZE;
for (i = 0; i < SSI_EEPROM_SIZE; i += 16) {
printf("%s: EEPROM(SSI):%3x: %16D\n",
sc->sc_xname, i, data + i, " ");
if_printf(sc->ifp,
"EEPROM(SSI):%3x: %16D\n", i, data + i, " ");
}
}
#endif
@ -645,8 +646,8 @@ fe_read_eeprom_lnx (struct fe_softc *sc, u_char *data)
this board was not a TDK/LANX) or not working
properly. */
if (bootverbose) {
printf("%s: no ACK received from EEPROM(LNX)\n",
sc->sc_xname);
if_printf(sc->ifp,
"no ACK received from EEPROM(LNX)\n");
}
/* Clear the given buffer to indicate we could not get
any info. and return. */
@ -684,8 +685,8 @@ fe_read_eeprom_lnx (struct fe_softc *sc, u_char *data)
if (bootverbose) {
data -= LNX_EEPROM_SIZE;
for (i = 0; i < LNX_EEPROM_SIZE; i += 16) {
printf("%s: EEPROM(LNX):%3x: %16D\n",
sc->sc_xname, i, data + i, " ");
if_printf(sc->ifp,
"EEPROM(LNX):%3x: %16D\n", i, data + i, " ");
}
}
#endif
@ -729,8 +730,15 @@ int
fe_attach (device_t dev)
{
struct fe_softc *sc = device_get_softc(dev);
struct ifnet *ifp;
int flags = device_get_flags(dev);
int b, error;
ifp = sc->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not ifalloc\n");
return (ENOSPC);
}
error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
fe_intr, sc, &sc->irq_handle);
@ -742,14 +750,14 @@ fe_attach (device_t dev)
/*
* Initialize ifnet structure
*/
sc->sc_if.if_softc = sc;
if_initname(&sc->sc_if, device_get_name(dev), device_get_unit(dev));
sc->sc_if.if_start = fe_start;
sc->sc_if.if_ioctl = fe_ioctl;
sc->sc_if.if_watchdog = fe_watchdog;
sc->sc_if.if_init = fe_init;
sc->sc_if.if_linkmib = &sc->mibdata;
sc->sc_if.if_linkmiblen = sizeof (sc->mibdata);
ifp->if_softc = sc;
if_initname(sc->ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_start = fe_start;
ifp->if_ioctl = fe_ioctl;
ifp->if_watchdog = fe_watchdog;
ifp->if_init = fe_init;
ifp->if_linkmib = &sc->mibdata;
ifp->if_linkmiblen = sizeof (sc->mibdata);
#if 0 /* I'm not sure... */
sc->mibdata.dot3Compliance = DOT3COMPLIANCE_COLLS;
@ -758,7 +766,7 @@ fe_attach (device_t dev)
/*
* Set fixed interface flags.
*/
sc->sc_if.if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
IFF_NEEDSGIANT;
#if 1
@ -772,8 +780,8 @@ fe_attach (device_t dev)
* since it must be a common workaround for all network drivers.
* FIXME.
*/
if (sc->sc_if.if_snd.ifq_maxlen == 0)
sc->sc_if.if_snd.ifq_maxlen = ifqmaxlen;
if (ifp->if_snd.ifq_maxlen == 0)
ifp->if_snd.ifq_maxlen = ifqmaxlen;
#endif
#if FE_SINGLE_TRANSMISSION
@ -794,8 +802,8 @@ fe_attach (device_t dev)
default:
/* Oops, we can't work with single buffer configuration. */
if (bootverbose) {
printf("%s: strange TXBSIZ config; fixing\n",
sc->sc_xname);
if_printf(sc->ifp,
"strange TXBSIZ config; fixing\n");
}
sc->proto_dlcr6 &= ~FE_D6_TXBSIZ;
sc->proto_dlcr6 |= FE_D6_TXBSIZ_2x2KB;
@ -821,7 +829,7 @@ fe_attach (device_t dev)
#endif
/* Attach and stop the interface. */
ether_ifattach(&sc->sc_if, sc->arpcom.ac_enaddr);
ether_ifattach(sc->ifp, sc->enaddr);
fe_stop(sc);
/* Print additional info when attached. */
@ -927,12 +935,12 @@ static void
fe_reset (struct fe_softc *sc)
{
/* Record how many packets are lost by this accident. */
sc->sc_if.if_oerrors += sc->txb_sched + sc->txb_count;
sc->ifp->if_oerrors += sc->txb_sched + sc->txb_count;
sc->mibdata.dot3StatsInternalMacTransmitErrors++;
/* Put the interface into known initial state. */
fe_stop(sc);
if (sc->sc_if.if_flags & IFF_UP)
if (sc->ifp->if_flags & IFF_UP)
fe_init(sc);
}
@ -968,8 +976,8 @@ fe_stop (struct fe_softc *sc)
DELAY(200);
/* Reset transmitter variables and interface flags. */
sc->sc_if.if_flags &= ~(IFF_OACTIVE | IFF_RUNNING);
sc->sc_if.if_timer = 0;
sc->ifp->if_flags &= ~(IFF_OACTIVE | IFF_RUNNING);
sc->ifp->if_timer = 0;
sc->txb_free = sc->txb_size;
sc->txb_count = 0;
sc->txb_sched = 0;
@ -991,13 +999,13 @@ fe_stop (struct fe_softc *sc)
static void
fe_watchdog ( struct ifnet *ifp )
{
struct fe_softc *sc = (struct fe_softc *)ifp;
struct fe_softc *sc = ifp->if_softc;
/* A "debug" message. */
if_printf(ifp, "transmission timeout (%d+%d)%s\n",
sc->txb_sched, sc->txb_count,
(ifp->if_flags & IFF_UP) ? "" : " when down");
if (sc->sc_if.if_opackets == 0 && sc->sc_if.if_ipackets == 0)
if (sc->ifp->if_opackets == 0 && sc->ifp->if_ipackets == 0)
if_printf(ifp, "wrong IRQ setting in config?\n");
fe_reset(sc);
}
@ -1034,7 +1042,7 @@ fe_init (void * xsc)
DELAY(200);
/* Feed the station address. */
fe_outblk(sc, FE_DLCR8, sc->sc_enaddr, ETHER_ADDR_LEN);
fe_outblk(sc, FE_DLCR8, IFP2ENADDR(sc->ifp), ETHER_ADDR_LEN);
/* Clear multicast address filter to receive nothing. */
fe_outb(sc, FE_DLCR7,
@ -1091,8 +1099,8 @@ fe_init (void * xsc)
* The following message helps discovering the fact. FIXME.
*/
if (!(fe_inb(sc, FE_DLCR5) & FE_D5_BUFEMP)) {
printf("%s: receive buffer has some data after reset\n",
sc->sc_xname);
if_printf(sc->ifp,
"receive buffer has some data after reset\n");
fe_emptybuffer(sc);
}
@ -1102,7 +1110,7 @@ fe_init (void * xsc)
#endif
/* Set 'running' flag, because we are now running. */
sc->sc_if.if_flags |= IFF_RUNNING;
sc->ifp->if_flags |= IFF_RUNNING;
/*
* At this point, the interface is running properly,
@ -1119,7 +1127,7 @@ fe_init (void * xsc)
the interface keeping it idle. The upper layer will soon
start the interface anyway, and there are no significant
delay. */
fe_start(&sc->sc_if);
fe_start(sc->ifp);
#endif
(void) splx(s);
@ -1136,7 +1144,7 @@ fe_xmit (struct fe_softc *sc)
* We use longer timeout for multiple packet transmission.
* I'm not sure this timer value is appropriate. FIXME.
*/
sc->sc_if.if_timer = 1 + sc->txb_count;
sc->ifp->if_timer = 1 + sc->txb_count;
/* Update txb variables. */
sc->txb_sched = sc->txb_count;
@ -1253,7 +1261,7 @@ fe_start (struct ifnet *ifp)
/*
* Get the next mbuf chain for a packet to send.
*/
IF_DEQUEUE(&sc->sc_if.if_snd, m);
IF_DEQUEUE(&sc->ifp->if_snd, m);
if (m == NULL) {
/* No more packets to send. */
goto indicate_inactive;
@ -1276,8 +1284,8 @@ fe_start (struct ifnet *ifp)
* and only if it is in "receive everything"
* mode.)
*/
if (!(sc->sc_if.if_flags & IFF_PROMISC))
BPF_MTAP(&sc->sc_if, m);
if (!(sc->ifp->if_flags & IFF_PROMISC))
BPF_MTAP(sc->ifp, m);
m_freem(m);
}
@ -1292,7 +1300,7 @@ fe_start (struct ifnet *ifp)
* filled all the buffers with data then we still
* want to accept more.
*/
sc->sc_if.if_flags &= ~IFF_OACTIVE;
sc->ifp->if_flags &= ~IFF_OACTIVE;
return;
indicate_active:
@ -1300,7 +1308,7 @@ fe_start (struct ifnet *ifp)
* The transmitter is active, and there are no room for
* more outgoing packets in the transmission buffer.
*/
sc->sc_if.if_flags |= IFF_OACTIVE;
sc->ifp->if_flags |= IFF_OACTIVE;
return;
}
@ -1359,7 +1367,7 @@ fe_emptybuffer (struct fe_softc * sc)
u_char saved_dlcr5;
#ifdef FE_DEBUG
printf("%s: emptying receive buffer\n", sc->sc_xname);
if_printf(sc->ifp, "emptying receive buffer\n");
#endif
/*
@ -1395,7 +1403,8 @@ fe_emptybuffer (struct fe_softc * sc)
* Double check.
*/
if (fe_inb(sc, FE_DLCR5) & FE_D5_BUFEMP) {
printf("%s: could not empty receive buffer\n", sc->sc_xname);
if_printf(sc->ifp,
"could not empty receive buffer\n");
/* Hmm. What should I do if this happens? FIXME. */
}
@ -1426,8 +1435,8 @@ fe_tint (struct fe_softc * sc, u_char tstat)
* are left unsent in transmission buffer.
*/
left = fe_inb(sc, FE_BMPR10);
printf("%s: excessive collision (%d/%d)\n",
sc->sc_xname, left, sc->txb_sched);
if_printf(sc->ifp, "excessive collision (%d/%d)\n",
left, sc->txb_sched);
/*
* Clear the collision flag (in 86960) here
@ -1499,7 +1508,7 @@ fe_tint (struct fe_softc * sc, u_char tstat)
*/
col = 1;
}
sc->sc_if.if_collisions += col;
sc->ifp->if_collisions += col;
if (col == 1)
sc->mibdata.dot3StatsSingleCollisionFrames++;
else
@ -1512,9 +1521,9 @@ fe_tint (struct fe_softc * sc, u_char tstat)
* Be sure to reflect number of excessive collisions.
*/
col = sc->tx_excolls;
sc->sc_if.if_opackets += sc->txb_sched - col;
sc->sc_if.if_oerrors += col;
sc->sc_if.if_collisions += col * 16;
sc->ifp->if_opackets += sc->txb_sched - col;
sc->ifp->if_oerrors += col;
sc->ifp->if_collisions += col * 16;
sc->mibdata.dot3StatsExcessiveCollisions += col;
sc->mibdata.dot3StatsCollFrequencies[15] += col;
sc->txb_sched = 0;
@ -1523,8 +1532,8 @@ fe_tint (struct fe_softc * sc, u_char tstat)
* The transmitter is no more active.
* Reset output active flag and watchdog timer.
*/
sc->sc_if.if_flags &= ~IFF_OACTIVE;
sc->sc_if.if_timer = 0;
sc->ifp->if_flags &= ~IFF_OACTIVE;
sc->ifp->if_timer = 0;
/*
* If more data is ready to transmit in the buffer, start
@ -1571,7 +1580,7 @@ fe_rint (struct fe_softc * sc, u_char rstat)
if (rstat & FE_D1_SRTPKT)
sc->mibdata.dot3StatsFrameTooShorts++; /* :-) */
#endif
sc->sc_if.if_ierrors++;
sc->ifp->if_ierrors++;
}
/*
@ -1629,8 +1638,9 @@ fe_rint (struct fe_softc * sc, u_char rstat)
if ((status & 0xF0) != 0x20 ||
len > ETHER_MAX_LEN - ETHER_CRC_LEN ||
len < ETHER_MIN_LEN - ETHER_CRC_LEN) {
printf("%s: RX buffer out-of-sync\n", sc->sc_xname);
sc->sc_if.if_ierrors++;
if_printf(sc->ifp,
"RX buffer out-of-sync\n");
sc->ifp->if_ierrors++;
sc->mibdata.dot3StatsInternalMacReceiveErrors++;
fe_reset(sc);
return;
@ -1647,19 +1657,19 @@ fe_rint (struct fe_softc * sc, u_char rstat)
* in the buffer. We hope we can get more
* mbuf next time.
*/
sc->sc_if.if_ierrors++;
sc->ifp->if_ierrors++;
sc->mibdata.dot3StatsMissedFrames++;
fe_droppacket(sc, len);
return;
}
/* Successfully received a packet. Update stat. */
sc->sc_if.if_ipackets++;
sc->ifp->if_ipackets++;
}
/* Maximum number of frames has been received. Something
strange is happening here... */
printf("%s: unusual receive flood\n", sc->sc_xname);
if_printf(sc->ifp, "unusual receive flood\n");
sc->mibdata.dot3StatsInternalMacReceiveErrors++;
fe_reset(sc);
}
@ -1713,7 +1723,7 @@ fe_intr (void *arg)
if (sc->filter_change &&
sc->txb_count == 0 && sc->txb_sched == 0) {
fe_loadmar(sc);
sc->sc_if.if_flags &= ~IFF_OACTIVE;
sc->ifp->if_flags &= ~IFF_OACTIVE;
}
/*
@ -1729,11 +1739,11 @@ fe_intr (void *arg)
* receiver interrupts. 86960 can raise a receiver
* interrupt when the transmission buffer is full.
*/
if ((sc->sc_if.if_flags & IFF_OACTIVE) == 0)
fe_start(&sc->sc_if);
if ((sc->ifp->if_flags & IFF_OACTIVE) == 0)
fe_start(sc->ifp);
}
printf("%s: too many loops\n", sc->sc_xname);
if_printf(sc->ifp, "too many loops\n");
}
/*
@ -1756,11 +1766,11 @@ fe_ioctl (struct ifnet * ifp, u_long command, caddr_t data)
* Switch interface state between "running" and
* "stopped", reflecting the UP flag.
*/
if (sc->sc_if.if_flags & IFF_UP) {
if ((sc->sc_if.if_flags & IFF_RUNNING) == 0)
if (sc->ifp->if_flags & IFF_UP) {
if ((sc->ifp->if_flags & IFF_RUNNING) == 0)
fe_init(sc);
} else {
if ((sc->sc_if.if_flags & IFF_RUNNING) != 0)
if ((sc->ifp->if_flags & IFF_RUNNING) != 0)
fe_stop(sc);
}
@ -1806,7 +1816,7 @@ fe_ioctl (struct ifnet * ifp, u_long command, caddr_t data)
static int
fe_get_packet (struct fe_softc * sc, u_short len)
{
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->ifp;
struct ether_header *eh;
struct mbuf *m;
@ -1911,8 +1921,9 @@ fe_write_mbufs (struct fe_softc *sc, struct mbuf *m)
/* Check if this matches the one in the packet header. */
if (length != m->m_pkthdr.len) {
printf("%s: packet length mismatch? (%d/%d)\n", sc->sc_xname,
length, m->m_pkthdr.len);
if_printf(sc->ifp,
"packet length mismatch? (%d/%d)\n",
length, m->m_pkthdr.len);
}
#else
/* Just use the length value in the packet header. */
@ -1927,9 +1938,9 @@ fe_write_mbufs (struct fe_softc *sc, struct mbuf *m)
*/
if (length < ETHER_HDR_LEN ||
length > ETHER_MAX_LEN - ETHER_CRC_LEN) {
printf("%s: got an out-of-spec packet (%u bytes) to send\n",
sc->sc_xname, length);
sc->sc_if.if_oerrors++;
if_printf(sc->ifp,
"got an out-of-spec packet (%u bytes) to send\n", length);
sc->ifp->if_oerrors++;
sc->mibdata.dot3StatsInternalMacTransmitErrors++;
return;
}
@ -2049,14 +2060,14 @@ fe_mcaf ( struct fe_softc *sc )
struct ifmultiaddr *ifma;
filter = fe_filter_nothing;
TAILQ_FOREACH(ifma, &sc->arpcom.ac_if.if_multiaddrs, ifma_link) {
TAILQ_FOREACH(ifma, &sc->ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
index = ether_crc32_le(LLADDR((struct sockaddr_dl *)
ifma->ifma_addr), ETHER_ADDR_LEN) >> 26;
#ifdef FE_DEBUG
printf("%s: hash(%6D) == %d\n",
sc->sc_xname, enm->enm_addrlo , ":", index);
if_printf(sc->ifp, "hash(%6D) == %d\n",
enm->enm_addrlo , ":", index);
#endif
filter.data[index >> 3] |= 1 << (index & 7);
@ -2071,7 +2082,7 @@ fe_mcaf ( struct fe_softc *sc )
static void
fe_setmode (struct fe_softc *sc)
{
int flags = sc->sc_if.if_flags;
int flags = sc->ifp->if_flags;
/*
* If the interface is not running, we postpone the update
@ -2198,8 +2209,9 @@ fe_medchange (struct ifnet *ifp)
if (bit2media[b] == sc->media.ifm_media) break;
}
if (((1 << b) & sc->mbitmap) == 0) {
printf("%s: got an unsupported media request (0x%x)\n",
sc->sc_xname, sc->media.ifm_media);
if_printf(sc->ifp,
"got an unsupported media request (0x%x)\n",
sc->media.ifm_media);
return EINVAL;
}
#endif
@ -2209,7 +2221,7 @@ fe_medchange (struct ifnet *ifp)
until the transmission buffer being empty? Changing the
media when we are sending a frame will cause two garbages
on wires, one on old media and another on new. FIXME */
if (sc->sc_if.if_flags & IFF_UP) {
if (sc->ifp->if_flags & IFF_UP) {
if (sc->msel) sc->msel(sc);
}

View File

@ -251,8 +251,8 @@ fe_probe_fmv(device_t dev)
/* Get our station address from EEPROM, and make sure it is
Fujitsu's. */
fe_inblk(sc, FE_FMV4, sc->sc_enaddr, ETHER_ADDR_LEN);
if (!fe_valid_Ether_p(sc->sc_enaddr, 0x00000E))
fe_inblk(sc, FE_FMV4, sc->enaddr, ETHER_ADDR_LEN);
if (!fe_valid_Ether_p(sc->enaddr, 0x00000E))
return ENXIO;
/* Find the supported media and "hardware revision" to know
@ -386,8 +386,8 @@ fe_probe_jli_ati(struct fe_softc * sc, u_char const * eeprom)
/* Get our station address from EEPROM, and make sure the
EEPROM contains ATI's address. */
bcopy(eeprom + 8, sc->sc_enaddr, ETHER_ADDR_LEN);
if (!fe_valid_Ether_p(sc->sc_enaddr, 0x0000F4))
bcopy(eeprom + 8, sc->enaddr, ETHER_ADDR_LEN);
if (!fe_valid_Ether_p(sc->enaddr, 0x0000F4))
return NULL;
/*
@ -515,10 +515,10 @@ fe_probe_jli_icl(struct fe_softc * sc, u_char const * eeprom)
valid. Use it if it is, or use the "permanent" address instead. */
if (fe_valid_Ether_p(eeprom+4, 0x020000)) {
/* The configured address is valid. Use it. */
bcopy(eeprom+4, sc->sc_enaddr, ETHER_ADDR_LEN);
bcopy(eeprom+4, sc->enaddr, ETHER_ADDR_LEN);
} else {
/* The configured address is invalid. Use permanent. */
bcopy(eeprom+122, sc->sc_enaddr, ETHER_ADDR_LEN);
bcopy(eeprom+122, sc->enaddr, ETHER_ADDR_LEN);
}
/* Determine model and supported media. */
@ -613,15 +613,15 @@ fe_probe_jli_rex(struct fe_softc * sc, u_char const * eeprom)
/* Get our station address from EEPROM. Note that RATOC
stores it "byte-swapped" in each word. (I don't know why.)
So, we just can't use bcopy().*/
sc->sc_enaddr[0] = eeprom[3];
sc->sc_enaddr[1] = eeprom[2];
sc->sc_enaddr[2] = eeprom[5];
sc->sc_enaddr[3] = eeprom[4];
sc->sc_enaddr[4] = eeprom[7];
sc->sc_enaddr[5] = eeprom[6];
sc->enaddr[0] = eeprom[3];
sc->enaddr[1] = eeprom[2];
sc->enaddr[2] = eeprom[5];
sc->enaddr[3] = eeprom[4];
sc->enaddr[4] = eeprom[7];
sc->enaddr[5] = eeprom[6];
/* Make sure the EEPROM contains RATOC's station address. */
if (!fe_valid_Ether_p(sc->sc_enaddr, 0x00C0D0))
if (!fe_valid_Ether_p(sc->enaddr, 0x00C0D0))
return NULL;
/* I don't know any sub-model identification. */
@ -667,7 +667,7 @@ fe_probe_jli_unk(struct fe_softc * sc, u_char const * eeprom)
return NULL;
/* Extract our (guessed) station address. */
bcopy(eeprom+n, sc->sc_enaddr, ETHER_ADDR_LEN);
bcopy(eeprom+n, sc->enaddr, ETHER_ADDR_LEN);
/* We are not sure what type of board it is... */
sc->type = FE_TYPE_JLI;
@ -841,7 +841,7 @@ fe_probe_ssi(device_t dev)
/* Make sure the Ethernet (MAC) station address is of TDK's. */
if (!fe_valid_Ether_p(eeprom+FE_SSI_EEP_ADDR, 0x008098))
return ENXIO;
bcopy(eeprom + FE_SSI_EEP_ADDR, sc->sc_enaddr, ETHER_ADDR_LEN);
bcopy(eeprom + FE_SSI_EEP_ADDR, sc->enaddr, ETHER_ADDR_LEN);
/* This looks like a TDK-AX031 board. It requires an explicit
IRQ setting in config, since we currently don't know how we
@ -902,7 +902,7 @@ fe_probe_lnx(device_t dev)
/* Make sure the Ethernet (MAC) station address is of TDK/LANX's. */
if (!fe_valid_Ether_p(eeprom, 0x008098))
return ENXIO;
bcopy(eeprom, sc->sc_enaddr, ETHER_ADDR_LEN);
bcopy(eeprom, sc->enaddr, ETHER_ADDR_LEN);
/* This looks like a TDK/LANX board. It requires an
explicit IRQ setting in config. Make sure we have one,
@ -962,10 +962,10 @@ fe_probe_gwy(device_t dev)
return ENXIO;
/* Get our station address from EEPROM. */
fe_inblk(sc, 0x18, sc->sc_enaddr, ETHER_ADDR_LEN);
fe_inblk(sc, 0x18, sc->enaddr, ETHER_ADDR_LEN);
/* Make sure it is Gateway Communication's. */
if (!fe_valid_Ether_p(sc->sc_enaddr, 0x000061))
if (!fe_valid_Ether_p(sc->enaddr, 0x000061))
return ENXIO;
/* Gateway's board requires an explicit IRQ to work, since it
@ -1016,14 +1016,14 @@ fe_probe_ubn(device_t dev)
return ENXIO;
/* Get our station address form ID ROM and make sure it is UBN's. */
fe_inblk(sc, 0x18, sc->sc_enaddr, ETHER_ADDR_LEN);
if (!fe_valid_Ether_p(sc->sc_enaddr, 0x00DD01))
fe_inblk(sc, 0x18, sc->enaddr, ETHER_ADDR_LEN);
if (!fe_valid_Ether_p(sc->enaddr, 0x00DD01))
return ENXIO;
#if 0
/* Calculate checksum. */
sum = fe_inb(sc, 0x1e);
for (i = 0; i < ETHER_ADDR_LEN; i++) {
sum ^= sc->sc_enaddr[i];
sum ^= sc->enaddr[i];
}
if (sum != 0)
return ENXIO;

View File

@ -183,10 +183,11 @@ static int
fe_pccard_detach(device_t dev)
{
struct fe_softc *sc = device_get_softc(dev);
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->ifp;
fe_stop(sc);
ether_ifdetach(ifp);
if_free(ifp);
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
fe_release_resource(dev);
@ -241,10 +242,10 @@ fe_probe_mbh(device_t dev, const struct fe_pccard_product *pp)
return ENXIO;
/* Get our station address from EEPROM. */
fe_inblk(sc, FE_MBH10, sc->sc_enaddr, ETHER_ADDR_LEN);
fe_inblk(sc, FE_MBH10, sc->enaddr, ETHER_ADDR_LEN);
/* Make sure we got a valid station address. */
if (!fe_valid_Ether_p(sc->sc_enaddr, 0))
if (!fe_valid_Ether_p(sc->enaddr, 0))
return ENXIO;
/* Determine the card type. */
@ -299,10 +300,10 @@ fe_probe_tdk (device_t dev, const struct fe_pccard_product *pp)
sc->type = FE_TYPE_TDK;
sc->typestr = "Generic MB8696x/78Q837x Ethernet (PCMCIA)";
pccard_get_ether(dev, sc->sc_enaddr);
pccard_get_ether(dev, sc->enaddr);
/* Make sure we got a valid station address. */
if (!fe_valid_Ether_p(sc->sc_enaddr, 0))
if (!fe_valid_Ether_p(sc->enaddr, 0))
return ENXIO;
return 0;

View File

@ -68,8 +68,9 @@ struct fe_filter {
struct fe_softc {
/* Used by "common" codes. */
struct arpcom arpcom; /* Ethernet common */
struct ifnet *ifp;
int sc_unit;
u_char enaddr[6];
/* Used by config codes. */
int type;
@ -118,11 +119,6 @@ struct fe_softc {
};
#define sc_if arpcom.ac_if
#define sc_xname arpcom.ac_if.if_xname
#define sc_enaddr arpcom.ac_enaddr
struct fe_simple_probe_struct {
u_char port; /* Offset from the base I/O address. */
u_char mask; /* Bits to be checked. */

View File

@ -52,6 +52,7 @@
#include <net/ethernet.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <net/if_types.h>
#ifdef __DragonFly__
#include <net/vlan/if_vlan_var.h>
#include <bus/firewire/firewire.h>
@ -159,7 +160,11 @@ fwe_attach(device_t dev)
struct fwe_softc *fwe;
struct ifnet *ifp;
int unit, s;
#if defined(__DragonFly__) || __FreeBSD_version < 500000
u_char *eaddr;
#else
u_char eaddr[6];
#endif
struct fw_eui64 *eui;
fwe = ((struct fwe_softc *)device_get_softc(dev));
@ -185,7 +190,10 @@ fwe_attach(device_t dev)
/* generate fake MAC address: first and last 3bytes from eui64 */
#define LOCAL (0x02)
#define GROUP (0x01)
eaddr = &fwe->eth_softc.arpcom.ac_enaddr[0];
#if defined(__DragonFly__) || __FreeBSD_version < 500000
eaddr = &IFP2ENADDR(fwe->eth_softc.ifp)[0];
#endif
eui = &fwe->fd.fc->eui;
eaddr[0] = (FW_EUI64_BYTE(eui, 0) | LOCAL) & ~GROUP;
@ -199,7 +207,11 @@ fwe_attach(device_t dev)
eaddr[0], eaddr[1], eaddr[2], eaddr[3], eaddr[4], eaddr[5]);
/* fill the rest and attach interface */
ifp = &fwe->fwe_if;
ifp = fwe->eth_softc.ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
return (ENOSPC);
}
ifp->if_softc = &fwe->eth_softc;
#if __FreeBSD_version >= 501113 || defined(__DragonFly__)
@ -244,7 +256,7 @@ fwe_stop(struct fwe_softc *fwe)
{
struct firewire_comm *fc;
struct fw_xferq *xferq;
struct ifnet *ifp = &fwe->fwe_if;
struct ifnet *ifp = fwe->eth_softc.ifp;
struct fw_xfer *xfer, *next;
int i;
@ -284,16 +296,19 @@ static int
fwe_detach(device_t dev)
{
struct fwe_softc *fwe;
struct ifnet *ifp;
int s;
fwe = (struct fwe_softc *)device_get_softc(dev);
fwe = device_get_softc(dev);
ifp = fwe->eth_softc.ifp;
s = splimp();
fwe_stop(fwe);
#if defined(__DragonFly__) || __FreeBSD_version < 500000
ether_ifdetach(&fwe->fwe_if, 1);
ether_ifdetach(ifp, 1);
#else
ether_ifdetach(&fwe->fwe_if);
ether_ifdetach(ifp);
if_free(ifp);
#endif
splx(s);
@ -305,7 +320,7 @@ fwe_init(void *arg)
{
struct fwe_softc *fwe = ((struct fwe_eth_softc *)arg)->fwe;
struct firewire_comm *fc;
struct ifnet *ifp = &fwe->fwe_if;
struct ifnet *ifp = fwe->eth_softc.ifp;
struct fw_xferq *xferq;
struct fw_xfer *xfer;
struct mbuf *m;
@ -464,7 +479,7 @@ fwe_output_callback(struct fw_xfer *xfer)
int s;
fwe = (struct fwe_softc *)xfer->sc;
ifp = &fwe->fwe_if;
ifp = fwe->eth_softc.ifp;
/* XXX error check */
FWEDEBUG(ifp, "resp = %d\n", xfer->resp);
if (xfer->resp != 0)
@ -593,7 +608,7 @@ fwe_as_input(struct fw_xferq *xferq)
#endif
fwe = (struct fwe_softc *)xferq->sc;
ifp = &fwe->fwe_if;
ifp = fwe->eth_softc.ifp;
#if 0
FWE_POLL_REGISTER(fwe_poll, fwe, ifp);
#endif

View File

@ -45,9 +45,7 @@ struct fwe_softc {
struct fw_pkt pkt_hdr;
STAILQ_HEAD(, fw_xfer) xferlist;
struct fwe_eth_softc {
/* XXX this must be the first for if_ethersub.c */
struct arpcom arpcom; /* ethernet common data */
#define fwe_if eth_softc.arpcom.ac_if
struct ifnet *ifp;
struct fwe_softc *fwe;
} eth_softc;
};

View File

@ -55,6 +55,7 @@
#include <net/if.h>
#include <net/firewire.h>
#include <net/if_arp.h>
#include <net/if_types.h>
#ifdef __DragonFly__
#include <bus/firewire/firewire.h>
#include <bus/firewire/firewirereg.h>
@ -170,6 +171,9 @@ fwip_attach(device_t dev)
fwip = ((struct fwip_softc *)device_get_softc(dev));
unit = device_get_unit(dev);
ifp = fwip->fw_softc.fwip_ifp = if_alloc(IFT_IEEE1394);
if (ifp == NULL)
return (ENOSPC);
bzero(fwip, sizeof(struct fwip_softc));
/* XXX */
@ -188,7 +192,7 @@ fwip_attach(device_t dev)
/*
* Encode our hardware the way that arp likes it.
*/
hwaddr = &fwip->fw_softc.fwcom.fc_hwaddr;
hwaddr = &IFP2FWC(fwip->fw_softc.fwip_ifp)->fc_hwaddr;
hwaddr->sender_unique_ID_hi = htonl(fwip->fd.fc->eui.hi);
hwaddr->sender_unique_ID_lo = htonl(fwip->fd.fc->eui.lo);
hwaddr->sender_max_rec = fwip->fd.fc->maxrec;
@ -197,7 +201,6 @@ fwip_attach(device_t dev)
hwaddr->sender_unicast_FIFO_lo = htonl((uint32_t)INET_FIFO);
/* fill the rest and attach interface */
ifp = &fwip->fwip_if;
ifp->if_softc = &fwip->fw_softc;
#if __FreeBSD_version >= 501113 || defined(__DragonFly__)
@ -226,7 +229,7 @@ fwip_stop(struct fwip_softc *fwip)
{
struct firewire_comm *fc;
struct fw_xferq *xferq;
struct ifnet *ifp = &fwip->fwip_if;
struct ifnet *ifp = fwip->fw_softc.fwip_ifp;
struct fw_xfer *xfer, *next;
int i;
@ -279,7 +282,8 @@ fwip_detach(device_t dev)
s = splimp();
fwip_stop(fwip);
firewire_ifdetach(&fwip->fwip_if);
firewire_ifdetach(fwip->fw_softc.fwip_ifp);
if_free(fwip->fw_softc.fwip_ifp);
splx(s);
return 0;
@ -290,7 +294,7 @@ fwip_init(void *arg)
{
struct fwip_softc *fwip = ((struct fwip_eth_softc *)arg)->fwip;
struct firewire_comm *fc;
struct ifnet *ifp = &fwip->fwip_if;
struct ifnet *ifp = fwip->fw_softc.fwip_ifp;
struct fw_xferq *xferq;
struct fw_xfer *xfer;
struct mbuf *m;
@ -473,7 +477,7 @@ fwip_post_busreset(void *arg)
fwip->last_dest.hi = 0;
fwip->last_dest.lo = 0;
firewire_busreset(&fwip->fwip_if);
firewire_busreset(fwip->fw_softc.fwip_ifp);
}
static void
@ -486,7 +490,7 @@ fwip_output_callback(struct fw_xfer *xfer)
GIANT_REQUIRED;
fwip = (struct fwip_softc *)xfer->sc;
ifp = &fwip->fwip_if;
ifp = fwip->fw_softc.fwip_ifp;
/* XXX error check */
FWIPDEBUG(ifp, "resp = %d\n", xfer->resp);
if (xfer->resp != 0)
@ -728,7 +732,7 @@ fwip_stream_input(struct fw_xferq *xferq)
GIANT_REQUIRED;
fwip = (struct fwip_softc *)xferq->sc;
ifp = &fwip->fwip_if;
ifp = fwip->fw_softc.fwip_ifp;
#if 0
FWIP_POLL_REGISTER(fwip_poll, fwip, ifp);
#endif
@ -858,7 +862,7 @@ fwip_unicast_input(struct fw_xfer *xfer)
GIANT_REQUIRED;
fwip = (struct fwip_softc *)xfer->sc;
ifp = &fwip->fwip_if;
ifp = fwip->fw_softc.fwip_ifp;
m = xfer->mbuf;
xfer->mbuf = 0;
fp = &xfer->recv.hdr;

View File

@ -55,9 +55,7 @@ struct fwip_softc {
struct crom_chunk spec6; /* specifier description IPv6 */
struct crom_chunk ver6; /* version description IPv6 */
struct fwip_eth_softc {
/* XXX this must be the first for if_fwsubr.c */
struct fw_com fwcom; /* firewire common data */
#define fwip_if fw_softc.fwcom.fc_if
struct ifnet *fwip_ifp;
struct fwip_softc *fwip;
} fw_softc;
};

View File

@ -373,6 +373,7 @@ fxp_attach(device_t dev)
struct ifnet *ifp;
uint32_t val;
uint16_t data, myea[ETHER_ADDR_LEN / 2];
u_char eaddr[ETHER_ADDR_LEN];
int i, rid, m1, m2, prefer_iomap;
int error, s;
@ -707,12 +708,12 @@ fxp_attach(device_t dev)
* Read MAC address.
*/
fxp_read_eeprom(sc, myea, 0, 3);
sc->arpcom.ac_enaddr[0] = myea[0] & 0xff;
sc->arpcom.ac_enaddr[1] = myea[0] >> 8;
sc->arpcom.ac_enaddr[2] = myea[1] & 0xff;
sc->arpcom.ac_enaddr[3] = myea[1] >> 8;
sc->arpcom.ac_enaddr[4] = myea[2] & 0xff;
sc->arpcom.ac_enaddr[5] = myea[2] >> 8;
eaddr[0] = myea[0] & 0xff;
eaddr[1] = myea[0] >> 8;
eaddr[2] = myea[1] & 0xff;
eaddr[3] = myea[1] >> 8;
eaddr[4] = myea[2] & 0xff;
eaddr[5] = myea[2] >> 8;
if (bootverbose) {
device_printf(dev, "PCI IDs: %04x %04x %04x %04x %04x\n",
pci_get_vendor(dev), pci_get_device(dev),
@ -744,7 +745,12 @@ fxp_attach(device_t dev)
}
}
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
error = ENOSPC;
goto fail;
}
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_baudrate = 100000000;
ifp->if_init = fxp_init;
@ -772,7 +778,7 @@ fxp_attach(device_t dev)
/*
* Attach the interface.
*/
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
ether_ifattach(ifp, eaddr);
/*
* Tell the upper layer(s) we support long frames.
@ -798,14 +804,15 @@ fxp_attach(device_t dev)
fxp_intr, sc, &sc->ih);
if (error) {
device_printf(dev, "could not setup irq\n");
ether_ifdetach(&sc->arpcom.ac_if);
ether_ifdetach(sc->ifp);
goto fail;
}
fail:
splx(s);
if (error)
if (error) {
fxp_release(sc);
}
return (error);
}
@ -874,6 +881,8 @@ fxp_release(struct fxp_softc *sc)
bus_dma_tag_destroy(sc->cbl_tag);
if (sc->mcs_tag)
bus_dma_tag_destroy(sc->mcs_tag);
if (sc->ifp)
if_free(sc->ifp);
mtx_destroy(&sc->sc_mtx);
}
@ -894,7 +903,8 @@ fxp_detach(device_t dev)
/*
* Close down routes etc.
*/
ether_ifdetach(&sc->arpcom.ac_if);
ether_ifdetach(sc->ifp);
if_free(sc->ifp);
/*
* Stop DMA and drop transmit queue, but disable interrupts first.
@ -965,7 +975,7 @@ static int
fxp_resume(device_t dev)
{
struct fxp_softc *sc = device_get_softc(dev);
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->ifp;
uint16_t pci_command;
int s;
@ -1246,7 +1256,7 @@ fxp_encap(struct fxp_softc *sc, struct mbuf *m_head)
int chainlen, error, i, nseg;
FXP_LOCK_ASSERT(sc, MA_OWNED);
ifp = &sc->sc_if;
ifp = sc->ifp;
/*
* Get pointer to next available tx desc.
@ -1492,7 +1502,7 @@ static void
fxp_intr(void *xsc)
{
struct fxp_softc *sc = xsc;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->ifp;
uint8_t statack;
FXP_LOCK(sc);
@ -1735,7 +1745,7 @@ static void
fxp_tick(void *xsc)
{
struct fxp_softc *sc = xsc;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->ifp;
struct fxp_stats *sp = sc->fxp_stats;
int s;
@ -1836,7 +1846,7 @@ fxp_tick(void *xsc)
static void
fxp_stop(struct fxp_softc *sc)
{
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->ifp;
struct fxp_tx *txp;
int i;
@ -1920,7 +1930,7 @@ fxp_init(void *xsc)
static void
fxp_init_body(struct fxp_softc *sc)
{
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->ifp;
struct fxp_cb_config *cbp;
struct fxp_cb_ias *cb_ias;
struct fxp_cb_tx *tcbp;
@ -2101,8 +2111,8 @@ fxp_init_body(struct fxp_softc *sc)
cb_ias->cb_status = 0;
cb_ias->cb_command = htole16(FXP_CB_COMMAND_IAS | FXP_CB_COMMAND_EL);
cb_ias->link_addr = 0xffffffff;
bcopy(sc->arpcom.ac_enaddr, cb_ias->macaddr,
sizeof(sc->arpcom.ac_enaddr));
bcopy(IFP2ENADDR(sc->ifp), cb_ias->macaddr,
sizeof(IFP2ENADDR(sc->ifp)));
/*
* Start the IAS (Individual Address Setup) command/DMA.
@ -2464,7 +2474,7 @@ static int
fxp_mc_addrs(struct fxp_softc *sc)
{
struct fxp_cb_mcs *mcsp = sc->mcsp;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->ifp;
struct ifmultiaddr *ifma;
int nmcasts;
@ -2509,7 +2519,7 @@ static void
fxp_mc_setup(struct fxp_softc *sc)
{
struct fxp_cb_mcs *mcsp = sc->mcsp;
struct ifnet *ifp = &sc->sc_if;
struct ifnet *ifp = sc->ifp;
struct fxp_tx *txp;
int count;

View File

@ -153,7 +153,7 @@ struct fxp_desc_list {
* for functional grouping.
*/
struct fxp_softc {
struct arpcom arpcom; /* per-interface network data */
struct ifnet *ifp; /* per-interface network data */
struct resource *mem; /* resource descriptor for registers */
int rtp; /* register resource type */
int rgd; /* register descriptor in use */
@ -222,5 +222,3 @@ struct fxp_softc {
bus_space_write_2((sc)->sc_st, (sc)->sc_sh, (reg), (val))
#define CSR_WRITE_4(sc, reg, val) \
bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val))
#define sc_if arpcom.ac_if

View File

@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_arp.h>
#include <net/if_dl.h>
#include <net/if_media.h>
#include <net/if_types.h>
#include <machine/bus.h>
@ -124,11 +125,15 @@ int
gem_attach(sc)
struct gem_softc *sc;
{
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct ifnet *ifp;
struct mii_softc *child;
int i, error;
u_int32_t v;
ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL)
return (ENOSPC);
/* Make sure the chip is stopped. */
ifp->if_softc = sc;
gem_reset(sc);
@ -137,7 +142,7 @@ gem_attach(sc)
BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, GEM_NSEGS,
BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL, &sc->sc_pdmatag);
if (error)
return (error);
goto fail_ifnet;
error = bus_dma_tag_create(sc->sc_pdmatag, 1, 0,
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MAXBSIZE,
@ -301,7 +306,7 @@ gem_attach(sc)
bus_space_write_4(sc->sc_bustag, sc->sc_h, GEM_MIF_CONFIG,
sc->sc_mif_config);
/* Attach the interface. */
ether_ifattach(ifp, sc->sc_arpcom.ac_enaddr);
ether_ifattach(ifp, sc->sc_enaddr);
#if notyet
/*
@ -346,6 +351,8 @@ gem_attach(sc)
bus_dma_tag_destroy(sc->sc_rdmatag);
fail_ptag:
bus_dma_tag_destroy(sc->sc_pdmatag);
fail_ifnet:
if_free(ifp);
return (error);
}
@ -353,10 +360,11 @@ void
gem_detach(sc)
struct gem_softc *sc;
{
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct ifnet *ifp = sc->sc_ifp;
int i;
ether_ifdetach(ifp);
if_free(ifp);
gem_stop(ifp, 1);
device_delete_child(sc->sc_dev, sc->sc_miibus);
@ -385,7 +393,7 @@ void
gem_suspend(sc)
struct gem_softc *sc;
{
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct ifnet *ifp = sc->sc_ifp;
gem_stop(ifp, 0);
}
@ -394,7 +402,7 @@ void
gem_resume(sc)
struct gem_softc *sc;
{
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct ifnet *ifp = sc->sc_ifp;
if (ifp->if_flags & IFF_UP)
gem_init(ifp);
@ -847,7 +855,7 @@ gem_init(xsc)
void *xsc;
{
struct gem_softc *sc = (struct gem_softc *)xsc;
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct ifnet *ifp = sc->sc_ifp;
bus_space_tag_t t = sc->sc_bustag;
bus_space_handle_t h = sc->sc_h;
int s;
@ -866,7 +874,7 @@ gem_init(xsc)
*/
/* step 1 & 2. Reset the Ethernet Channel */
gem_stop(&sc->sc_arpcom.ac_if, 0);
gem_stop(sc->sc_ifp, 0);
gem_reset(sc);
#ifdef GEM_DEBUG
CTR1(KTR_GEM, "%s: gem_init: restarting", device_get_name(sc->sc_dev));
@ -1019,7 +1027,7 @@ gem_init_regs(sc)
{
bus_space_tag_t t = sc->sc_bustag;
bus_space_handle_t h = sc->sc_h;
const u_char *laddr = sc->sc_arpcom.ac_enaddr;
const u_char *laddr = IFP2ENADDR(sc->sc_ifp);
u_int32_t v;
/* These regs are not cleared on reset */
@ -1198,7 +1206,7 @@ static void
gem_tint(sc)
struct gem_softc *sc;
{
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct ifnet *ifp = sc->sc_ifp;
bus_space_tag_t t = sc->sc_bustag;
bus_space_handle_t mac = sc->sc_h;
struct gem_txsoft *txs;
@ -1342,7 +1350,7 @@ static void
gem_rint(sc)
struct gem_softc *sc;
{
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct ifnet *ifp = sc->sc_ifp;
bus_space_tag_t t = sc->sc_bustag;
bus_space_handle_t h = sc->sc_h;
struct gem_rxsoft *rxs;
@ -1843,7 +1851,7 @@ static void
gem_setladrf(sc)
struct gem_softc *sc;
{
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct ifnet *ifp = sc->sc_ifp;
struct ifmultiaddr *inm;
bus_space_tag_t t = sc->sc_bustag;
bus_space_handle_t h = sc->sc_h;
@ -1886,7 +1894,7 @@ gem_setladrf(sc)
/* Clear hash table */
memset(hash, 0, sizeof(hash));
TAILQ_FOREACH(inm, &sc->sc_arpcom.ac_if.if_multiaddrs, ifma_link) {
TAILQ_FOREACH(inm, &ifp->if_multiaddrs, ifma_link) {
if (inm->ifma_addr->sa_family != AF_LINK)
continue;
crc = ether_crc32_le(LLADDR((struct sockaddr_dl *)

View File

@ -195,7 +195,7 @@ gem_pci_attach(dev)
sc->sc_h = rman_get_bushandle(gsc->gsc_sres);
/* All platform that this driver is used on must provide this. */
OF_getetheraddr(dev, sc->sc_arpcom.ac_enaddr);
OF_getetheraddr(dev, sc->sc_enaddr);
/*
* call the main configure

View File

@ -123,10 +123,11 @@ struct gem_rxsoft {
* Software state per device.
*/
struct gem_softc {
struct arpcom sc_arpcom; /* arp common data */
struct ifnet *sc_ifp;
device_t sc_miibus;
struct mii_data *sc_mii; /* MII media control */
device_t sc_dev; /* generic device information */
u_char sc_enaddr[6];
struct callout sc_tick_ch; /* tick callout */
struct callout sc_rx_ch; /* delayed rx callout */

View File

@ -354,7 +354,7 @@ harp_output(Cmn_unit *cu, Cmn_vcc *cv, KBuffer *m)
sc->cmn.cu_pif.pif_oerrors++;
cv->cv_connvc->cvc_vcc->vc_oerrors++;
if (cv->cv_connvc->cvc_vcc->vc_nif)
cv->cv_connvc->cvc_vcc->vc_nif->nif_if.if_oerrors++;
ANIF2IFP(cv->cv_connvc->cvc_vcc->vc_nif)->if_oerrors++;
return;
}
@ -365,8 +365,8 @@ harp_output(Cmn_unit *cu, Cmn_vcc *cv, KBuffer *m)
cv->cv_connvc->cvc_vcc->vc_obytes += mlen;
if (cv->cv_connvc->cvc_vcc->vc_nif) {
cv->cv_connvc->cvc_vcc->vc_nif->nif_obytes += mlen;
cv->cv_connvc->cvc_vcc->vc_nif->nif_if.if_obytes += mlen;
cv->cv_connvc->cvc_vcc->vc_nif->nif_if.if_opackets++;
ANIF2IFP(cv->cv_connvc->cvc_vcc->vc_nif)->if_obytes += mlen;
ANIF2IFP(cv->cv_connvc->cvc_vcc->vc_nif)->if_opackets++;
}
}
@ -592,8 +592,8 @@ harp_input(struct ifnet *ifp, struct mbuf **mp, struct atm_pseudohdr *ah,
vcc->cv_connvc->cvc_vcc->vc_ibytes += mlen;
if (vcc->cv_connvc->cvc_vcc->vc_nif) {
vcc->cv_connvc->cvc_vcc->vc_nif->nif_ibytes += mlen;
vcc->cv_connvc->cvc_vcc->vc_nif->nif_if.if_ipackets++;
vcc->cv_connvc->cvc_vcc->vc_nif->nif_if.if_ibytes += mlen;
ANIF2IFP(vcc->cv_connvc->cvc_vcc->vc_nif)->if_ipackets++;
ANIF2IFP(vcc->cv_connvc->cvc_vcc->vc_nif)->if_ibytes += mlen;
}
/* hand it off */

View File

@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
#include <net/if.h>
#include <net/if_media.h>
#include <net/if_atm.h>
#include <net/if_types.h>
#include <net/route.h>
#ifdef ENABLE_BPF
#include <net/bpf.h>
@ -217,13 +218,13 @@ hatm_alloc_dmamem(struct hatm_softc *sc, const char *what, struct dmamem *mem)
BUS_SPACE_MAXSIZE_32BIT, BUS_DMA_ALLOCNOW,
NULL, NULL, &mem->tag);
if (error) {
if_printf(&sc->ifatm.ifnet, "DMA tag create (%s)\n", what);
if_printf(sc->ifp, "DMA tag create (%s)\n", what);
return (error);
}
error = bus_dmamem_alloc(mem->tag, &mem->base, 0, &mem->map);
if (error) {
if_printf(&sc->ifatm.ifnet, "DMA mem alloc (%s): %d\n",
if_printf(sc->ifp, "DMA mem alloc (%s): %d\n",
what, error);
bus_dma_tag_destroy(mem->tag);
mem->base = NULL;
@ -233,7 +234,7 @@ hatm_alloc_dmamem(struct hatm_softc *sc, const char *what, struct dmamem *mem)
error = bus_dmamap_load(mem->tag, mem->map, mem->base, mem->size,
dmaload_helper, &mem->paddr, BUS_DMA_NOWAIT);
if (error) {
if_printf(&sc->ifatm.ifnet, "DMA map load (%s): %d\n",
if_printf(sc->ifp, "DMA map load (%s): %d\n",
what, error);
bus_dmamem_free(mem->tag, mem->base, mem->map);
bus_dma_tag_destroy(mem->tag);
@ -316,11 +317,11 @@ hatm_destroy_smbufs(struct hatm_softc *sc)
h = (struct mbuf_chunk_hdr *) ((char *)pg +
b * pg->hdr.chunksize + pg->hdr.hdroff);
if (h->flags & MBUF_CARD)
if_printf(&sc->ifatm.ifnet,
if_printf(sc->ifp,
"%s -- mbuf page=%u card buf %u\n",
__func__, i, b);
if (h->flags & MBUF_USED)
if_printf(&sc->ifatm.ifnet,
if_printf(sc->ifp,
"%s -- mbuf page=%u used buf %u\n",
__func__, i, b);
}
@ -353,7 +354,7 @@ hatm_destroy_tpds(struct hatm_softc *sc)
DBG(sc, ATTACH, ("releasing TPDs ..."));
if (sc->tpd_nfree != sc->tpd_total)
if_printf(&sc->ifatm.ifnet, "%u tpds still in use from %u\n",
if_printf(sc->ifp, "%u tpds still in use from %u\n",
sc->tpd_total - sc->tpd_nfree, sc->tpd_total);
while ((t = SLIST_FIRST(&sc->tpd_free)) != NULL) {
SLIST_REMOVE_HEAD(&sc->tpd_free, link);
@ -477,15 +478,15 @@ hatm_destroy(struct hatm_softc *sc)
if (sc->tx_tag != NULL)
if (bus_dma_tag_destroy(sc->tx_tag))
if_printf(&sc->ifatm.ifnet, "mbuf DMA tag busy\n");
if_printf(sc->ifp, "mbuf DMA tag busy\n");
if (sc->mbuf_tag != NULL)
if (bus_dma_tag_destroy(sc->mbuf_tag))
if_printf(&sc->ifatm.ifnet, "mbuf DMA tag busy\n");
if_printf(sc->ifp, "mbuf DMA tag busy\n");
if (sc->parent_tag != NULL)
if (bus_dma_tag_destroy(sc->parent_tag))
if_printf(&sc->ifatm.ifnet, "parent DMA tag busy\n");
if_printf(sc->ifp, "parent DMA tag busy\n");
if (sc->memres != NULL)
bus_release_resource(sc->dev, SYS_RES_MEMORY,
@ -514,7 +515,7 @@ hatm_reset(struct hatm_softc *sc)
while (((v = READ4(sc, HE_REGO_RESET_CNTL)) & HE_REGM_RESET_STATE) == 0) {
BARRIER_R(sc);
if (++count == 100) {
if_printf(&sc->ifatm.ifnet, "reset failed\n");
if_printf(sc->ifp, "reset failed\n");
return (ENXIO);
}
DELAY(1000);
@ -669,12 +670,12 @@ hatm_init_read_eeprom(struct hatm_softc *sc)
while (n > 0 && sc->rev[n-1] == ' ')
n--;
sc->rev[n] = '\0';
sc->ifatm.mib.hw_version = sc->rev[0];
IFP2IFATM(sc->ifp)->mib.hw_version = sc->rev[0];
sc->ifatm.mib.serial = hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 0) << 0;
sc->ifatm.mib.serial |= hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 1) << 8;
sc->ifatm.mib.serial |= hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 2) << 16;
sc->ifatm.mib.serial |= hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 3) << 24;
IFP2IFATM(sc->ifp)->mib.serial = hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 0) << 0;
IFP2IFATM(sc->ifp)->mib.serial |= hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 1) << 8;
IFP2IFATM(sc->ifp)->mib.serial |= hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 2) << 16;
IFP2IFATM(sc->ifp)->mib.serial |= hatm_read_prom_byte(sc, HE_EEPROM_M_SN + 3) << 24;
v = hatm_read_prom_byte(sc, HE_EEPROM_MEDIA + 0) << 0;
v |= hatm_read_prom_byte(sc, HE_EEPROM_MEDIA + 1) << 8;
@ -683,41 +684,41 @@ hatm_init_read_eeprom(struct hatm_softc *sc)
switch (v) {
case HE_MEDIA_UTP155:
sc->ifatm.mib.media = IFM_ATM_UTP_155;
sc->ifatm.mib.pcr = ATM_RATE_155M;
IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_UTP_155;
IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_155M;
break;
case HE_MEDIA_MMF155:
sc->ifatm.mib.media = IFM_ATM_MM_155;
sc->ifatm.mib.pcr = ATM_RATE_155M;
IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_MM_155;
IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_155M;
break;
case HE_MEDIA_MMF622:
sc->ifatm.mib.media = IFM_ATM_MM_622;
sc->ifatm.mib.device = ATM_DEVICE_HE622;
sc->ifatm.mib.pcr = ATM_RATE_622M;
IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_MM_622;
IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_HE622;
IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_622M;
sc->he622 = 1;
break;
case HE_MEDIA_SMF155:
sc->ifatm.mib.media = IFM_ATM_SM_155;
sc->ifatm.mib.pcr = ATM_RATE_155M;
IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_SM_155;
IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_155M;
break;
case HE_MEDIA_SMF622:
sc->ifatm.mib.media = IFM_ATM_SM_622;
sc->ifatm.mib.device = ATM_DEVICE_HE622;
sc->ifatm.mib.pcr = ATM_RATE_622M;
IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_SM_622;
IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_HE622;
IFP2IFATM(sc->ifp)->mib.pcr = ATM_RATE_622M;
sc->he622 = 1;
break;
}
sc->ifatm.mib.esi[0] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 0);
sc->ifatm.mib.esi[1] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 1);
sc->ifatm.mib.esi[2] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 2);
sc->ifatm.mib.esi[3] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 3);
sc->ifatm.mib.esi[4] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 4);
sc->ifatm.mib.esi[5] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 5);
IFP2IFATM(sc->ifp)->mib.esi[0] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 0);
IFP2IFATM(sc->ifp)->mib.esi[1] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 1);
IFP2IFATM(sc->ifp)->mib.esi[2] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 2);
IFP2IFATM(sc->ifp)->mib.esi[3] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 3);
IFP2IFATM(sc->ifp)->mib.esi[4] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 4);
IFP2IFATM(sc->ifp)->mib.esi[5] = hatm_read_prom_byte(sc, HE_EEPROM_MAC + 5);
}
/*
@ -781,18 +782,18 @@ hatm_init_cm(struct hatm_softc *sc)
numbuffs = sc->r0_numbuffs + sc->r1_numbuffs + sc->tx_numbuffs;
rsra = 0;
mlbm = ((rsra + sc->ifatm.mib.max_vccs * 8) + 0x7ff) & ~0x7ff;
mlbm = ((rsra + IFP2IFATM(sc->ifp)->mib.max_vccs * 8) + 0x7ff) & ~0x7ff;
rabr = ((mlbm + numbuffs * 2) + 0x7ff) & ~0x7ff;
sc->rsrb = ((rabr + 2048) + (2 * sc->ifatm.mib.max_vccs - 1)) &
~(2 * sc->ifatm.mib.max_vccs - 1);
sc->rsrb = ((rabr + 2048) + (2 * IFP2IFATM(sc->ifp)->mib.max_vccs - 1)) &
~(2 * IFP2IFATM(sc->ifp)->mib.max_vccs - 1);
tsra = 0;
sc->tsrb = tsra + sc->ifatm.mib.max_vccs * 8;
sc->tsrc = sc->tsrb + sc->ifatm.mib.max_vccs * 4;
sc->tsrd = sc->tsrc + sc->ifatm.mib.max_vccs * 2;
tabr = sc->tsrd + sc->ifatm.mib.max_vccs * 1;
mtpd = ((tabr + 1024) + (16 * sc->ifatm.mib.max_vccs - 1)) &
~(16 * sc->ifatm.mib.max_vccs - 1);
sc->tsrb = tsra + IFP2IFATM(sc->ifp)->mib.max_vccs * 8;
sc->tsrc = sc->tsrb + IFP2IFATM(sc->ifp)->mib.max_vccs * 4;
sc->tsrd = sc->tsrc + IFP2IFATM(sc->ifp)->mib.max_vccs * 2;
tabr = sc->tsrd + IFP2IFATM(sc->ifp)->mib.max_vccs * 1;
mtpd = ((tabr + 1024) + (16 * IFP2IFATM(sc->ifp)->mib.max_vccs - 1)) &
~(16 * IFP2IFATM(sc->ifp)->mib.max_vccs - 1);
DBG(sc, ATTACH, ("rsra=%x mlbm=%x rabr=%x rsrb=%x",
rsra, mlbm, rabr, sc->rsrb));
@ -1322,7 +1323,7 @@ kenv_getuint(struct hatm_softc *sc, const char *var,
return (EINVAL);
}
if (bootverbose)
if_printf(&sc->ifatm.ifnet, "%s=%u\n", full, u);
if_printf(sc->ifp, "%s=%u\n", full, u);
*ptr = u;
return (0);
}
@ -1629,7 +1630,8 @@ hatm_detach(device_t dev)
}
mtx_unlock(&sc->mtx);
atm_ifdetach(&sc->ifatm.ifnet);
atm_ifdetach(sc->ifp);
if_free(sc->ifp);
hatm_destroy(sc);
@ -1650,18 +1652,25 @@ hatm_attach(device_t dev)
sc = device_get_softc(dev);
ifp = sc->ifp = if_alloc(IFT_ATM);
if (ifp == NULL) {
device_printf(dev, "could not if_alloc()\n");
error = ENOSPC;
goto failed;
}
sc->dev = dev;
sc->ifatm.mib.device = ATM_DEVICE_HE155;
sc->ifatm.mib.serial = 0;
sc->ifatm.mib.hw_version = 0;
sc->ifatm.mib.sw_version = 0;
sc->ifatm.mib.vpi_bits = HE_CONFIG_VPI_BITS;
sc->ifatm.mib.vci_bits = HE_CONFIG_VCI_BITS;
sc->ifatm.mib.max_vpcs = 0;
sc->ifatm.mib.max_vccs = HE_MAX_VCCS;
sc->ifatm.mib.media = IFM_ATM_UNKNOWN;
IFP2IFATM(sc->ifp)->mib.device = ATM_DEVICE_HE155;
IFP2IFATM(sc->ifp)->mib.serial = 0;
IFP2IFATM(sc->ifp)->mib.hw_version = 0;
IFP2IFATM(sc->ifp)->mib.sw_version = 0;
IFP2IFATM(sc->ifp)->mib.vpi_bits = HE_CONFIG_VPI_BITS;
IFP2IFATM(sc->ifp)->mib.vci_bits = HE_CONFIG_VCI_BITS;
IFP2IFATM(sc->ifp)->mib.max_vpcs = 0;
IFP2IFATM(sc->ifp)->mib.max_vccs = HE_MAX_VCCS;
IFP2IFATM(sc->ifp)->mib.media = IFM_ATM_UNKNOWN;
sc->he622 = 0;
sc->ifatm.phy = &sc->utopia;
IFP2IFATM(sc->ifp)->phy = &sc->utopia;
SLIST_INIT(&sc->tpd_free);
@ -1761,7 +1770,6 @@ hatm_attach(device_t dev)
goto failed;
}
ifp = &sc->ifatm.ifnet;
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
@ -1922,7 +1930,7 @@ hatm_attach(device_t dev)
ifp->if_watchdog = NULL;
ifp->if_init = hatm_init;
utopia_attach(&sc->utopia, &sc->ifatm, &sc->media, &sc->mtx,
utopia_attach(&sc->utopia, IFP2IFATM(sc->ifp), &sc->media, &sc->mtx,
&sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree),
&hatm_utopia_methods);
utopia_init_media(&sc->utopia);
@ -1966,17 +1974,17 @@ hatm_initialize(struct hatm_softc *sc)
u_int cid;
static const u_int layout[2][7] = HE_CONFIG_MEM_LAYOUT;
if (sc->ifatm.ifnet.if_flags & IFF_RUNNING)
if (sc->ifp->if_flags & IFF_RUNNING)
return;
hatm_init_bus_width(sc);
hatm_init_endianess(sc);
if_printf(&sc->ifatm.ifnet, "%s, Rev. %s, S/N %u, "
if_printf(sc->ifp, "%s, Rev. %s, S/N %u, "
"MAC=%02x:%02x:%02x:%02x:%02x:%02x (%ubit PCI)\n",
sc->prod_id, sc->rev, sc->ifatm.mib.serial,
sc->ifatm.mib.esi[0], sc->ifatm.mib.esi[1], sc->ifatm.mib.esi[2],
sc->ifatm.mib.esi[3], sc->ifatm.mib.esi[4], sc->ifatm.mib.esi[5],
sc->prod_id, sc->rev, IFP2IFATM(sc->ifp)->mib.serial,
IFP2IFATM(sc->ifp)->mib.esi[0], IFP2IFATM(sc->ifp)->mib.esi[1], IFP2IFATM(sc->ifp)->mib.esi[2],
IFP2IFATM(sc->ifp)->mib.esi[3], IFP2IFATM(sc->ifp)->mib.esi[4], IFP2IFATM(sc->ifp)->mib.esi[5],
sc->pci64 ? 64 : 32);
/*
@ -2119,22 +2127,22 @@ hatm_initialize(struct hatm_softc *sc)
if (sc->he622) {
WRITE4(sc, HE_REGO_RCCONFIG,
(8 << HE_REGS_RCCONFIG_UTDELAY) |
(sc->ifatm.mib.vpi_bits << HE_REGS_RCCONFIG_VP) |
(sc->ifatm.mib.vci_bits << HE_REGS_RCCONFIG_VC));
(IFP2IFATM(sc->ifp)->mib.vpi_bits << HE_REGS_RCCONFIG_VP) |
(IFP2IFATM(sc->ifp)->mib.vci_bits << HE_REGS_RCCONFIG_VC));
WRITE4(sc, HE_REGO_TXCONFIG,
(32 << HE_REGS_TXCONFIG_THRESH) |
(sc->ifatm.mib.vci_bits << HE_REGS_TXCONFIG_VCI_MASK) |
(IFP2IFATM(sc->ifp)->mib.vci_bits << HE_REGS_TXCONFIG_VCI_MASK) |
(sc->tx_numbuffs << HE_REGS_TXCONFIG_LBFREE));
} else {
WRITE4(sc, HE_REGO_RCCONFIG,
(0 << HE_REGS_RCCONFIG_UTDELAY) |
HE_REGM_RCCONFIG_UT_MODE |
(sc->ifatm.mib.vpi_bits << HE_REGS_RCCONFIG_VP) |
(sc->ifatm.mib.vci_bits << HE_REGS_RCCONFIG_VC));
(IFP2IFATM(sc->ifp)->mib.vpi_bits << HE_REGS_RCCONFIG_VP) |
(IFP2IFATM(sc->ifp)->mib.vci_bits << HE_REGS_RCCONFIG_VC));
WRITE4(sc, HE_REGO_TXCONFIG,
(32 << HE_REGS_TXCONFIG_THRESH) |
HE_REGM_TXCONFIG_UTMODE |
(sc->ifatm.mib.vci_bits << HE_REGS_TXCONFIG_VCI_MASK) |
(IFP2IFATM(sc->ifp)->mib.vci_bits << HE_REGS_TXCONFIG_VCI_MASK) |
(sc->tx_numbuffs << HE_REGS_TXCONFIG_LBFREE));
}
@ -2236,8 +2244,8 @@ hatm_initialize(struct hatm_softc *sc)
v |= HE_PCIM_CTL0_INIT_ENB | HE_PCIM_CTL0_INT_PROC_ENB;
pci_write_config(sc->dev, HE_PCIR_GEN_CNTL_0, v, 4);
sc->ifatm.ifnet.if_flags |= IFF_RUNNING;
sc->ifatm.ifnet.if_baudrate = 53 * 8 * sc->ifatm.mib.pcr;
sc->ifp->if_flags |= IFF_RUNNING;
sc->ifp->if_baudrate = 53 * 8 * IFP2IFATM(sc->ifp)->mib.pcr;
sc->utopia.flags &= ~UTP_FL_POLL_CARRIER;
@ -2246,7 +2254,7 @@ hatm_initialize(struct hatm_softc *sc)
if (sc->vccs[cid] != NULL)
hatm_load_vc(sc, cid, 1);
ATMEV_SEND_IFSTATE_CHANGED(&sc->ifatm,
ATMEV_SEND_IFSTATE_CHANGED(IFP2IFATM(sc->ifp),
sc->utopia.carrier == UTP_CARR_OK);
}
@ -2264,11 +2272,11 @@ hatm_stop(struct hatm_softc *sc)
mtx_assert(&sc->mtx, MA_OWNED);
if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING))
if (!(sc->ifp->if_flags & IFF_RUNNING))
return;
sc->ifatm.ifnet.if_flags &= ~IFF_RUNNING;
sc->ifp->if_flags &= ~IFF_RUNNING;
ATMEV_SEND_IFSTATE_CHANGED(&sc->ifatm,
ATMEV_SEND_IFSTATE_CHANGED(IFP2IFATM(sc->ifp),
sc->utopia.carrier == UTP_CARR_OK);
sc->utopia.flags |= UTP_FL_POLL_CARRIER;

View File

@ -203,7 +203,7 @@ hatm_mbuf_page_alloc(struct hatm_softc *sc, u_int group)
err = bus_dmamap_create(sc->mbuf_tag, 0, &pg->hdr.map);
if (err != 0) {
if_printf(&sc->ifatm.ifnet, "%s -- bus_dmamap_create: %d\n",
if_printf(sc->ifp, "%s -- bus_dmamap_create: %d\n",
__func__, err);
free(pg, M_DEVBUF);
return;
@ -211,7 +211,7 @@ hatm_mbuf_page_alloc(struct hatm_softc *sc, u_int group)
err = bus_dmamap_load(sc->mbuf_tag, pg->hdr.map, pg, MBUF_ALLOC_SIZE,
hatm_extbuf_helper, &pg->hdr.phys, BUS_DMA_NOWAIT);
if (err != 0) {
if_printf(&sc->ifatm.ifnet, "%s -- mbuf mapping failed %d\n",
if_printf(sc->ifp, "%s -- mbuf mapping failed %d\n",
__func__, err);
bus_dmamap_destroy(sc->mbuf_tag, pg->hdr.map);
free(pg, M_DEVBUF);
@ -329,7 +329,7 @@ he_intr_rbp(struct hatm_softc *sc, struct herbp *rbp, u_int large,
/* allocate the MBUF */
if ((m = m_getcl(M_DONTWAIT, MT_DATA,
M_PKTHDR)) == NULL) {
if_printf(&sc->ifatm.ifnet,
if_printf(sc->ifp,
"no mbuf clusters\n");
break;
}
@ -534,7 +534,7 @@ hatm_intr(void *p)
/* if we have a stray interrupt with a non-initialized card,
* we cannot even lock before looking at the flag */
if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING))
if (!(sc->ifp->if_flags & IFF_RUNNING))
return;
mtx_lock(&sc->mtx);
@ -590,7 +590,7 @@ hatm_intr(void *p)
break;
default:
if_printf(&sc->ifatm.ifnet, "bad INTR RBPS%u\n",
if_printf(sc->ifp, "bad INTR RBPS%u\n",
status & HE_REGM_IGROUP);
break;
}
@ -605,7 +605,7 @@ hatm_intr(void *p)
break;
default:
if_printf(&sc->ifatm.ifnet, "bad INTR RBPL%u\n",
if_printf(sc->ifp, "bad INTR RBPL%u\n",
status & HE_REGM_IGROUP);
break;
}
@ -628,7 +628,7 @@ hatm_intr(void *p)
/* FALLTHRU */
default:
if_printf(&sc->ifatm.ifnet, "bad INTR RBRQ%u\n",
if_printf(sc->ifp, "bad INTR RBRQ%u\n",
status & HE_REGM_IGROUP);
break;
}
@ -651,7 +651,7 @@ hatm_intr(void *p)
/* FALLTHRU */
default:
if_printf(&sc->ifatm.ifnet, "bad INTR RBRQT%u\n",
if_printf(sc->ifp, "bad INTR RBRQT%u\n",
status & HE_REGM_IGROUP);
break;
}
@ -665,7 +665,7 @@ hatm_intr(void *p)
#if HE_REGM_ITYPE_UNKNOWN != HE_REGM_ITYPE_INVALID
case HE_REGM_ITYPE_UNKNOWN:
sc->istats.itype_unknown++;
if_printf(&sc->ifatm.ifnet, "bad interrupt\n");
if_printf(sc->ifp, "bad interrupt\n");
break;
#endif
@ -674,17 +674,17 @@ hatm_intr(void *p)
switch (status) {
case HE_REGM_ITYPE_PERR:
if_printf(&sc->ifatm.ifnet, "parity error\n");
if_printf(sc->ifp, "parity error\n");
break;
case HE_REGM_ITYPE_ABORT:
if_printf(&sc->ifatm.ifnet, "abort interrupt "
if_printf(sc->ifp, "abort interrupt "
"addr=0x%08x\n",
READ4(sc, HE_REGO_ABORT_ADDR));
break;
default:
if_printf(&sc->ifatm.ifnet,
if_printf(sc->ifp,
"bad interrupt type %08x\n", status);
break;
}
@ -706,7 +706,7 @@ hatm_intr(void *p)
break;
default:
if_printf(&sc->ifatm.ifnet, "bad interrupt type %08x\n",
if_printf(sc->ifp, "bad interrupt type %08x\n",
status);
break;
}

View File

@ -116,7 +116,7 @@ hatm_open_vcc(struct hatm_softc *sc, struct atmio_openvcc *arg)
return (ENOMEM);
mtx_lock(&sc->mtx);
if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
if (!(sc->ifp->if_flags & IFF_RUNNING)) {
error = EIO;
goto done;
}
@ -188,7 +188,7 @@ hatm_load_vc(struct hatm_softc *sc, u_int cid, int reopen)
/* inform management about non-NG and NG-PVCs */
if (!(vcc->param.flags & ATMIO_FLAG_NG) ||
(vcc->param.flags & ATMIO_FLAG_PVC))
ATMEV_SEND_VCC_CHANGED(&sc->ifatm, vcc->param.vpi,
ATMEV_SEND_VCC_CHANGED(IFP2IFATM(sc->ifp), vcc->param.vpi,
vcc->param.vci, 1);
}
@ -203,7 +203,7 @@ hatm_vcc_closed(struct hatm_softc *sc, u_int cid)
/* inform management about non-NG and NG-PVCs */
if (!(vcc->param.flags & ATMIO_FLAG_NG) ||
(vcc->param.flags & ATMIO_FLAG_PVC))
ATMEV_SEND_VCC_CHANGED(&sc->ifatm, HE_VPI(cid), HE_VCI(cid), 0);
ATMEV_SEND_VCC_CHANGED(IFP2IFATM(sc->ifp), HE_VPI(cid), HE_VCI(cid), 0);
sc->open_vccs--;
uma_zfree(sc->vcc_zone, vcc);
@ -230,7 +230,7 @@ hatm_close_vcc(struct hatm_softc *sc, struct atmio_closevcc *arg)
mtx_lock(&sc->mtx);
vcc = sc->vccs[cid];
if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
if (!(sc->ifp->if_flags & IFF_RUNNING)) {
error = EIO;
goto done;
}
@ -248,11 +248,11 @@ hatm_close_vcc(struct hatm_softc *sc, struct atmio_closevcc *arg)
if (vcc->param.flags & ATMIO_FLAG_ASYNC)
goto done;
while ((sc->ifatm.ifnet.if_flags & IFF_RUNNING) &&
while ((sc->ifp->if_flags & IFF_RUNNING) &&
(vcc->vflags & (HE_VCC_TX_CLOSING | HE_VCC_RX_CLOSING)))
cv_wait(&sc->vcc_cv, &sc->mtx);
if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) {
if (!(sc->ifp->if_flags & IFF_RUNNING)) {
error = EIO;
goto done;
}

View File

@ -130,7 +130,7 @@ hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0,
vcc->chain = vcc->last = m0;
vcc->last->m_next = NULL;
vcc->chain->m_pkthdr.len = m0->m_len;
vcc->chain->m_pkthdr.rcvif = &sc->ifatm.ifnet;
vcc->chain->m_pkthdr.rcvif = sc->ifp;
} else {
sc->istats.rx_seg++;
@ -148,7 +148,7 @@ hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0,
m_freem(vcc->chain);
vcc->chain = vcc->last = NULL;
sc->istats.crc_error++;
sc->ifatm.ifnet.if_ierrors++;
sc->ifp->if_ierrors++;
return;
}
if (flags & HE_REGM_RBRQ_LEN_ERROR) {
@ -156,7 +156,7 @@ hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0,
m_freem(vcc->chain);
vcc->chain = vcc->last = NULL;
sc->istats.len_error++;
sc->ifatm.ifnet.if_ierrors++;
sc->ifp->if_ierrors++;
return;
}
@ -229,7 +229,7 @@ hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0,
if (!(vcc->param.flags & ATMIO_FLAG_NG) &&
(vcc->param.aal == ATMIO_AAL_5) &&
(vcc->param.flags & ATM_PH_LLCSNAP))
BPF_MTAP(&sc->ifatm.ifnet, m);
BPF_MTAP(sc->ifp, m);
#endif
vpi = HE_VPI(cid);
@ -239,9 +239,9 @@ hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0,
ATM_PH_VPI(&aph) = vpi;
ATM_PH_SETVCI(&aph, vci);
sc->ifatm.ifnet.if_ipackets++;
sc->ifp->if_ipackets++;
/* this is in if_atmsubr.c */
/* sc->ifatm.ifnet.if_ibytes += len; */
/* sc->ifp->if_ibytes += len; */
vcc->ibytes += len;
vcc->ipackets++;
@ -260,7 +260,7 @@ hatm_rx(struct hatm_softc *sc, u_int cid, u_int flags, struct mbuf *m0,
}
#endif
atm_input(&sc->ifatm.ifnet, &aph, m, vcc->rxhand);
atm_input(sc->ifp, &aph, m, vcc->rxhand);
return;
@ -316,11 +316,11 @@ hatm_rx_vcc_close(struct hatm_softc *sc, u_int cid)
WRITE_RSR(sc, cid, 0, 0xf, 0);
v = READ4(sc, HE_REGO_RCCSTAT);
while ((sc->ifatm.ifnet.if_flags & IFF_RUNNING) &&
while ((sc->ifp->if_flags & IFF_RUNNING) &&
(READ4(sc, HE_REGO_RCCSTAT) & HE_REGM_RCCSTAT_PROG))
cv_timedwait(&sc->cv_rcclose, &sc->mtx, 1);
if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING))
if (!(sc->ifp->if_flags & IFF_RUNNING))
return;
WRITE_MBOX4(sc, HE_REGO_RCON_CLOSE, cid);

View File

@ -193,7 +193,7 @@ hatm_queue_tpds(struct hatm_softc *sc, u_int count, struct tpd **list,
sc->tpdrq.size;
if (space <= count) {
if_printf(&sc->ifatm.ifnet, "TPDRQ full\n");
if_printf(sc->ifp, "TPDRQ full\n");
sc->istats.tdprq_full++;
return (EBUSY);
}
@ -262,7 +262,7 @@ hatm_load_txbuf(void *uarg, bus_dma_segment_t *segs, int nseg,
/* ensure, we have enough TPDs (remember, we already have one) */
tpds_needed = (nseg + 2) / 3;
if (HE_CONFIG_TPD_RESERVE + tpds_needed - 1 > arg->sc->tpd_nfree) {
if_printf(&arg->sc->ifatm.ifnet, "%s -- out of TPDs (need %d, "
if_printf(arg->sc->ifp, "%s -- out of TPDs (need %d, "
"have %u)\n", __func__, tpds_needed - 1,
arg->sc->tpd_nfree + 1);
arg->error = 1;
@ -277,7 +277,7 @@ hatm_load_txbuf(void *uarg, bus_dma_segment_t *segs, int nseg,
if (arg->vcc->ntpds + tpds_needed > arg->sc->max_tpd) {
arg->sc->istats.flow_closed++;
arg->vcc->vflags |= HE_VCC_FLOW_CTRL;
ATMEV_SEND_FLOW_CONTROL(&arg->sc->ifatm,
ATMEV_SEND_FLOW_CONTROL(IFP2IFATM(arg->sc->ifp),
arg->vpi, arg->vci, 1);
arg->error = 1;
return;
@ -451,7 +451,7 @@ hatm_start(struct ifnet *ifp)
if ((tpd = hatm_alloc_tpd(sc, M_NOWAIT)) == NULL) {
hatm_free_txmbuf(sc);
m_freem(m);
sc->ifatm.ifnet.if_oerrors++;
sc->ifp->if_oerrors++;
continue;
}
tpd->cid = cid;
@ -471,7 +471,7 @@ hatm_start(struct ifnet *ifp)
tpd->mbuf = NULL;
hatm_free_txmbuf(sc);
hatm_free_tpd(sc, tpd);
sc->ifatm.ifnet.if_oerrors++;
sc->ifp->if_oerrors++;
continue;
}
arg.mbuf = m;
@ -480,20 +480,20 @@ hatm_start(struct ifnet *ifp)
}
if (error != 0) {
if_printf(&sc->ifatm.ifnet, "mbuf loaded error=%d\n",
if_printf(sc->ifp, "mbuf loaded error=%d\n",
error);
hatm_free_tpd(sc, tpd);
sc->ifatm.ifnet.if_oerrors++;
sc->ifp->if_oerrors++;
continue;
}
if (arg.error) {
hatm_free_tpd(sc, tpd);
sc->ifatm.ifnet.if_oerrors++;
sc->ifp->if_oerrors++;
continue;
}
arg.vcc->opackets++;
arg.vcc->obytes += len;
sc->ifatm.ifnet.if_opackets++;
sc->ifp->if_opackets++;
}
mtx_unlock(&sc->mtx);
}
@ -528,7 +528,7 @@ hatm_tx_complete(struct hatm_softc *sc, struct tpd *tpd, uint32_t flags)
if ((vcc->vflags & HE_VCC_FLOW_CTRL) &&
vcc->ntpds <= HE_CONFIG_TPD_FLOW_ENB) {
vcc->vflags &= ~HE_VCC_FLOW_CTRL;
ATMEV_SEND_FLOW_CONTROL(&sc->ifatm,
ATMEV_SEND_FLOW_CONTROL(IFP2IFATM(sc->ifp),
HE_VPI(tpd->cid), HE_VCI(tpd->cid), 0);
}
}
@ -569,13 +569,13 @@ hatm_tx_vcc_can_open(struct hatm_softc *sc, u_int cid, struct hevcc *vcc)
#if 0
v = READ_TSR(sc, cid, 4);
if(!(v & HE_REGM_TSR4_SESS_END)) {
if_printf(&sc->ifatm.ifnet, "cid=%#x not closed (TSR4)\n", cid);
if_printf(sc->ifp, "cid=%#x not closed (TSR4)\n", cid);
return (EBUSY);
}
#endif
v = READ_TSR(sc, cid, 0);
if((v & HE_REGM_TSR0_CONN_STATE) != 0) {
if_printf(&sc->ifatm.ifnet, "cid=%#x not closed (TSR0=%#x)\n",
if_printf(sc->ifp, "cid=%#x not closed (TSR0=%#x)\n",
cid, v);
return (EBUSY);
}

View File

@ -363,7 +363,7 @@ struct herg {
* Softc
*/
struct hatm_softc {
struct ifatm ifatm; /* common ATM stuff */
struct ifnet *ifp;
struct mtx mtx; /* lock */
struct ifmedia media; /* media */
device_t dev; /* device */

View File

@ -131,7 +131,7 @@ fore_output(cup, cvp, m)
fup->fu_stats->st_drv.drv_xm_notact++;
vcp->vc_oerrors++;
if (vcp->vc_nif)
vcp->vc_nif->nif_if.if_oerrors++;
ANIF2IFP(vcp->vc_nif)->if_oerrors++;
KB_FREEALL(m);
return;
}
@ -164,7 +164,7 @@ fore_output(cup, cvp, m)
fup->fu_pif.pif_oerrors++;
vcp->vc_oerrors++;
if (vcp->vc_nif)
vcp->vc_nif->nif_if.if_oerrors++;
ANIF2IFP(vcp->vc_nif)->if_oerrors++;
KB_FREEALL(m);
(void) splx(s);
return;
@ -185,7 +185,7 @@ fore_output(cup, cvp, m)
*/
vcp->vc_oerrors++;
if (vcp->vc_nif)
vcp->vc_nif->nif_if.if_oerrors++;
ANIF2IFP(vcp->vc_nif)->if_oerrors++;
(void) splx(s);
return;
}

View File

@ -299,7 +299,7 @@ fore_recv_drain(fup)
vcp = fvp->fv_connvc->cvc_vcc;
vcp->vc_ierrors++;
if (vcp->vc_nif)
vcp->vc_nif->nif_if.if_ierrors++;
ANIF2IFP(vcp->vc_nif)->if_ierrors++;
}
ATM_DEBUG1("fore receive error: hdr=0x%lx\n", hdr);
error = 1;
@ -451,9 +451,9 @@ fore_recv_drain(fup)
vcp->vc_ibytes += pdulen;
if (vcp->vc_nif) {
vcp->vc_nif->nif_ibytes += pdulen;
vcp->vc_nif->nif_if.if_ipackets++;
ANIF2IFP(vcp->vc_nif)->if_ipackets++;
#if (defined(BSD) && (BSD >= 199103))
vcp->vc_nif->nif_if.if_ibytes += pdulen;
ANIF2IFP(vcp->vc_nif)->if_ibytes += pdulen;
#endif
}

View File

@ -272,7 +272,7 @@ fore_xmit_drain(fup)
vcp = fvp->fv_connvc->cvc_vcc;
vcp->vc_oerrors++;
if (vcp->vc_nif)
vcp->vc_nif->nif_if.if_oerrors++;
ANIF2IFP(vcp->vc_nif)->if_oerrors++;
}
} else {
/*
@ -288,9 +288,9 @@ fore_xmit_drain(fup)
vcp->vc_obytes += len;
if (vcp->vc_nif) {
vcp->vc_nif->nif_obytes += len;
vcp->vc_nif->nif_if.if_opackets++;
ANIF2IFP(vcp->vc_nif)->if_opackets++;
#if (defined(BSD) && (BSD >= 199103))
vcp->vc_nif->nif_if.if_obytes += len;
ANIF2IFP(vcp->vc_nif)->if_obytes += len;
#endif
}
}

View File

@ -82,6 +82,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_arp.h>
#include <net/if_dl.h>
#include <net/if_media.h>
#include <net/if_types.h>
#include <net/if_vlan_var.h>
#include <netinet/in.h>
@ -105,7 +106,7 @@ static int hme_ioctl(struct ifnet *, u_long, caddr_t);
static void hme_tick(void *);
static void hme_watchdog(struct ifnet *);
static void hme_init(void *);
static void hme_init_locked(void *);
static void hme_init_locked(struct hme_softc *);
static int hme_add_rxbuf(struct hme_softc *, unsigned int, int);
static int hme_meminit(struct hme_softc *);
static int hme_mac_bitflip(struct hme_softc *, u_int32_t, u_int32_t,
@ -170,11 +171,15 @@ MODULE_DEPEND(hme, miibus, 1, 1, 1);
int
hme_config(struct hme_softc *sc)
{
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct ifnet *ifp;
struct mii_softc *child;
bus_size_t size;
int error, rdesc, tdesc, i;
ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL)
return (ENOSPC);
/*
* HME common initialization.
*
@ -214,7 +219,7 @@ hme_config(struct hme_softc *sc)
BUS_SPACE_MAXADDR, NULL, NULL, size, HME_NTXDESC + HME_NRXDESC + 1,
BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL, &sc->sc_pdmatag);
if (error)
return (error);
goto fail_ifnet;
error = bus_dma_tag_create(sc->sc_pdmatag, 2048, 0,
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, size,
@ -333,7 +338,7 @@ hme_config(struct hme_softc *sc)
}
/* Attach the interface. */
ether_ifattach(ifp, sc->sc_arpcom.ac_enaddr);
ether_ifattach(ifp, sc->sc_enaddr);
/*
* Tell the upper layer(s) we support long frames/checksum offloads.
@ -368,18 +373,21 @@ hme_config(struct hme_softc *sc)
bus_dma_tag_destroy(sc->sc_cdmatag);
fail_ptag:
bus_dma_tag_destroy(sc->sc_pdmatag);
fail_ifnet:
if_free(ifp);
return (error);
}
void
hme_detach(struct hme_softc *sc)
{
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct ifnet *ifp = sc->sc_ifp;
int i;
HME_LOCK_ASSERT(sc, MA_NOTOWNED);
ether_ifdetach(ifp);
if_free(ifp);
HME_LOCK(sc);
hme_stop(sc);
HME_UNLOCK(sc);
@ -416,11 +424,11 @@ hme_suspend(struct hme_softc *sc)
void
hme_resume(struct hme_softc *sc)
{
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct ifnet *ifp = sc->sc_ifp;
HME_LOCK(sc);
if ((ifp->if_flags & IFF_UP) != 0)
hme_init_locked(ifp);
hme_init_locked(sc);
HME_UNLOCK(sc);
}
@ -682,10 +690,9 @@ hme_init(void *xsc)
}
static void
hme_init_locked(void *xsc)
hme_init_locked(struct hme_softc *sc)
{
struct hme_softc *sc = (struct hme_softc *)xsc;
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct ifnet *ifp = sc->sc_ifp;
u_int8_t *ea;
u_int32_t n, v;
@ -722,7 +729,7 @@ hme_init_locked(void *xsc)
HME_MAC_WRITE_4(sc, HME_MACI_TXSIZE, HME_MAX_FRAMESIZE);
/* Load station MAC address */
ea = sc->sc_arpcom.ac_enaddr;
ea = IFP2ENADDR(sc->sc_ifp);
HME_MAC_WRITE_4(sc, HME_MACI_MACADDR0, (ea[0] << 8) | ea[1]);
HME_MAC_WRITE_4(sc, HME_MACI_MACADDR1, (ea[2] << 8) | ea[3]);
HME_MAC_WRITE_4(sc, HME_MACI_MACADDR2, (ea[4] << 8) | ea[5]);
@ -1041,7 +1048,7 @@ hme_load_txmbuf(struct hme_softc *sc, struct mbuf *m0)
static void
hme_read(struct hme_softc *sc, int ix, int len, u_int32_t flags)
{
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct ifnet *ifp = sc->sc_ifp;
struct mbuf *m;
if (len <= sizeof(struct ether_header) ||
@ -1139,7 +1146,7 @@ hme_start_locked(struct ifnet *ifp)
static void
hme_tint(struct hme_softc *sc)
{
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct ifnet *ifp = sc->sc_ifp;
struct hme_txdesc *htx;
unsigned int ri, txflags;
@ -1282,7 +1289,7 @@ static void
hme_rint(struct hme_softc *sc)
{
caddr_t xdr = sc->sc_rb.rb_rxd;
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct ifnet *ifp = sc->sc_ifp;
unsigned int ri, len;
int progress = 0;
u_int32_t flags;
@ -1619,7 +1626,7 @@ hme_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
static void
hme_setladrf(struct hme_softc *sc, int reenable)
{
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
struct ifnet *ifp = sc->sc_ifp;
struct ifmultiaddr *inm;
u_int32_t crc;
u_int32_t hash[4];
@ -1672,7 +1679,7 @@ hme_setladrf(struct hme_softc *sc, int reenable)
* the word.
*/
TAILQ_FOREACH(inm, &sc->sc_arpcom.ac_if.if_multiaddrs, ifma_link) {
TAILQ_FOREACH(inm, &sc->sc_ifp->if_multiaddrs, ifma_link) {
if (inm->ifma_addr->sa_family != AF_LINK)
continue;
crc = ether_crc32_le(LLADDR((struct sockaddr_dl *)

View File

@ -222,7 +222,7 @@ hme_pci_attach(device_t dev)
&sc->sc_mifh);
#if defined(__powerpc__) || defined(__sparc64__)
OF_getetheraddr(dev, sc->sc_arpcom.ac_enaddr);
OF_getetheraddr(dev, sc->sc_enaddr);
#else
/*
* Dig out VPD (vital product data) and read NA (network address).
@ -329,7 +329,7 @@ hme_pci_attach(device_t dev)
error = ENXIO;
goto fail_rres;
}
bcopy(buf + 3 + sizeof(struct pci_vpd), sc->sc_arpcom.ac_enaddr,
bcopy(buf + 3 + sizeof(struct pci_vpd), sc->sc_enaddr,
ETHER_ADDR_LEN);
fail_rres:

View File

@ -247,7 +247,7 @@ hme_sbus_attach(device_t dev)
goto fail_mif_res;
}
OF_getetheraddr(dev, sc->sc_arpcom.ac_enaddr);
OF_getetheraddr(dev, sc->sc_enaddr);
burst = sbus_get_burstsz(dev);
/* Translate into plain numerical format */

View File

@ -108,11 +108,12 @@ struct hme_ring {
};
struct hme_softc {
struct arpcom sc_arpcom;
struct ifnet *sc_ifp;
struct ifmedia sc_ifmedia;
device_t sc_dev;
device_t sc_miibus;
struct mii_data *sc_mii; /* MII media control */
u_char sc_enaddr[6];
struct callout sc_tick_ch; /* tick callout */
/* The following bus handles are to be provided by the bus front-end */

View File

@ -1556,7 +1556,7 @@ idt_queue_put(CONNECTION * connection, struct mbuf * m)
return (1);
}
m->m_nextpkt = NULL;
m->m_pkthdr.rcvif = (struct ifnet *) connection;
m->m_pkthdr.rcvif = (void *) connection;
s = splimp();
@ -1599,7 +1599,7 @@ idt_queue_flush(CONNECTION * connection)
m0 = &txqueue->mget;
m1 = *m0;
while (m1 != NULL) {
if (m1->m_pkthdr.rcvif == (struct ifnet *) connection) {
if (m1->m_pkthdr.rcvif == (void *) connection) {
*m0 = m1->m_nextpkt;
m_freem(m1);
m1 = *m0;

View File

@ -266,7 +266,11 @@ ie_attach(device_t dev)
int factor;
sc = device_get_softc(dev);
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(sc->dev, "can not if_alloc()\n");
return (ENOSPC);
}
sc->dev = dev;
sc->unit = device_get_unit(dev);
@ -290,8 +294,10 @@ ie_attach(device_t dev)
sc->rframes = (volatile struct ie_recv_frame_desc **) malloc(allocsize,
M_DEVBUF,
M_NOWAIT);
if (sc->rframes == NULL)
if (sc->rframes == NULL) {
if_free(ifp);
return (ENXIO);
}
sc->rbuffs =
(volatile struct ie_recv_buf_desc **)&sc->rframes[sc->nframes];
sc->cbuffs = (volatile u_char **)&sc->rbuffs[sc->nrxbufs];
@ -319,7 +325,7 @@ ie_attach(device_t dev)
EVENTHANDLER_REGISTER(shutdown_post_sync, ee16_shutdown,
sc, SHUTDOWN_PRI_DEFAULT);
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
ether_ifattach(ifp, sc->enaddr);
return (0);
}
@ -417,9 +423,9 @@ ierint(struct ie_softc *sc)
status = sc->rframes[i]->ie_fd_status;
if ((status & IE_FD_COMPLETE) && (status & IE_FD_OK)) {
sc->arpcom.ac_if.if_ipackets++;
sc->ifp->if_ipackets++;
if (!--timesthru) {
sc->arpcom.ac_if.if_ierrors +=
sc->ifp->if_ierrors +=
sc->scb->ie_err_crc +
sc->scb->ie_err_align +
sc->scb->ie_err_resource +
@ -459,32 +465,32 @@ ietint(struct ie_softc *sc)
int status;
int i;
sc->arpcom.ac_if.if_timer = 0;
sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
sc->ifp->if_timer = 0;
sc->ifp->if_flags &= ~IFF_OACTIVE;
for (i = 0; i < sc->xmit_count; i++) {
status = sc->xmit_cmds[i]->ie_xmit_status;
if (status & IE_XS_LATECOLL) {
printf("ie%d: late collision\n", sc->unit);
sc->arpcom.ac_if.if_collisions++;
sc->arpcom.ac_if.if_oerrors++;
sc->ifp->if_collisions++;
sc->ifp->if_oerrors++;
} else if (status & IE_XS_NOCARRIER) {
printf("ie%d: no carrier\n", sc->unit);
sc->arpcom.ac_if.if_oerrors++;
sc->ifp->if_oerrors++;
} else if (status & IE_XS_LOSTCTS) {
printf("ie%d: lost CTS\n", sc->unit);
sc->arpcom.ac_if.if_oerrors++;
sc->ifp->if_oerrors++;
} else if (status & IE_XS_UNDERRUN) {
printf("ie%d: DMA underrun\n", sc->unit);
sc->arpcom.ac_if.if_oerrors++;
sc->ifp->if_oerrors++;
} else if (status & IE_XS_EXCMAX) {
printf("ie%d: too many collisions\n", sc->unit);
sc->arpcom.ac_if.if_collisions += 16;
sc->arpcom.ac_if.if_oerrors++;
sc->ifp->if_collisions += 16;
sc->ifp->if_oerrors++;
} else {
sc->arpcom.ac_if.if_opackets++;
sc->arpcom.ac_if.if_collisions += status & IE_XS_MAXCOLL;
sc->ifp->if_opackets++;
sc->ifp->if_collisions += status & IE_XS_MAXCOLL;
}
}
sc->xmit_count = 0;
@ -501,7 +507,7 @@ ietint(struct ie_softc *sc)
/* Wish I knew why this seems to be necessary... */
sc->xmit_cmds[0]->ie_xmit_status |= IE_STAT_COMPL;
iestart(&sc->arpcom.ac_if);
iestart(sc->ifp);
return (0); /* shouldn't be necessary */
}
@ -529,7 +535,7 @@ iernr(struct ie_softc *sc)
#endif
ie_ack(sc, IE_ST_WHENCE);
sc->arpcom.ac_if.if_ierrors++;
sc->ifp->if_ierrors++;
return (0);
}
@ -593,7 +599,7 @@ check_eh(struct ie_softc *sc, struct ether_header *eh)
return (1);
/* Always accept packets directed at us */
if (ether_equal(eh->ether_dhost, sc->arpcom.ac_enaddr))
if (ether_equal(eh->ether_dhost, IFP2ENADDR(sc->ifp)))
return (1);
/* Must have IFF_ALLMULTI but not IFF_PROMISC set. The chip is
@ -678,7 +684,7 @@ ieget(struct ie_softc *sc, struct mbuf **mp)
*/
if (!check_eh(sc, &eh)) {
ie_drop_packet_buffer(sc);
sc->arpcom.ac_if.if_ierrors--; /* just this case, it's not an
sc->ifp->if_ierrors--; /* just this case, it's not an
* error
*/
return (-1);
@ -692,7 +698,7 @@ ieget(struct ie_softc *sc, struct mbuf **mp)
}
*mp = m;
m->m_pkthdr.rcvif = &sc->arpcom.ac_if;
m->m_pkthdr.rcvif = sc->ifp;
m->m_len = MHLEN;
resid = m->m_pkthdr.len = totlen;
top = 0;
@ -827,7 +833,7 @@ ieget(struct ie_softc *sc, struct mbuf **mp)
static void
ie_readframe(struct ie_softc *sc, int num/* frame number to read */)
{
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->ifp;
struct ie_recv_frame_desc rfd;
struct mbuf *m = 0;
#ifdef DEBUG
@ -849,7 +855,7 @@ ie_readframe(struct ie_softc *sc, int num/* frame number to read */)
if (rfd.ie_fd_status & IE_FD_OK) {
if (ieget(sc, &m)) {
sc->arpcom.ac_if.if_ierrors++; /* this counts as an
sc->ifp->if_ierrors++; /* this counts as an
* error */
return;
}
@ -927,7 +933,7 @@ iestart(struct ifnet *ifp)
return;
do {
IF_DEQUEUE(&sc->arpcom.ac_if.if_snd, m);
IF_DEQUEUE(&sc->ifp->if_snd, m);
if (!m)
break;
@ -947,7 +953,7 @@ iestart(struct ifnet *ifp)
* See if bpf is listening on this interface, let it see the
* packet before we commit it to the wire.
*/
BPF_TAP(&sc->arpcom.ac_if,
BPF_TAP(sc->ifp,
(void *)sc->xmit_cbuffs[sc->xmit_count], len);
sc->xmit_buffs[sc->xmit_count]->ie_xmit_flags =
@ -1231,8 +1237,8 @@ iereset(struct ie_softc *sc)
int s = splimp();
printf("ie%d: reset\n", sc->unit);
sc->arpcom.ac_if.if_flags &= ~IFF_UP;
ieioctl(&sc->arpcom.ac_if, SIOCSIFFLAGS, 0);
sc->ifp->if_flags &= ~IFF_UP;
ieioctl(sc->ifp, SIOCSIFFLAGS, 0);
/*
* Stop i82586 dead in its tracks.
@ -1248,8 +1254,8 @@ iereset(struct ie_softc *sc)
panic("ie disappeared!");
#endif
sc->arpcom.ac_if.if_flags |= IFF_UP;
ieioctl(&sc->arpcom.ac_if, SIOCSIFFLAGS, 0);
sc->ifp->if_flags |= IFF_UP;
ieioctl(sc->ifp, SIOCSIFFLAGS, 0);
splx(s);
return;
@ -1524,7 +1530,7 @@ ieinit(xsc)
cmd->com.ie_cmd_cmd = IE_CMD_IASETUP | IE_CMD_LAST;
cmd->com.ie_cmd_link = 0xffff;
bcopy((volatile char *)sc->arpcom.ac_enaddr,
bcopy((volatile char *)IFP2ENADDR(sc->ifp),
(volatile char *)&cmd->ie_address, sizeof cmd->ie_address);
scb->ie_command_list = MK_16(MEM(sc), cmd);
if (command_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL)
@ -1595,9 +1601,9 @@ ieinit(xsc)
ee16_interrupt_enable(sc);
ee16_chan_attn(sc);
}
sc->arpcom.ac_if.if_flags |= IFF_RUNNING; /* tell higher levels
sc->ifp->if_flags |= IFF_RUNNING; /* tell higher levels
* we're here */
sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
sc->ifp->if_flags &= ~IFF_OACTIVE;
start_receiver(sc);
@ -1670,14 +1676,14 @@ ie_mc_reset(struct ie_softc *sc)
* Step through the list of addresses.
*/
sc->mcast_count = 0;
TAILQ_FOREACH(ifma, &sc->arpcom.ac_if.if_multiaddrs, ifma_link) {
TAILQ_FOREACH(ifma, &sc->ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
/* XXX - this is broken... */
if (sc->mcast_count >= MAXMCAST) {
sc->arpcom.ac_if.if_flags |= IFF_ALLMULTI;
ieioctl(&sc->arpcom.ac_if, SIOCSIFFLAGS, (void *) 0);
sc->ifp->if_flags |= IFF_ALLMULTI;
ieioctl(sc->ifp, SIOCSIFFLAGS, (void *) 0);
goto setflag;
}
bcopy(LLADDR((struct sockaddr_dl *) ifma->ifma_addr),
@ -1780,7 +1786,7 @@ ie_detach (device_t dev)
struct ifnet * ifp;
sc = device_get_softc(dev);
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
if (sc->hard_type == IE_EE16)
ee16_shutdown(sc, 0);
@ -1788,6 +1794,7 @@ ie_detach (device_t dev)
ie_stop(sc);
ifp->if_flags &= ~IFF_RUNNING;
ether_ifdetach(ifp);
if_free(ifp);
ie_release_resources(dev);
return (0);

View File

@ -259,7 +259,7 @@ ie_isa_3C507_attach (device_t dev)
goto bad;
}
sl_read_ether(sc, sc->arpcom.ac_enaddr);
sl_read_ether(sc, sc->enaddr);
/* Clear the interrupt latch just in case. */
outb(PORT(sc) + IE507_ICTRL, 1);
@ -526,14 +526,14 @@ ie_isa_ee16_attach (device_t dev)
* the softc for use by the 586 setup code.
*/
eaddrtemp = ie_ee16_hw_read_eeprom(PORT(sc), IEE16_EEPROM_ENET_HIGH);
sc->arpcom.ac_enaddr[1] = eaddrtemp & 0xFF;
sc->arpcom.ac_enaddr[0] = eaddrtemp >> 8;
sc->enaddr[1] = eaddrtemp & 0xFF;
sc->enaddr[0] = eaddrtemp >> 8;
eaddrtemp = ie_ee16_hw_read_eeprom(PORT(sc), IEE16_EEPROM_ENET_MID);
sc->arpcom.ac_enaddr[3] = eaddrtemp & 0xFF;
sc->arpcom.ac_enaddr[2] = eaddrtemp >> 8;
sc->enaddr[3] = eaddrtemp & 0xFF;
sc->enaddr[2] = eaddrtemp >> 8;
eaddrtemp = ie_ee16_hw_read_eeprom(PORT(sc), IEE16_EEPROM_ENET_LOW);
sc->arpcom.ac_enaddr[5] = eaddrtemp & 0xFF;
sc->arpcom.ac_enaddr[4] = eaddrtemp >> 8;
sc->enaddr[5] = eaddrtemp & 0xFF;
sc->enaddr[4] = eaddrtemp >> 8;
/* disable the board interrupts */
outb(PORT(sc) + IEE16_IRQ, sc->irq_encoded);
@ -757,7 +757,7 @@ ie_isa_sl_attach (device_t dev)
case IE_STARLAN10:
case IE_SLFIBER:
case IE_NI5210:
sl_read_ether(sc, sc->arpcom.ac_enaddr);
sl_read_ether(sc, sc->enaddr);
break;
default:
if (bootverbose)

View File

@ -17,12 +17,13 @@ enum ie_hardware {
* Ethernet status, per interface.
*/
struct ie_softc {
struct arpcom arpcom;
struct ifnet *ifp;
void (*ie_reset_586) (struct ie_softc *);
void (*ie_chan_attn) (struct ie_softc *);
enum ie_hardware hard_type;
int hard_vers;
int unit;
u_char enaddr[6];
device_t dev;

View File

@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_media.h>
#include <net/if_types.h>
#include <net/route.h>
#include <net/bpf.h>
@ -232,7 +233,7 @@ ndis_setmulti(sc)
int len, mclistsz, error;
uint8_t *mclist;
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
if (!NDIS_INITIALIZED(sc))
return;
@ -307,7 +308,7 @@ ndis_set_offload(sc)
struct ifnet *ifp;
int len, error;
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
if (!NDIS_INITIALIZED(sc))
return(EINVAL);
@ -369,7 +370,7 @@ ndis_probe_offload(sc)
struct ifnet *ifp;
int len, error, dummy;
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
len = sizeof(dummy);
error = ndis_get_info(sc, OID_TCP_TASK_OFFLOAD, &dummy, &len);
@ -557,8 +558,6 @@ ndis_attach(dev)
len = sizeof(eaddr);
ndis_get_info(sc, OID_802_3_CURRENT_ADDRESS, &eaddr, &len);
bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
/*
* Figure out if we're allowed to use multipacket sends
* with this driver, and if so, how many.
@ -613,7 +612,11 @@ ndis_attach(dev)
/* Check for task offload support. */
ndis_probe_offload(sc);
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
error = ENOSPC;
goto fail;
}
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_mtu = ETHERMTU;
@ -867,7 +870,7 @@ ndis_detach(dev)
KASSERT(mtx_initialized(&sc->ndis_mtx),
("ndis mutex not initialized"));
NDIS_LOCK(sc);
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
ifp->if_flags &= ~IFF_UP;
if (device_is_attached(dev)) {
@ -879,6 +882,8 @@ ndis_detach(dev)
ether_ifdetach(ifp);
} else
NDIS_UNLOCK(sc);
if (ifp != NULL)
if_free(ifp);
bus_generic_detach(dev);
@ -945,7 +950,7 @@ ndis_suspend(dev)
struct ifnet *ifp;
sc = device_get_softc(dev);
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
#ifdef notdef
if (NDIS_INITIALIZED(sc))
@ -963,7 +968,7 @@ ndis_resume(dev)
struct ifnet *ifp;
sc = device_get_softc(dev);
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
if (NDIS_INITIALIZED(sc))
ndis_init(sc);
@ -1087,7 +1092,7 @@ ndis_rxeof_xfr(dpc, adapter, sysarg1, sysarg2)
block = adapter;
sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
KeAcquireSpinLockAtDpcLevel(&block->nmb_lock);
@ -1152,7 +1157,7 @@ ndis_rxeof_xfr_done(adapter, packet, status, len)
block = adapter;
sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
m = packet->np_m0;
IoFreeMdl(packet->np_private.npp_head);
@ -1205,7 +1210,7 @@ ndis_rxeof(adapter, packets, pktcnt)
block = (ndis_miniport_block *)adapter;
sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
for (i = 0; i < pktcnt; i++) {
p = packets[i];
@ -1283,7 +1288,7 @@ ndis_txeof(adapter, packet, status)
block = (ndis_miniport_block *)adapter;
sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
m = packet->np_m0;
idx = packet->np_txidx;
@ -1339,7 +1344,7 @@ ndis_linksts_done(adapter)
block = adapter;
sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
if (!NDIS_INITIALIZED(sc))
return;
@ -1372,7 +1377,7 @@ ndis_intr(arg)
ndis_miniport_interrupt *intr;
sc = arg;
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
intr = sc->ndis_block->nmb_interrupt;
if (intr == NULL || sc->ndis_block->nmb_miniportadapterctx == NULL)
@ -1450,8 +1455,8 @@ ndis_ticktask(w, xsc)
ndis_getstate_80211(sc);
NDIS_LOCK(sc);
#ifdef LINK_STATE_UP
sc->arpcom.ac_if.if_link_state = LINK_STATE_UP;
rt_ifmsg(&(sc->arpcom.ac_if));
sc->ifp->if_link_state = LINK_STATE_UP;
rt_ifmsg(sc->ifp);
#endif /* LINK_STATE_UP */
}
@ -1459,8 +1464,8 @@ ndis_ticktask(w, xsc)
device_printf(sc->ndis_dev, "link down\n");
sc->ndis_link = 0;
#ifdef LINK_STATE_DOWN
sc->arpcom.ac_if.if_link_state = LINK_STATE_DOWN;
rt_ifmsg(&(sc->arpcom.ac_if));
sc->ifp->if_link_state = LINK_STATE_DOWN;
rt_ifmsg(sc->ifp);
#endif /* LINK_STATE_DOWN */
}
@ -1665,7 +1670,7 @@ ndis_init(xsc)
void *xsc;
{
struct ndis_softc *sc = xsc;
struct ifnet *ifp = &sc->arpcom.ac_if;
struct ifnet *ifp = sc->ifp;
int i, error;
/*
@ -1824,7 +1829,7 @@ ndis_setstate_80211(sc)
struct ifnet *ifp;
ic = &sc->ic;
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
if (!NDIS_INITIALIZED(sc))
return;
@ -2125,7 +2130,7 @@ ndis_getstate_80211(sc)
struct ifnet *ifp;
ic = &sc->ic;
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
if (!NDIS_INITIALIZED(sc))
return;
@ -2986,7 +2991,7 @@ ndis_stop(sc)
{
struct ifnet *ifp;
ifp = &sc->arpcom.ac_if;
ifp = sc->ifp;
untimeout(ndis_tick, sc, sc->ndis_stat_ch);
NDIS_LOCK(sc);

View File

@ -69,11 +69,8 @@ TAILQ_HEAD(nch, ndis_cfglist);
(x)->ndis_txidx = ((x)->ndis_txidx + 1) % (x)->ndis_maxpkts
struct ndis_softc {
struct arpcom arpcom;
struct ifnet *ifp;
struct ieee80211com ic; /* interface info */
#ifdef notdef
struct ieee80211com arpcom; /* interface info */
#endif
struct ifmedia ifmedia; /* media info */
u_long ndis_hwassist;
uint32_t ndis_v4tx;

View File

@ -70,7 +70,7 @@ __FBSDID("$FreeBSD$");
#define ICMTU 1500 /* default mtu */
struct ic_softc {
struct ifnet ic_if;
struct ifnet *ic_ifp;
u_char ic_addr; /* peer I2C address */
@ -129,7 +129,12 @@ static int
icattach(device_t dev)
{
struct ic_softc *sc = (struct ic_softc *)device_get_softc(dev);
struct ifnet *ifp = &sc->ic_if;
struct ifnet *ifp;
ifp = sc->ic_ifp = if_alloc(IFT_PARA);
if (ifp == NULL) {
return (ENOSPC);
}
sc->ic_addr = PCF_MASTER_ADDRESS; /* XXX only PCF masters */
@ -140,7 +145,6 @@ icattach(device_t dev)
IFF_NEEDSGIANT;
ifp->if_ioctl = icioctl;
ifp->if_output = icoutput;
ifp->if_type = IFT_PARA;
ifp->if_hdrlen = 0;
ifp->if_addrlen = 0;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
@ -192,14 +196,14 @@ icioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
if ((error = iicbus_request_bus(parent, icdev, IIC_WAIT|IIC_INTR)))
return (error);
sc->ic_obuf = malloc(sc->ic_if.if_mtu + ICHDRLEN,
sc->ic_obuf = malloc(sc->ic_ifp->if_mtu + ICHDRLEN,
M_DEVBUF, M_WAITOK);
if (!sc->ic_obuf) {
iicbus_release_bus(parent, icdev);
return ENOBUFS;
}
sc->ic_ifbuf = malloc(sc->ic_if.if_mtu + ICHDRLEN,
sc->ic_ifbuf = malloc(sc->ic_ifp->if_mtu + ICHDRLEN,
M_DEVBUF, M_WAITOK);
if (!sc->ic_ifbuf) {
iicbus_release_bus(parent, icdev);
@ -245,11 +249,11 @@ icioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
if (optr)
free(optr,M_DEVBUF);
sc->ic_if.if_mtu = ifr->ifr_mtu;
sc->ic_ifp->if_mtu = ifr->ifr_mtu;
break;
case SIOCGIFMTU:
ifr->ifr_mtu = sc->ic_if.if_mtu;
ifr->ifr_mtu = sc->ic_ifp->if_mtu;
break;
case SIOCADDMULTI:
@ -308,12 +312,12 @@ icintr (device_t dev, int event, char *ptr)
goto err;
len -= ICHDRLEN;
sc->ic_if.if_ipackets ++;
sc->ic_if.if_ibytes += len;
sc->ic_ifp->if_ipackets ++;
sc->ic_ifp->if_ibytes += len;
BPF_TAP(&sc->ic_if, sc->ic_ifbuf, len + ICHDRLEN);
BPF_TAP(sc->ic_ifp, sc->ic_ifbuf, len + ICHDRLEN);
top = m_devget(sc->ic_ifbuf + ICHDRLEN, len, 0, &sc->ic_if, 0);
top = m_devget(sc->ic_ifbuf + ICHDRLEN, len, 0, sc->ic_ifp, 0);
if (top)
netisr_dispatch(NETISR_IP, top);
@ -323,12 +327,12 @@ icintr (device_t dev, int event, char *ptr)
printf("ic%d: errors (%d)!\n", unit, sc->ic_iferrs);
sc->ic_iferrs = 0; /* reset error count */
sc->ic_if.if_ierrors ++;
sc->ic_ifp->if_ierrors ++;
break;
case INTR_RECEIVE:
if (sc->ic_xfercnt >= sc->ic_if.if_mtu+ICHDRLEN) {
if (sc->ic_xfercnt >= sc->ic_ifp->if_mtu+ICHDRLEN) {
sc->ic_iferrs ++;
} else {
@ -389,7 +393,7 @@ icoutput(struct ifnet *ifp, struct mbuf *m,
len = 0;
mm = m;
do {
if (len + mm->m_len > sc->ic_if.if_mtu) {
if (len + mm->m_len > sc->ic_ifp->if_mtu) {
/* packet to large */
ifp->if_oerrors ++;
goto error;

View File

@ -214,7 +214,7 @@ static int
ipw_attach(device_t dev)
{
struct ipw_softc *sc = device_get_softc(dev);
struct ifnet *ifp = &sc->sc_arp.ac_if;
struct ifnet *ifp;
struct ieee80211com *ic = &sc->sc_ic;
uint16_t val;
int error, i;
@ -263,7 +263,11 @@ ipw_attach(device_t dev)
device_printf(dev, "could not allocate DMA resources\n");
goto fail;
}
ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
device_printf(dev, "can not if_alloc()\n");
goto fail;
}
ifp->if_softc = sc;
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
@ -387,8 +391,11 @@ ipw_detach(device_t dev)
IPW_UNLOCK(sc);
bpfdetach(ifp);
if (ifp != NULL)
bpfdetach(ifp);
ieee80211_ifdetach(ic);
if (ifp != NULL)
if_free(ifp);
ipw_release(sc);

View File

@ -84,7 +84,7 @@ struct ipw_tx_radiotap_header {
(1 << IEEE80211_RADIOTAP_CHANNEL))
struct ipw_softc {
struct arpcom sc_arp;
struct ifnet *sc_ifp;
struct ieee80211com sc_ic;
int (*sc_newstate)(struct ieee80211com *,
enum ieee80211_state, int);

Some files were not shown because too many files have changed in this diff Show More