Deleted Added
full compact
if_vr.c (101896) if_vr.c (102336)
1/*
2 * Copyright (c) 1997, 1998
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 *
1/*
2 * Copyright (c) 1997, 1998
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * $FreeBSD: head/sys/dev/vr/if_vr.c 101896 2002-08-15 04:04:53Z silby $
32 * $FreeBSD: head/sys/dev/vr/if_vr.c 102336 2002-08-24 00:02:03Z alfred $
33 */
34
35/*
36 * VIA Rhine fast ethernet PCI NIC driver
37 *
38 * Supports various network adapters based on the VIA Rhine
39 * and Rhine II PCI controllers, including the D-Link DFE530TX.
40 * Datasheets are available at http://www.via.com.tw.

--- 55 unchanged lines hidden (view full) ---

96
97MODULE_DEPEND(vr, miibus, 1, 1, 1);
98
99/* "controller miibus0" required. See GENERIC if you get errors here. */
100#include "miibus_if.h"
101
102#ifndef lint
103static const char rcsid[] =
33 */
34
35/*
36 * VIA Rhine fast ethernet PCI NIC driver
37 *
38 * Supports various network adapters based on the VIA Rhine
39 * and Rhine II PCI controllers, including the D-Link DFE530TX.
40 * Datasheets are available at http://www.via.com.tw.

--- 55 unchanged lines hidden (view full) ---

96
97MODULE_DEPEND(vr, miibus, 1, 1, 1);
98
99/* "controller miibus0" required. See GENERIC if you get errors here. */
100#include "miibus_if.h"
101
102#ifndef lint
103static const char rcsid[] =
104 "$FreeBSD: head/sys/dev/vr/if_vr.c 101896 2002-08-15 04:04:53Z silby $";
104 "$FreeBSD: head/sys/dev/vr/if_vr.c 102336 2002-08-24 00:02:03Z alfred $";
105#endif
106
107/*
108 * Various supported device vendors/types and their names.
109 */
110static struct vr_type vr_devs[] = {
111 { VIA_VENDORID, VIA_DEVICEID_RHINE,
112 "VIA VT3043 Rhine I 10/100BaseTX" },

--- 116 unchanged lines hidden (view full) ---

229
230#define SIO_CLR(x) \
231 CSR_WRITE_1(sc, VR_MIICMD, \
232 CSR_READ_1(sc, VR_MIICMD) & ~x)
233
234/*
235 * Sync the PHYs by setting data bit and strobing the clock 32 times.
236 */
105#endif
106
107/*
108 * Various supported device vendors/types and their names.
109 */
110static struct vr_type vr_devs[] = {
111 { VIA_VENDORID, VIA_DEVICEID_RHINE,
112 "VIA VT3043 Rhine I 10/100BaseTX" },

--- 116 unchanged lines hidden (view full) ---

229
230#define SIO_CLR(x) \
231 CSR_WRITE_1(sc, VR_MIICMD, \
232 CSR_READ_1(sc, VR_MIICMD) & ~x)
233
234/*
235 * Sync the PHYs by setting data bit and strobing the clock 32 times.
236 */
237static void vr_mii_sync(sc)
237static void
238vr_mii_sync(sc)
238 struct vr_softc *sc;
239{
240 register int i;
241
242 SIO_SET(VR_MIICMD_DIR|VR_MIICMD_DATAIN);
243
244 for (i = 0; i < 32; i++) {
245 SIO_SET(VR_MIICMD_CLK);
246 DELAY(1);
247 SIO_CLR(VR_MIICMD_CLK);
248 DELAY(1);
249 }
250
251 return;
252}
253
254/*
255 * Clock a series of bits through the MII.
256 */
239 struct vr_softc *sc;
240{
241 register int i;
242
243 SIO_SET(VR_MIICMD_DIR|VR_MIICMD_DATAIN);
244
245 for (i = 0; i < 32; i++) {
246 SIO_SET(VR_MIICMD_CLK);
247 DELAY(1);
248 SIO_CLR(VR_MIICMD_CLK);
249 DELAY(1);
250 }
251
252 return;
253}
254
255/*
256 * Clock a series of bits through the MII.
257 */
257static void vr_mii_send(sc, bits, cnt)
258static void
259vr_mii_send(sc, bits, cnt)
258 struct vr_softc *sc;
259 u_int32_t bits;
260 int cnt;
261{
262 int i;
263
264 SIO_CLR(VR_MIICMD_CLK);
265

--- 8 unchanged lines hidden (view full) ---

274 DELAY(1);
275 SIO_SET(VR_MIICMD_CLK);
276 }
277}
278
279/*
280 * Read an PHY register through the MII.
281 */
260 struct vr_softc *sc;
261 u_int32_t bits;
262 int cnt;
263{
264 int i;
265
266 SIO_CLR(VR_MIICMD_CLK);
267

--- 8 unchanged lines hidden (view full) ---

276 DELAY(1);
277 SIO_SET(VR_MIICMD_CLK);
278 }
279}
280
281/*
282 * Read an PHY register through the MII.
283 */
282static int vr_mii_readreg(sc, frame)
284static int
285vr_mii_readreg(sc, frame)
283 struct vr_softc *sc;
284 struct vr_mii_frame *frame;
285
286{
287 int i, ack;
288
289 VR_LOCK(sc);
290

--- 77 unchanged lines hidden (view full) ---

368 if (ack)
369 return(1);
370 return(0);
371}
372
373/*
374 * Write to a PHY register through the MII.
375 */
286 struct vr_softc *sc;
287 struct vr_mii_frame *frame;
288
289{
290 int i, ack;
291
292 VR_LOCK(sc);
293

--- 77 unchanged lines hidden (view full) ---

371 if (ack)
372 return(1);
373 return(0);
374}
375
376/*
377 * Write to a PHY register through the MII.
378 */
376static int vr_mii_writereg(sc, frame)
379static int
380vr_mii_writereg(sc, frame)
377 struct vr_softc *sc;
378 struct vr_mii_frame *frame;
379
380{
381 VR_LOCK(sc);
382
383 CSR_WRITE_1(sc, VR_MIICMD, 0);
384 VR_SETBIT(sc, VR_MIICMD, VR_MIICMD_DIRECTPGM);

--- 31 unchanged lines hidden (view full) ---

416 */
417 SIO_CLR(VR_MIICMD_DIR);
418
419 VR_UNLOCK(sc);
420
421 return(0);
422}
423
381 struct vr_softc *sc;
382 struct vr_mii_frame *frame;
383
384{
385 VR_LOCK(sc);
386
387 CSR_WRITE_1(sc, VR_MIICMD, 0);
388 VR_SETBIT(sc, VR_MIICMD, VR_MIICMD_DIRECTPGM);

--- 31 unchanged lines hidden (view full) ---

420 */
421 SIO_CLR(VR_MIICMD_DIR);
422
423 VR_UNLOCK(sc);
424
425 return(0);
426}
427
424static int vr_miibus_readreg(dev, phy, reg)
428static int
429vr_miibus_readreg(dev, phy, reg)
425 device_t dev;
426 int phy, reg;
427{
428 struct vr_softc *sc;
429 struct vr_mii_frame frame;
430
431 sc = device_get_softc(dev);
432 bzero((char *)&frame, sizeof(frame));
433
434 frame.mii_phyaddr = phy;
435 frame.mii_regaddr = reg;
436 vr_mii_readreg(sc, &frame);
437
438 return(frame.mii_data);
439}
440
430 device_t dev;
431 int phy, reg;
432{
433 struct vr_softc *sc;
434 struct vr_mii_frame frame;
435
436 sc = device_get_softc(dev);
437 bzero((char *)&frame, sizeof(frame));
438
439 frame.mii_phyaddr = phy;
440 frame.mii_regaddr = reg;
441 vr_mii_readreg(sc, &frame);
442
443 return(frame.mii_data);
444}
445
441static int vr_miibus_writereg(dev, phy, reg, data)
446static int
447vr_miibus_writereg(dev, phy, reg, data)
442 device_t dev;
443 u_int16_t phy, reg, data;
444{
445 struct vr_softc *sc;
446 struct vr_mii_frame frame;
447
448 sc = device_get_softc(dev);
449 bzero((char *)&frame, sizeof(frame));
450
451 frame.mii_phyaddr = phy;
452 frame.mii_regaddr = reg;
453 frame.mii_data = data;
454
455 vr_mii_writereg(sc, &frame);
456
457 return(0);
458}
459
448 device_t dev;
449 u_int16_t phy, reg, data;
450{
451 struct vr_softc *sc;
452 struct vr_mii_frame frame;
453
454 sc = device_get_softc(dev);
455 bzero((char *)&frame, sizeof(frame));
456
457 frame.mii_phyaddr = phy;
458 frame.mii_regaddr = reg;
459 frame.mii_data = data;
460
461 vr_mii_writereg(sc, &frame);
462
463 return(0);
464}
465
460static void vr_miibus_statchg(dev)
466static void
467vr_miibus_statchg(dev)
461 device_t dev;
462{
463 struct vr_softc *sc;
464 struct mii_data *mii;
465
466 sc = device_get_softc(dev);
467 VR_LOCK(sc);
468 mii = device_get_softc(sc->vr_miibus);

--- 29 unchanged lines hidden (view full) ---

498
499 /* return the filter bit position */
500 return((crc >> 26) & 0x0000003F);
501}
502
503/*
504 * Program the 64-bit multicast hash filter.
505 */
468 device_t dev;
469{
470 struct vr_softc *sc;
471 struct mii_data *mii;
472
473 sc = device_get_softc(dev);
474 VR_LOCK(sc);
475 mii = device_get_softc(sc->vr_miibus);

--- 29 unchanged lines hidden (view full) ---

505
506 /* return the filter bit position */
507 return((crc >> 26) & 0x0000003F);
508}
509
510/*
511 * Program the 64-bit multicast hash filter.
512 */
506static void vr_setmulti(sc)
513static void
514vr_setmulti(sc)
507 struct vr_softc *sc;
508{
509 struct ifnet *ifp;
510 int h = 0;
511 u_int32_t hashes[2] = { 0, 0 };
512 struct ifmultiaddr *ifma;
513 u_int8_t rxfilt;
514 int mcnt = 0;

--- 38 unchanged lines hidden (view full) ---

553 return;
554}
555
556/*
557 * In order to fiddle with the
558 * 'full-duplex' and '100Mbps' bits in the netconfig register, we
559 * first have to put the transmit and/or receive logic in the idle state.
560 */
515 struct vr_softc *sc;
516{
517 struct ifnet *ifp;
518 int h = 0;
519 u_int32_t hashes[2] = { 0, 0 };
520 struct ifmultiaddr *ifma;
521 u_int8_t rxfilt;
522 int mcnt = 0;

--- 38 unchanged lines hidden (view full) ---

561 return;
562}
563
564/*
565 * In order to fiddle with the
566 * 'full-duplex' and '100Mbps' bits in the netconfig register, we
567 * first have to put the transmit and/or receive logic in the idle state.
568 */
561static void vr_setcfg(sc, media)
569static void
570vr_setcfg(sc, media)
562 struct vr_softc *sc;
563 int media;
564{
565 int restart = 0;
566
567 if (CSR_READ_2(sc, VR_COMMAND) & (VR_CMD_TX_ON|VR_CMD_RX_ON)) {
568 restart = 1;
569 VR_CLRBIT16(sc, VR_COMMAND, (VR_CMD_TX_ON|VR_CMD_RX_ON));

--- 5 unchanged lines hidden (view full) ---

575 VR_CLRBIT16(sc, VR_COMMAND, VR_CMD_FULLDUPLEX);
576
577 if (restart)
578 VR_SETBIT16(sc, VR_COMMAND, VR_CMD_TX_ON|VR_CMD_RX_ON);
579
580 return;
581}
582
571 struct vr_softc *sc;
572 int media;
573{
574 int restart = 0;
575
576 if (CSR_READ_2(sc, VR_COMMAND) & (VR_CMD_TX_ON|VR_CMD_RX_ON)) {
577 restart = 1;
578 VR_CLRBIT16(sc, VR_COMMAND, (VR_CMD_TX_ON|VR_CMD_RX_ON));

--- 5 unchanged lines hidden (view full) ---

584 VR_CLRBIT16(sc, VR_COMMAND, VR_CMD_FULLDUPLEX);
585
586 if (restart)
587 VR_SETBIT16(sc, VR_COMMAND, VR_CMD_TX_ON|VR_CMD_RX_ON);
588
589 return;
590}
591
583static void vr_reset(sc)
592static void
593vr_reset(sc)
584 struct vr_softc *sc;
585{
586 register int i;
587
588 VR_SETBIT16(sc, VR_COMMAND, VR_CMD_RESET);
589
590 for (i = 0; i < VR_TIMEOUT; i++) {
591 DELAY(10);

--- 8 unchanged lines hidden (view full) ---

600
601 return;
602}
603
604/*
605 * Probe for a VIA Rhine chip. Check the PCI vendor and device
606 * IDs against our list and return a device name if we find a match.
607 */
594 struct vr_softc *sc;
595{
596 register int i;
597
598 VR_SETBIT16(sc, VR_COMMAND, VR_CMD_RESET);
599
600 for (i = 0; i < VR_TIMEOUT; i++) {
601 DELAY(10);

--- 8 unchanged lines hidden (view full) ---

610
611 return;
612}
613
614/*
615 * Probe for a VIA Rhine chip. Check the PCI vendor and device
616 * IDs against our list and return a device name if we find a match.
617 */
608static int vr_probe(dev)
618static int
619vr_probe(dev)
609 device_t dev;
610{
611 struct vr_type *t;
612
613 t = vr_devs;
614
615 while(t->vr_name != NULL) {
616 if ((pci_get_vendor(dev) == t->vr_vid) &&

--- 6 unchanged lines hidden (view full) ---

623
624 return(ENXIO);
625}
626
627/*
628 * Attach the interface. Allocate softc structures, do ifmedia
629 * setup and ethernet/BPF attach.
630 */
620 device_t dev;
621{
622 struct vr_type *t;
623
624 t = vr_devs;
625
626 while(t->vr_name != NULL) {
627 if ((pci_get_vendor(dev) == t->vr_vid) &&

--- 6 unchanged lines hidden (view full) ---

634
635 return(ENXIO);
636}
637
638/*
639 * Attach the interface. Allocate softc structures, do ifmedia
640 * setup and ethernet/BPF attach.
641 */
631static int vr_attach(dev)
642static int
643vr_attach(dev)
632 device_t dev;
633{
634 int i;
635 u_char eaddr[ETHER_ADDR_LEN];
636 u_int32_t command;
637 struct vr_softc *sc;
638 struct ifnet *ifp;
639 int unit, error = 0, rid;

--- 169 unchanged lines hidden (view full) ---

809
810fail:
811 VR_UNLOCK(sc);
812 mtx_destroy(&sc->vr_mtx);
813
814 return(error);
815}
816
644 device_t dev;
645{
646 int i;
647 u_char eaddr[ETHER_ADDR_LEN];
648 u_int32_t command;
649 struct vr_softc *sc;
650 struct ifnet *ifp;
651 int unit, error = 0, rid;

--- 169 unchanged lines hidden (view full) ---

821
822fail:
823 VR_UNLOCK(sc);
824 mtx_destroy(&sc->vr_mtx);
825
826 return(error);
827}
828
817static int vr_detach(dev)
829static int
830vr_detach(dev)
818 device_t dev;
819{
820 struct vr_softc *sc;
821 struct ifnet *ifp;
822
823 sc = device_get_softc(dev);
824 VR_LOCK(sc);
825 ifp = &sc->arpcom.ac_if;

--- 14 unchanged lines hidden (view full) ---

840 mtx_destroy(&sc->vr_mtx);
841
842 return(0);
843}
844
845/*
846 * Initialize the transmit descriptors.
847 */
831 device_t dev;
832{
833 struct vr_softc *sc;
834 struct ifnet *ifp;
835
836 sc = device_get_softc(dev);
837 VR_LOCK(sc);
838 ifp = &sc->arpcom.ac_if;

--- 14 unchanged lines hidden (view full) ---

853 mtx_destroy(&sc->vr_mtx);
854
855 return(0);
856}
857
858/*
859 * Initialize the transmit descriptors.
860 */
848static int vr_list_tx_init(sc)
861static int
862vr_list_tx_init(sc)
849 struct vr_softc *sc;
850{
851 struct vr_chain_data *cd;
852 struct vr_list_data *ld;
853 int i;
854
855 cd = &sc->vr_cdata;
856 ld = sc->vr_ldata;

--- 14 unchanged lines hidden (view full) ---

871}
872
873
874/*
875 * Initialize the RX descriptors and allocate mbufs for them. Note that
876 * we arrange the descriptors in a closed ring, so that the last descriptor
877 * points back to the first.
878 */
863 struct vr_softc *sc;
864{
865 struct vr_chain_data *cd;
866 struct vr_list_data *ld;
867 int i;
868
869 cd = &sc->vr_cdata;
870 ld = sc->vr_ldata;

--- 14 unchanged lines hidden (view full) ---

885}
886
887
888/*
889 * Initialize the RX descriptors and allocate mbufs for them. Note that
890 * we arrange the descriptors in a closed ring, so that the last descriptor
891 * points back to the first.
892 */
879static int vr_list_rx_init(sc)
893static int
894vr_list_rx_init(sc)
880 struct vr_softc *sc;
881{
882 struct vr_chain_data *cd;
883 struct vr_list_data *ld;
884 int i;
885
886 cd = &sc->vr_cdata;
887 ld = sc->vr_ldata;

--- 23 unchanged lines hidden (view full) ---

911
912/*
913 * Initialize an RX descriptor and attach an MBUF cluster.
914 * Note: the length fields are only 11 bits wide, which means the
915 * largest size we can specify is 2047. This is important because
916 * MCLBYTES is 2048, so we have to subtract one otherwise we'll
917 * overflow the field and make a mess.
918 */
895 struct vr_softc *sc;
896{
897 struct vr_chain_data *cd;
898 struct vr_list_data *ld;
899 int i;
900
901 cd = &sc->vr_cdata;
902 ld = sc->vr_ldata;

--- 23 unchanged lines hidden (view full) ---

926
927/*
928 * Initialize an RX descriptor and attach an MBUF cluster.
929 * Note: the length fields are only 11 bits wide, which means the
930 * largest size we can specify is 2047. This is important because
931 * MCLBYTES is 2048, so we have to subtract one otherwise we'll
932 * overflow the field and make a mess.
933 */
919static int vr_newbuf(sc, c, m)
934static int
935vr_newbuf(sc, c, m)
920 struct vr_softc *sc;
921 struct vr_chain_onefrag *c;
922 struct mbuf *m;
923{
924 struct mbuf *m_new = NULL;
925
926 if (m == NULL) {
927 MGETHDR(m_new, M_DONTWAIT, MT_DATA);

--- 21 unchanged lines hidden (view full) ---

949
950 return(0);
951}
952
953/*
954 * A frame has been uploaded: pass the resulting mbuf chain up to
955 * the higher level protocols.
956 */
936 struct vr_softc *sc;
937 struct vr_chain_onefrag *c;
938 struct mbuf *m;
939{
940 struct mbuf *m_new = NULL;
941
942 if (m == NULL) {
943 MGETHDR(m_new, M_DONTWAIT, MT_DATA);

--- 21 unchanged lines hidden (view full) ---

965
966 return(0);
967}
968
969/*
970 * A frame has been uploaded: pass the resulting mbuf chain up to
971 * the higher level protocols.
972 */
957static void vr_rxeof(sc)
973static void
974vr_rxeof(sc)
958 struct vr_softc *sc;
959{
960 struct ether_header *eh;
961 struct mbuf *m;
962 struct ifnet *ifp;
963 struct vr_chain_onefrag *cur_rx;
964 int total_len = 0;
965 u_int32_t rxstat;

--- 74 unchanged lines hidden (view full) ---

1040 /* Remove header from mbuf and pass it on. */
1041 m_adj(m, sizeof(struct ether_header));
1042 ether_input(ifp, eh, m);
1043 }
1044
1045 return;
1046}
1047
975 struct vr_softc *sc;
976{
977 struct ether_header *eh;
978 struct mbuf *m;
979 struct ifnet *ifp;
980 struct vr_chain_onefrag *cur_rx;
981 int total_len = 0;
982 u_int32_t rxstat;

--- 74 unchanged lines hidden (view full) ---

1057 /* Remove header from mbuf and pass it on. */
1058 m_adj(m, sizeof(struct ether_header));
1059 ether_input(ifp, eh, m);
1060 }
1061
1062 return;
1063}
1064
1048void vr_rxeoc(sc)
1065void
1066vr_rxeoc(sc)
1049 struct vr_softc *sc;
1050{
1051
1052 vr_rxeof(sc);
1053 VR_CLRBIT16(sc, VR_COMMAND, VR_CMD_RX_ON);
1054 CSR_WRITE_4(sc, VR_RXADDR, vtophys(sc->vr_cdata.vr_rx_head->vr_ptr));
1055 VR_SETBIT16(sc, VR_COMMAND, VR_CMD_RX_ON);
1056 VR_SETBIT16(sc, VR_COMMAND, VR_CMD_RX_GO);
1057
1058 return;
1059}
1060
1061/*
1062 * A frame was downloaded to the chip. It's safe for us to clean up
1063 * the list buffers.
1064 */
1065
1067 struct vr_softc *sc;
1068{
1069
1070 vr_rxeof(sc);
1071 VR_CLRBIT16(sc, VR_COMMAND, VR_CMD_RX_ON);
1072 CSR_WRITE_4(sc, VR_RXADDR, vtophys(sc->vr_cdata.vr_rx_head->vr_ptr));
1073 VR_SETBIT16(sc, VR_COMMAND, VR_CMD_RX_ON);
1074 VR_SETBIT16(sc, VR_COMMAND, VR_CMD_RX_GO);
1075
1076 return;
1077}
1078
1079/*
1080 * A frame was downloaded to the chip. It's safe for us to clean up
1081 * the list buffers.
1082 */
1083
1066static void vr_txeof(sc)
1084static void
1085vr_txeof(sc)
1067 struct vr_softc *sc;
1068{
1069 struct vr_chain *cur_tx;
1070 struct ifnet *ifp;
1071
1072 ifp = &sc->arpcom.ac_if;
1073
1074 /* Reset the timeout timer; if_txeoc will clear it. */

--- 51 unchanged lines hidden (view full) ---

1126 }
1127
1128 return;
1129}
1130
1131/*
1132 * TX 'end of channel' interrupt handler.
1133 */
1086 struct vr_softc *sc;
1087{
1088 struct vr_chain *cur_tx;
1089 struct ifnet *ifp;
1090
1091 ifp = &sc->arpcom.ac_if;
1092
1093 /* Reset the timeout timer; if_txeoc will clear it. */

--- 51 unchanged lines hidden (view full) ---

1145 }
1146
1147 return;
1148}
1149
1150/*
1151 * TX 'end of channel' interrupt handler.
1152 */
1134static void vr_txeoc(sc)
1153static void
1154vr_txeoc(sc)
1135 struct vr_softc *sc;
1136{
1137 struct ifnet *ifp;
1138
1139 ifp = &sc->arpcom.ac_if;
1140
1141 if (sc->vr_cdata.vr_tx_head == NULL) {
1142 ifp->if_flags &= ~IFF_OACTIVE;
1143 sc->vr_cdata.vr_tx_tail = NULL;
1144 ifp->if_timer = 0;
1145 }
1146
1147 return;
1148}
1149
1155 struct vr_softc *sc;
1156{
1157 struct ifnet *ifp;
1158
1159 ifp = &sc->arpcom.ac_if;
1160
1161 if (sc->vr_cdata.vr_tx_head == NULL) {
1162 ifp->if_flags &= ~IFF_OACTIVE;
1163 sc->vr_cdata.vr_tx_tail = NULL;
1164 ifp->if_timer = 0;
1165 }
1166
1167 return;
1168}
1169
1150static void vr_tick(xsc)
1170static void
1171vr_tick(xsc)
1151 void *xsc;
1152{
1153 struct vr_softc *sc;
1154 struct mii_data *mii;
1155
1156 sc = xsc;
1157 VR_LOCK(sc);
1158 mii = device_get_softc(sc->vr_miibus);
1159 mii_tick(mii);
1160
1161 sc->vr_stat_ch = timeout(vr_tick, sc, hz);
1162
1163 VR_UNLOCK(sc);
1164
1165 return;
1166}
1167
1172 void *xsc;
1173{
1174 struct vr_softc *sc;
1175 struct mii_data *mii;
1176
1177 sc = xsc;
1178 VR_LOCK(sc);
1179 mii = device_get_softc(sc->vr_miibus);
1180 mii_tick(mii);
1181
1182 sc->vr_stat_ch = timeout(vr_tick, sc, hz);
1183
1184 VR_UNLOCK(sc);
1185
1186 return;
1187}
1188
1168static void vr_intr(arg)
1189static void
1190vr_intr(arg)
1169 void *arg;
1170{
1171 struct vr_softc *sc;
1172 struct ifnet *ifp;
1173 u_int16_t status;
1174
1175 sc = arg;
1176 VR_LOCK(sc);

--- 62 unchanged lines hidden (view full) ---

1239
1240 return;
1241}
1242
1243/*
1244 * Encapsulate an mbuf chain in a descriptor by coupling the mbuf data
1245 * pointers to the fragment pointers.
1246 */
1191 void *arg;
1192{
1193 struct vr_softc *sc;
1194 struct ifnet *ifp;
1195 u_int16_t status;
1196
1197 sc = arg;
1198 VR_LOCK(sc);

--- 62 unchanged lines hidden (view full) ---

1261
1262 return;
1263}
1264
1265/*
1266 * Encapsulate an mbuf chain in a descriptor by coupling the mbuf data
1267 * pointers to the fragment pointers.
1268 */
1247static int vr_encap(sc, c, m_head)
1269static int
1270vr_encap(sc, c, m_head)
1248 struct vr_softc *sc;
1249 struct vr_chain *c;
1250 struct mbuf *m_head;
1251{
1252 int frag = 0;
1253 struct vr_desc *f = NULL;
1254 int total_len;
1255 struct mbuf *m;

--- 55 unchanged lines hidden (view full) ---

1311
1312/*
1313 * Main transmit routine. To avoid having to do mbuf copies, we put pointers
1314 * to the mbuf data regions directly in the transmit lists. We also save a
1315 * copy of the pointers since the transmit list fragment pointers are
1316 * physical addresses.
1317 */
1318
1271 struct vr_softc *sc;
1272 struct vr_chain *c;
1273 struct mbuf *m_head;
1274{
1275 int frag = 0;
1276 struct vr_desc *f = NULL;
1277 int total_len;
1278 struct mbuf *m;

--- 55 unchanged lines hidden (view full) ---

1334
1335/*
1336 * Main transmit routine. To avoid having to do mbuf copies, we put pointers
1337 * to the mbuf data regions directly in the transmit lists. We also save a
1338 * copy of the pointers since the transmit list fragment pointers are
1339 * physical addresses.
1340 */
1341
1319static void vr_start(ifp)
1342static void
1343vr_start(ifp)
1320 struct ifnet *ifp;
1321{
1322 struct vr_softc *sc;
1323 struct mbuf *m_head = NULL;
1324 struct vr_chain *cur_tx = NULL, *start_tx;
1325
1326 sc = ifp->if_softc;
1327

--- 62 unchanged lines hidden (view full) ---

1390 * Set a timeout in case the chip goes out to lunch.
1391 */
1392 ifp->if_timer = 5;
1393 VR_UNLOCK(sc);
1394
1395 return;
1396}
1397
1344 struct ifnet *ifp;
1345{
1346 struct vr_softc *sc;
1347 struct mbuf *m_head = NULL;
1348 struct vr_chain *cur_tx = NULL, *start_tx;
1349
1350 sc = ifp->if_softc;
1351

--- 62 unchanged lines hidden (view full) ---

1414 * Set a timeout in case the chip goes out to lunch.
1415 */
1416 ifp->if_timer = 5;
1417 VR_UNLOCK(sc);
1418
1419 return;
1420}
1421
1398static void vr_init(xsc)
1422static void
1423vr_init(xsc)
1399 void *xsc;
1400{
1401 struct vr_softc *sc = xsc;
1402 struct ifnet *ifp = &sc->arpcom.ac_if;
1403 struct mii_data *mii;
1404 int i;
1405
1406 VR_LOCK(sc);

--- 91 unchanged lines hidden (view full) ---

1498 VR_UNLOCK(sc);
1499
1500 return;
1501}
1502
1503/*
1504 * Set media options.
1505 */
1424 void *xsc;
1425{
1426 struct vr_softc *sc = xsc;
1427 struct ifnet *ifp = &sc->arpcom.ac_if;
1428 struct mii_data *mii;
1429 int i;
1430
1431 VR_LOCK(sc);

--- 91 unchanged lines hidden (view full) ---

1523 VR_UNLOCK(sc);
1524
1525 return;
1526}
1527
1528/*
1529 * Set media options.
1530 */
1506static int vr_ifmedia_upd(ifp)
1531static int
1532vr_ifmedia_upd(ifp)
1507 struct ifnet *ifp;
1508{
1509 struct vr_softc *sc;
1510
1511 sc = ifp->if_softc;
1512
1513 if (ifp->if_flags & IFF_UP)
1514 vr_init(sc);
1515
1516 return(0);
1517}
1518
1519/*
1520 * Report current media status.
1521 */
1533 struct ifnet *ifp;
1534{
1535 struct vr_softc *sc;
1536
1537 sc = ifp->if_softc;
1538
1539 if (ifp->if_flags & IFF_UP)
1540 vr_init(sc);
1541
1542 return(0);
1543}
1544
1545/*
1546 * Report current media status.
1547 */
1522static void vr_ifmedia_sts(ifp, ifmr)
1548static void
1549vr_ifmedia_sts(ifp, ifmr)
1523 struct ifnet *ifp;
1524 struct ifmediareq *ifmr;
1525{
1526 struct vr_softc *sc;
1527 struct mii_data *mii;
1528
1529 sc = ifp->if_softc;
1530 mii = device_get_softc(sc->vr_miibus);
1531 mii_pollstat(mii);
1532 ifmr->ifm_active = mii->mii_media_active;
1533 ifmr->ifm_status = mii->mii_media_status;
1534
1535 return;
1536}
1537
1550 struct ifnet *ifp;
1551 struct ifmediareq *ifmr;
1552{
1553 struct vr_softc *sc;
1554 struct mii_data *mii;
1555
1556 sc = ifp->if_softc;
1557 mii = device_get_softc(sc->vr_miibus);
1558 mii_pollstat(mii);
1559 ifmr->ifm_active = mii->mii_media_active;
1560 ifmr->ifm_status = mii->mii_media_status;
1561
1562 return;
1563}
1564
1538static int vr_ioctl(ifp, command, data)
1565static int
1566vr_ioctl(ifp, command, data)
1539 struct ifnet *ifp;
1540 u_long command;
1541 caddr_t data;
1542{
1543 struct vr_softc *sc = ifp->if_softc;
1544 struct ifreq *ifr = (struct ifreq *) data;
1545 struct mii_data *mii;
1546 int error = 0;

--- 30 unchanged lines hidden (view full) ---

1577 break;
1578 }
1579
1580 VR_UNLOCK(sc);
1581
1582 return(error);
1583}
1584
1567 struct ifnet *ifp;
1568 u_long command;
1569 caddr_t data;
1570{
1571 struct vr_softc *sc = ifp->if_softc;
1572 struct ifreq *ifr = (struct ifreq *) data;
1573 struct mii_data *mii;
1574 int error = 0;

--- 30 unchanged lines hidden (view full) ---

1605 break;
1606 }
1607
1608 VR_UNLOCK(sc);
1609
1610 return(error);
1611}
1612
1585static void vr_watchdog(ifp)
1613static void
1614vr_watchdog(ifp)
1586 struct ifnet *ifp;
1587{
1588 struct vr_softc *sc;
1589
1590 sc = ifp->if_softc;
1591
1592 VR_LOCK(sc);
1593 ifp->if_oerrors++;

--- 10 unchanged lines hidden (view full) ---

1604
1605 return;
1606}
1607
1608/*
1609 * Stop the adapter and free any mbufs allocated to the
1610 * RX and TX lists.
1611 */
1615 struct ifnet *ifp;
1616{
1617 struct vr_softc *sc;
1618
1619 sc = ifp->if_softc;
1620
1621 VR_LOCK(sc);
1622 ifp->if_oerrors++;

--- 10 unchanged lines hidden (view full) ---

1633
1634 return;
1635}
1636
1637/*
1638 * Stop the adapter and free any mbufs allocated to the
1639 * RX and TX lists.
1640 */
1612static void vr_stop(sc)
1641static void
1642vr_stop(sc)
1613 struct vr_softc *sc;
1614{
1615 register int i;
1616 struct ifnet *ifp;
1617
1618 VR_LOCK(sc);
1619
1620 ifp = &sc->arpcom.ac_if;

--- 37 unchanged lines hidden (view full) ---

1658
1659 return;
1660}
1661
1662/*
1663 * Stop all chip I/O so that the kernel's probe routines don't
1664 * get confused by errant DMAs when rebooting.
1665 */
1643 struct vr_softc *sc;
1644{
1645 register int i;
1646 struct ifnet *ifp;
1647
1648 VR_LOCK(sc);
1649
1650 ifp = &sc->arpcom.ac_if;

--- 37 unchanged lines hidden (view full) ---

1688
1689 return;
1690}
1691
1692/*
1693 * Stop all chip I/O so that the kernel's probe routines don't
1694 * get confused by errant DMAs when rebooting.
1695 */
1666static void vr_shutdown(dev)
1696static void
1697vr_shutdown(dev)
1667 device_t dev;
1668{
1669 struct vr_softc *sc;
1670
1671 sc = device_get_softc(dev);
1672
1673 vr_stop(sc);
1674
1675 return;
1676}
1698 device_t dev;
1699{
1700 struct vr_softc *sc;
1701
1702 sc = device_get_softc(dev);
1703
1704 vr_stop(sc);
1705
1706 return;
1707}