Lines Matching refs:sc

111 lance_config(struct lance_softc *sc, const char* name, int unit)
116 if (LE_LOCK_INITIALIZED(sc) == 0)
119 ifp = sc->sc_ifp = if_alloc(IFT_ETHER);
123 callout_init_mtx(&sc->sc_wdog_ch, &sc->sc_mtx, 0);
126 ifp->if_softc = sc;
141 ifmedia_init(&sc->sc_media, 0, lance_mediachange, lance_mediastatus);
142 if (sc->sc_supmedia != NULL) {
143 for (i = 0; i < sc->sc_nsupmedia; i++)
144 ifmedia_add(&sc->sc_media, sc->sc_supmedia[i], 0, NULL);
145 ifmedia_set(&sc->sc_media, sc->sc_defaultmedia);
147 ifmedia_add(&sc->sc_media,
149 ifmedia_set(&sc->sc_media,
153 switch (sc->sc_memsize) {
155 sc->sc_nrbuf = 4;
156 sc->sc_ntbuf = 1;
159 sc->sc_nrbuf = 8;
160 sc->sc_ntbuf = 2;
163 sc->sc_nrbuf = 16;
164 sc->sc_ntbuf = 4;
167 sc->sc_nrbuf = 32;
168 sc->sc_ntbuf = 8;
171 sc->sc_nrbuf = 64;
172 sc->sc_ntbuf = 16;
175 sc->sc_nrbuf = 128;
176 sc->sc_ntbuf = 32;
180 nbuf = sc->sc_memsize / LEBLEN;
181 sc->sc_ntbuf = nbuf / 5;
182 sc->sc_nrbuf = nbuf - sc->sc_ntbuf;
186 sc->sc_nrbuf, sc->sc_ntbuf);
189 LE_LOCK(sc);
190 lance_stop(sc);
191 LE_UNLOCK(sc);
197 lance_attach(struct lance_softc *sc)
199 struct ifnet *ifp = sc->sc_ifp;
202 ether_ifattach(ifp, sc->sc_enaddr);
211 lance_detach(struct lance_softc *sc)
213 struct ifnet *ifp = sc->sc_ifp;
215 LE_LOCK(sc);
216 lance_stop(sc);
217 LE_UNLOCK(sc);
218 callout_drain(&sc->sc_wdog_ch);
224 lance_suspend(struct lance_softc *sc)
227 LE_LOCK(sc);
228 lance_stop(sc);
229 LE_UNLOCK(sc);
233 lance_resume(struct lance_softc *sc)
236 LE_LOCK(sc);
237 if (sc->sc_ifp->if_flags & IFF_UP)
238 lance_init_locked(sc);
239 LE_UNLOCK(sc);
245 struct lance_softc *sc = ifp->if_softc;
247 LE_LOCK(sc);
248 (*sc->sc_start_locked)(sc);
249 LE_UNLOCK(sc);
253 lance_stop(struct lance_softc *sc)
255 struct ifnet *ifp = sc->sc_ifp;
257 LE_LOCK_ASSERT(sc, MA_OWNED);
263 callout_stop(&sc->sc_wdog_ch);
264 sc->sc_wdog_timer = 0;
266 (*sc->sc_wrcsr)(sc, LE_CSR0, LE_C0_STOP);
272 struct lance_softc *sc = (struct lance_softc *)xsc;
274 LE_LOCK(sc);
275 lance_init_locked(sc);
276 LE_UNLOCK(sc);
284 lance_init_locked(struct lance_softc *sc)
286 struct ifnet *ifp = sc->sc_ifp;
290 LE_LOCK_ASSERT(sc, MA_OWNED);
292 (*sc->sc_wrcsr)(sc, LE_CSR0, LE_C0_STOP);
296 if (sc->sc_hwreset)
297 (*sc->sc_hwreset)(sc);
300 (*sc->sc_wrcsr)(sc, LE_CSR3, sc->sc_conf3);
303 if (sc->sc_mediachange)
304 (void)(*sc->sc_mediachange)(sc);
310 memcpy(sc->sc_enaddr, IF_LLADDR(ifp), ETHER_ADDR_LEN);
313 (*sc->sc_meminit)(sc);
316 a = sc->sc_addr + LE_INITADDR(sc);
317 (*sc->sc_wrcsr)(sc, LE_CSR1, a & 0xffff);
318 (*sc->sc_wrcsr)(sc, LE_CSR2, a >> 16);
322 (*sc->sc_wrcsr)(sc, LE_CSR0, LE_C0_INIT);
326 if ((*sc->sc_rdcsr)(sc, LE_CSR0) & LE_C0_IDON)
329 if ((*sc->sc_rdcsr)(sc, LE_CSR0) & LE_C0_IDON) {
331 (*sc->sc_wrcsr)(sc, LE_CSR0, LE_C0_INEA | LE_C0_STRT);
334 sc->sc_wdog_timer = 0;
335 callout_reset(&sc->sc_wdog_ch, hz, lance_watchdog, sc);
336 (*sc->sc_start_locked)(sc);
340 if (sc->sc_hwinit)
341 (*sc->sc_hwinit)(sc);
349 lance_put(struct lance_softc *sc, int boff, struct mbuf *m)
354 LE_LOCK_ASSERT(sc, MA_OWNED);
363 (*sc->sc_copytobuf)(sc, mtod(m, caddr_t), boff, len);
370 (*sc->sc_zerobuf)(sc, boff, LEMINSIZE - tlen);
383 lance_get(struct lance_softc *sc, int boff, int totlen)
385 struct ifnet *ifp = sc->sc_ifp;
421 (*sc->sc_copyfrombuf)(sc, mtod(m, caddr_t), boff, len);
444 struct lance_softc *sc = (struct lance_softc *)xsc;
445 struct ifnet *ifp = sc->sc_ifp;
447 LE_LOCK_ASSERT(sc, MA_OWNED);
449 if (sc->sc_wdog_timer == 0 || --sc->sc_wdog_timer != 0) {
450 callout_reset(&sc->sc_wdog_ch, hz, lance_watchdog, sc);
456 lance_init_locked(sc);
462 struct lance_softc *sc = ifp->if_softc;
464 if (sc->sc_mediachange) {
472 LE_LOCK(sc);
473 lance_stop(sc);
474 lance_init_locked(sc);
476 (*sc->sc_start_locked)(sc);
477 LE_UNLOCK(sc);
485 struct lance_softc *sc = ifp->if_softc;
487 LE_LOCK(sc);
489 LE_UNLOCK(sc);
494 if (sc->sc_flags & LE_CARRIER)
497 if (sc->sc_mediastatus)
498 (*sc->sc_mediastatus)(sc, ifmr);
499 LE_UNLOCK(sc);
508 struct lance_softc *sc = ifp->if_softc;
514 LE_LOCK(sc);
516 if (!(sc->sc_flags & LE_PROMISC)) {
517 sc->sc_flags |= LE_PROMISC;
518 lance_init_locked(sc);
520 } else if (sc->sc_flags & LE_PROMISC) {
521 sc->sc_flags &= ~LE_PROMISC;
522 lance_init_locked(sc);
526 !(sc->sc_flags & LE_ALLMULTI)) {
527 sc->sc_flags |= LE_ALLMULTI;
528 lance_init_locked(sc);
530 (sc->sc_flags & LE_ALLMULTI)) {
531 sc->sc_flags &= ~LE_ALLMULTI;
532 lance_init_locked(sc);
541 lance_stop(sc);
548 lance_init_locked(sc);
552 sc->sc_flags |= LE_DEBUG;
554 sc->sc_flags &= ~LE_DEBUG;
556 LE_UNLOCK(sc);
565 LE_LOCK(sc);
567 lance_init_locked(sc);
568 LE_UNLOCK(sc);
573 error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
588 lance_setladrf(struct lance_softc *sc, uint16_t *af)
590 struct ifnet *ifp = sc->sc_ifp;
602 if (ifp->if_flags & IFF_PROMISC || sc->sc_flags & LE_ALLMULTI) {
642 lance_copytobuf_contig(struct lance_softc *sc, void *from, int boff, int len)
644 volatile caddr_t buf = sc->sc_mem;
653 lance_copyfrombuf_contig(struct lance_softc *sc, void *to, int boff, int len)
655 volatile caddr_t buf = sc->sc_mem;
664 lance_zerobuf_contig(struct lance_softc *sc, int boff, int len)
666 volatile caddr_t buf = sc->sc_mem;
688 lance_copytobuf_gap2(struct lance_softc *sc, void *fromv, int boff, int len)
690 volatile caddr_t buf = sc->sc_mem;
713 lance_copyfrombuf_gap2(struct lance_softc *sc, void *tov, int boff, int len)
715 volatile caddr_t buf = sc->sc_mem;
740 lance_zerobuf_gap2(struct lance_softc *sc, int boff, int len)
742 volatile caddr_t buf = sc->sc_mem;
766 lance_copytobuf_gap16(struct lance_softc *sc, void *fromv, int boff, int len)
768 volatile caddr_t buf = sc->sc_mem;
786 lance_copyfrombuf_gap16(struct lance_softc *sc, void *tov, int boff, int len)
788 volatile caddr_t buf = sc->sc_mem;
806 lance_zerobuf_gap16(struct lance_softc *sc, int boff, int len)
808 volatile caddr_t buf = sc->sc_mem;