There is no way to enter the attach routine twice with the same softc

without a detach call in between so don't try to deal with that
possiability.

This is a diff-reduction commit for the upcoming if_xname conversion.
This commit is contained in:
brooks 2003-10-30 19:45:58 +00:00
parent e3ceb141f8
commit 6beed7c27c
6 changed files with 178 additions and 190 deletions

View File

@ -312,34 +312,32 @@ cm_attach(sc, unit)
*/
cm_stop(sc);
if (!ifp->if_name) {
ifp->if_softc = sc;
ifp->if_unit = unit;
ifp->if_name = "cm";
ifp->if_output = arc_output;
ifp->if_start = cm_start;
ifp->if_ioctl = cm_ioctl;
ifp->if_watchdog = cm_watchdog;
ifp->if_init = cm_init;
/* XXX IFQ_SET_READY(&ifp->if_snd); */
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
ifp->if_timer = 0;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX;
ifp->if_softc = sc;
ifp->if_unit = unit;
ifp->if_name = "cm";
ifp->if_output = arc_output;
ifp->if_start = cm_start;
ifp->if_ioctl = cm_ioctl;
ifp->if_watchdog = cm_watchdog;
ifp->if_init = cm_init;
/* XXX IFQ_SET_READY(&ifp->if_snd); */
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
ifp->if_timer = 0;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX;
arc_ifattach(ifp, linkaddress);
arc_ifattach(ifp, linkaddress);
#ifdef CMSOFTCOPY
sc->sc_rxcookie = softintr_establish(IPL_SOFTNET, cm_srint, sc);
sc->sc_txcookie = softintr_establish(IPL_SOFTNET,
(void (*)(void *))cm_start, ifp);
sc->sc_rxcookie = softintr_establish(IPL_SOFTNET, cm_srint, sc);
sc->sc_txcookie = softintr_establish(IPL_SOFTNET,
(void (*)(void *))cm_start, ifp);
#endif
#if __FreeBSD_version < 500000
callout_init(&sc->sc_recon_ch);
callout_init(&sc->sc_recon_ch);
#else
callout_init(&sc->sc_recon_ch, 0);
callout_init(&sc->sc_recon_ch, 0);
#endif
}
if_printf(ifp, "link addr 0x%02x (%d)\n", linkaddress, linkaddress);
return 0;

View File

@ -582,85 +582,83 @@ cs_attach(struct cs_softc *sc, int unit, int flags)
cs_stop( sc );
if (!ifp->if_name) {
ifp->if_softc=sc;
ifp->if_unit=unit;
ifp->if_name="cs";
ifp->if_output=ether_output;
ifp->if_start=cs_start;
ifp->if_ioctl=cs_ioctl;
ifp->if_watchdog=cs_watchdog;
ifp->if_init=cs_init;
ifp->if_snd.ifq_maxlen= IFQ_MAXLEN;
/*
* MIB DATA
*/
/*
ifp->if_linkmib=&sc->mibdata;
ifp->if_linkmiblen=sizeof sc->mibdata;
*/
ifp->if_softc=sc;
ifp->if_unit=unit;
ifp->if_name="cs";
ifp->if_output=ether_output;
ifp->if_start=cs_start;
ifp->if_ioctl=cs_ioctl;
ifp->if_watchdog=cs_watchdog;
ifp->if_init=cs_init;
ifp->if_snd.ifq_maxlen= IFQ_MAXLEN;
/*
* MIB DATA
*/
/*
ifp->if_linkmib=&sc->mibdata;
ifp->if_linkmiblen=sizeof sc->mibdata;
*/
ifp->if_flags=(IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST );
ifp->if_flags=(IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST );
/*
* this code still in progress (DMA support)
*
/*
* this code still in progress (DMA support)
*
sc->recv_ring=malloc(CS_DMA_BUFFER_SIZE<<1, M_DEVBUF, M_NOWAIT);
if (sc->recv_ring == NULL) {
log(LOG_ERR,CS_NAME
"%d: Couldn't allocate memory for NIC\n", unit);
return(0);
}
if ((sc->recv_ring-(sc->recv_ring & 0x1FFFF))
< (128*1024-CS_DMA_BUFFER_SIZE))
sc->recv_ring+=16*1024;
*/
sc->buffer=malloc(ETHER_MAX_LEN-ETHER_CRC_LEN,M_DEVBUF,M_NOWAIT);
if (sc->buffer == NULL) {
if_printf(ifp, "Couldn't allocate memory for NIC\n");
return(0);
}
/*
* Initialize the media structures.
*/
ifmedia_init(&sc->media, 0, cs_mediachange, cs_mediastatus);
if (sc->adapter_cnf & A_CNF_10B_T) {
ifmedia_add(&sc->media, IFM_ETHER|IFM_10_T, 0, NULL);
if (sc->chip_type != CS8900) {
ifmedia_add(&sc->media,
IFM_ETHER|IFM_10_T|IFM_FDX, 0, NULL);
ifmedia_add(&sc->media,
IFM_ETHER|IFM_10_T|IFM_HDX, 0, NULL);
}
}
if (sc->adapter_cnf & A_CNF_10B_2)
ifmedia_add(&sc->media, IFM_ETHER|IFM_10_2, 0, NULL);
if (sc->adapter_cnf & A_CNF_AUI)
ifmedia_add(&sc->media, IFM_ETHER|IFM_10_5, 0, NULL);
if (sc->adapter_cnf & A_CNF_MEDIA)
ifmedia_add(&sc->media, IFM_ETHER|IFM_AUTO, 0, NULL);
/* Set default media from EEPROM */
switch (sc->adapter_cnf & A_CNF_MEDIA_TYPE) {
case A_CNF_MEDIA_AUTO: media = IFM_ETHER|IFM_AUTO; break;
case A_CNF_MEDIA_10B_T: media = IFM_ETHER|IFM_10_T; break;
case A_CNF_MEDIA_10B_2: media = IFM_ETHER|IFM_10_2; break;
case A_CNF_MEDIA_AUI: media = IFM_ETHER|IFM_10_5; break;
default: if_printf(ifp, "adapter has no media\n");
}
ifmedia_set(&sc->media, media);
cs_mediaset(sc, media);
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
sc->recv_ring=malloc(CS_DMA_BUFFER_SIZE<<1, M_DEVBUF, M_NOWAIT);
if (sc->recv_ring == NULL) {
log(LOG_ERR,CS_NAME
"%d: Couldn't allocate memory for NIC\n", unit);
return(0);
}
if ((sc->recv_ring-(sc->recv_ring & 0x1FFFF))
< (128*1024-CS_DMA_BUFFER_SIZE))
sc->recv_ring+=16*1024;
*/
sc->buffer=malloc(ETHER_MAX_LEN-ETHER_CRC_LEN,M_DEVBUF,M_NOWAIT);
if (sc->buffer == NULL) {
if_printf(ifp, "Couldn't allocate memory for NIC\n");
return(0);
}
/*
* Initialize the media structures.
*/
ifmedia_init(&sc->media, 0, cs_mediachange, cs_mediastatus);
if (sc->adapter_cnf & A_CNF_10B_T) {
ifmedia_add(&sc->media, IFM_ETHER|IFM_10_T, 0, NULL);
if (sc->chip_type != CS8900) {
ifmedia_add(&sc->media,
IFM_ETHER|IFM_10_T|IFM_FDX, 0, NULL);
ifmedia_add(&sc->media,
IFM_ETHER|IFM_10_T|IFM_HDX, 0, NULL);
}
}
if (sc->adapter_cnf & A_CNF_10B_2)
ifmedia_add(&sc->media, IFM_ETHER|IFM_10_2, 0, NULL);
if (sc->adapter_cnf & A_CNF_AUI)
ifmedia_add(&sc->media, IFM_ETHER|IFM_10_5, 0, NULL);
if (sc->adapter_cnf & A_CNF_MEDIA)
ifmedia_add(&sc->media, IFM_ETHER|IFM_AUTO, 0, NULL);
/* Set default media from EEPROM */
switch (sc->adapter_cnf & A_CNF_MEDIA_TYPE) {
case A_CNF_MEDIA_AUTO: media = IFM_ETHER|IFM_AUTO; break;
case A_CNF_MEDIA_10B_T: media = IFM_ETHER|IFM_10_T; break;
case A_CNF_MEDIA_10B_2: media = IFM_ETHER|IFM_10_2; break;
case A_CNF_MEDIA_AUI: media = IFM_ETHER|IFM_10_5; break;
default: if_printf(ifp, "adapter has no media\n");
}
ifmedia_set(&sc->media, media);
cs_mediaset(sc, media);
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
if (bootverbose)
if_printf(ifp, "ethernet address %6D\n",

View File

@ -1713,51 +1713,49 @@ ed_attach(sc, unit, flags)
*/
ed_stop(sc);
if (!ifp->if_name) {
/*
* Initialize ifnet structure
*/
ifp->if_softc = sc;
ifp->if_unit = unit;
ifp->if_name = "ed";
ifp->if_output = ether_output;
ifp->if_start = ed_start;
ifp->if_ioctl = ed_ioctl;
ifp->if_watchdog = ed_watchdog;
ifp->if_init = ed_init;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
ifp->if_linkmib = &sc->mibdata;
ifp->if_linkmiblen = sizeof sc->mibdata;
/*
* XXX - should do a better job.
*/
if (sc->chip_type == ED_CHIP_TYPE_WD790)
sc->mibdata.dot3StatsEtherChipSet =
DOT3CHIPSET(dot3VendorWesternDigital,
dot3ChipSetWesternDigital83C790);
else
sc->mibdata.dot3StatsEtherChipSet =
DOT3CHIPSET(dot3VendorNational,
dot3ChipSetNational8390);
sc->mibdata.dot3Compliance = DOT3COMPLIANCE_COLLS;
/*
* Initialize ifnet structure
*/
ifp->if_softc = sc;
ifp->if_unit = unit;
ifp->if_name = "ed";
ifp->if_output = ether_output;
ifp->if_start = ed_start;
ifp->if_ioctl = ed_ioctl;
ifp->if_watchdog = ed_watchdog;
ifp->if_init = ed_init;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
ifp->if_linkmib = &sc->mibdata;
ifp->if_linkmiblen = sizeof sc->mibdata;
/*
* XXX - should do a better job.
*/
if (sc->chip_type == ED_CHIP_TYPE_WD790)
sc->mibdata.dot3StatsEtherChipSet =
DOT3CHIPSET(dot3VendorWesternDigital,
dot3ChipSetWesternDigital83C790);
else
sc->mibdata.dot3StatsEtherChipSet =
DOT3CHIPSET(dot3VendorNational,
dot3ChipSetNational8390);
sc->mibdata.dot3Compliance = DOT3COMPLIANCE_COLLS;
/*
* Set default state for ALTPHYS flag (used to disable the
* tranceiver for AUI operation), based on compile-time
* config option.
*/
if (flags & ED_FLAGS_DISABLE_TRANCEIVER)
ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX |
IFF_MULTICAST | IFF_ALTPHYS);
else
ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX |
IFF_MULTICAST);
/*
* Set default state for ALTPHYS flag (used to disable the
* tranceiver for AUI operation), based on compile-time
* config option.
*/
if (flags & ED_FLAGS_DISABLE_TRANCEIVER)
ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX |
IFF_MULTICAST | IFF_ALTPHYS);
else
ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX |
IFF_MULTICAST);
/*
* Attach the interface
*/
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
}
/*
* Attach the interface
*/
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
/* device attach does transition from UNCONFIGURED to IDLE state */
/*

View File

@ -226,26 +226,24 @@ sbni_attach(struct sbni_softc *sc, int unit, struct sbni_flags flags)
set_initial_values(sc, flags);
callout_handle_init(&sc->wch);
if (!ifp->if_name) {
/* Initialize ifnet structure */
ifp->if_softc = sc;
ifp->if_unit = unit;
ifp->if_name = "sbni";
ifp->if_init = sbni_init;
ifp->if_start = sbni_start;
ifp->if_output = ether_output;
ifp->if_ioctl = sbni_ioctl;
ifp->if_watchdog = sbni_watchdog;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
/* Initialize ifnet structure */
ifp->if_softc = sc;
ifp->if_unit = unit;
ifp->if_name = "sbni";
ifp->if_init = sbni_init;
ifp->if_start = sbni_start;
ifp->if_output = ether_output;
ifp->if_ioctl = sbni_ioctl;
ifp->if_watchdog = sbni_watchdog;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
/* report real baud rate */
csr0 = sbni_inb(sc, CSR0);
ifp->if_baudrate =
(csr0 & 0x01 ? 500000 : 2000000) / (1 << flags.rate);
/* report real baud rate */
csr0 = sbni_inb(sc, CSR0);
ifp->if_baudrate =
(csr0 & 0x01 ? 500000 : 2000000) / (1 << flags.rate);
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
}
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
/* device attach does transition from UNCONFIGURED to IDLE state */
if_printf(ifp, "speed %ld, address %6D, rxl ",

View File

@ -218,22 +218,20 @@ xe_attach (device_t dev)
scp->autoneg_status = XE_AUTONEG_NONE;
/* Initialise the ifnet structure */
if (!scp->ifp->if_name) {
scp->ifp->if_softc = scp;
scp->ifp->if_name = "xe";
scp->ifp->if_unit = device_get_unit(dev);
scp->ifp->if_timer = 0;
scp->ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
scp->ifp->if_linkmib = &scp->mibdata;
scp->ifp->if_linkmiblen = sizeof scp->mibdata;
scp->ifp->if_output = ether_output;
scp->ifp->if_start = xe_start;
scp->ifp->if_ioctl = xe_ioctl;
scp->ifp->if_watchdog = xe_watchdog;
scp->ifp->if_init = xe_init;
scp->ifp->if_baudrate = 100000000;
scp->ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
}
scp->ifp->if_softc = scp;
scp->ifp->if_name = "xe";
scp->ifp->if_unit = device_get_unit(dev);
scp->ifp->if_timer = 0;
scp->ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
scp->ifp->if_linkmib = &scp->mibdata;
scp->ifp->if_linkmiblen = sizeof scp->mibdata;
scp->ifp->if_output = ether_output;
scp->ifp->if_start = xe_start;
scp->ifp->if_ioctl = xe_ioctl;
scp->ifp->if_watchdog = xe_watchdog;
scp->ifp->if_init = xe_init;
scp->ifp->if_baudrate = 100000000;
scp->ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
/* Initialise the ifmedia structure */
ifmedia_init(scp->ifm, 0, xe_media_change, xe_media_status);

View File

@ -591,25 +591,23 @@ rdp_attach(struct isa_device *isa_dev)
*/
rdp_stop(sc);
if (!ifp->if_name) {
/*
* Initialize ifnet structure
*/
ifp->if_softc = sc;
ifp->if_unit = unit;
ifp->if_name = "rdp";
ifp->if_start = rdp_start;
ifp->if_ioctl = rdp_ioctl;
ifp->if_watchdog = rdp_watchdog;
ifp->if_init = rdp_init;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX;
/*
* Initialize ifnet structure
*/
ifp->if_softc = sc;
ifp->if_unit = unit;
ifp->if_name = "rdp";
ifp->if_start = rdp_start;
ifp->if_ioctl = rdp_ioctl;
ifp->if_watchdog = rdp_watchdog;
ifp->if_init = rdp_init;
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX;
/*
* Attach the interface
*/
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
}
/*
* Attach the interface
*/
ether_ifattach(ifp, sc->arpcom.ac_enaddr);
/*
* Print additional info when attached