Deleted Added
full compact
if_lge.c (268529) if_lge.c (271849)
1/*-
2 * Copyright (c) 2001 Wind River Systems
3 * Copyright (c) 1997, 1998, 1999, 2000, 2001
4 * Bill Paul <william.paul@windriver.com>. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001 Wind River Systems
3 * Copyright (c) 1997, 1998, 1999, 2000, 2001
4 * Bill Paul <william.paul@windriver.com>. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/dev/lge/if_lge.c 268529 2014-07-11 13:58:48Z glebius $");
35__FBSDID("$FreeBSD: head/sys/dev/lge/if_lge.c 271849 2014-09-19 03:51:26Z glebius $");
36
37/*
38 * Level 1 LXT1001 gigabit ethernet driver for FreeBSD. Public
39 * documentation not available, but ask me nicely.
40 *
41 * The Level 1 chip is used on some D-Link, SMC and Addtron NICs.
42 * It's a 64-bit PCI part that supports TCP/IP checksum offload,
43 * VLAN tagging/insertion, GMII and TBI (1000baseX) ports. There

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

911
912 /*
913 * If an error occurs, update stats, clear the
914 * status word and leave the mbuf cluster in place:
915 * it should simply get re-used next time this descriptor
916 * comes up in the ring.
917 */
918 if (rxctl & LGE_RXCTL_ERRMASK) {
36
37/*
38 * Level 1 LXT1001 gigabit ethernet driver for FreeBSD. Public
39 * documentation not available, but ask me nicely.
40 *
41 * The Level 1 chip is used on some D-Link, SMC and Addtron NICs.
42 * It's a 64-bit PCI part that supports TCP/IP checksum offload,
43 * VLAN tagging/insertion, GMII and TBI (1000baseX) ports. There

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

911
912 /*
913 * If an error occurs, update stats, clear the
914 * status word and leave the mbuf cluster in place:
915 * it should simply get re-used next time this descriptor
916 * comes up in the ring.
917 */
918 if (rxctl & LGE_RXCTL_ERRMASK) {
919 ifp->if_ierrors++;
919 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
920 lge_newbuf(sc, &LGE_RXTAIL(sc), m);
921 continue;
922 }
923
924 if (lge_newbuf(sc, &LGE_RXTAIL(sc), NULL) == ENOBUFS) {
925 m0 = m_devget(mtod(m, char *), total_len, ETHER_ALIGN,
926 ifp, NULL);
927 lge_newbuf(sc, &LGE_RXTAIL(sc), m);
928 if (m0 == NULL) {
929 device_printf(sc->lge_dev, "no receive buffers "
930 "available -- packet dropped!\n");
920 lge_newbuf(sc, &LGE_RXTAIL(sc), m);
921 continue;
922 }
923
924 if (lge_newbuf(sc, &LGE_RXTAIL(sc), NULL) == ENOBUFS) {
925 m0 = m_devget(mtod(m, char *), total_len, ETHER_ALIGN,
926 ifp, NULL);
927 lge_newbuf(sc, &LGE_RXTAIL(sc), m);
928 if (m0 == NULL) {
929 device_printf(sc->lge_dev, "no receive buffers "
930 "available -- packet dropped!\n");
931 ifp->if_ierrors++;
931 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
932 continue;
933 }
934 m = m0;
935 } else {
936 m->m_pkthdr.rcvif = ifp;
937 m->m_pkthdr.len = m->m_len = total_len;
938 }
939
932 continue;
933 }
934 m = m0;
935 } else {
936 m->m_pkthdr.rcvif = ifp;
937 m->m_pkthdr.len = m->m_len = total_len;
938 }
939
940 ifp->if_ipackets++;
940 if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
941
942 /* Do IP checksum checking. */
943 if (rxsts & LGE_RXSTS_ISIP)
944 m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED;
945 if (!(rxsts & LGE_RXSTS_IPCSUMERR))
946 m->m_pkthdr.csum_flags |= CSUM_IP_VALID;
947 if ((rxsts & LGE_RXSTS_ISTCP &&
948 !(rxsts & LGE_RXSTS_TCPCSUMERR)) ||

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

998 * frames that have been transmitted.
999 */
1000 idx = sc->lge_cdata.lge_tx_cons;
1001 txdone = CSR_READ_1(sc, LGE_TXDMADONE_8BIT);
1002
1003 while (idx != sc->lge_cdata.lge_tx_prod && txdone) {
1004 cur_tx = &sc->lge_ldata->lge_tx_list[idx];
1005
941
942 /* Do IP checksum checking. */
943 if (rxsts & LGE_RXSTS_ISIP)
944 m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED;
945 if (!(rxsts & LGE_RXSTS_IPCSUMERR))
946 m->m_pkthdr.csum_flags |= CSUM_IP_VALID;
947 if ((rxsts & LGE_RXSTS_ISTCP &&
948 !(rxsts & LGE_RXSTS_TCPCSUMERR)) ||

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

998 * frames that have been transmitted.
999 */
1000 idx = sc->lge_cdata.lge_tx_cons;
1001 txdone = CSR_READ_1(sc, LGE_TXDMADONE_8BIT);
1002
1003 while (idx != sc->lge_cdata.lge_tx_prod && txdone) {
1004 cur_tx = &sc->lge_ldata->lge_tx_list[idx];
1005
1006 ifp->if_opackets++;
1006 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
1007 if (cur_tx->lge_mbuf != NULL) {
1008 m_freem(cur_tx->lge_mbuf);
1009 cur_tx->lge_mbuf = NULL;
1010 }
1011 cur_tx->lge_ctl = 0;
1012
1013 txdone--;
1014 LGE_INC(idx, LGE_TX_LIST_CNT);

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

1031 struct mii_data *mii;
1032 struct ifnet *ifp;
1033
1034 sc = xsc;
1035 ifp = sc->lge_ifp;
1036 LGE_LOCK_ASSERT(sc);
1037
1038 CSR_WRITE_4(sc, LGE_STATSIDX, LGE_STATS_SINGLE_COLL_PKTS);
1007 if (cur_tx->lge_mbuf != NULL) {
1008 m_freem(cur_tx->lge_mbuf);
1009 cur_tx->lge_mbuf = NULL;
1010 }
1011 cur_tx->lge_ctl = 0;
1012
1013 txdone--;
1014 LGE_INC(idx, LGE_TX_LIST_CNT);

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

1031 struct mii_data *mii;
1032 struct ifnet *ifp;
1033
1034 sc = xsc;
1035 ifp = sc->lge_ifp;
1036 LGE_LOCK_ASSERT(sc);
1037
1038 CSR_WRITE_4(sc, LGE_STATSIDX, LGE_STATS_SINGLE_COLL_PKTS);
1039 ifp->if_collisions += CSR_READ_4(sc, LGE_STATSVAL);
1039 if_inc_counter(ifp, IFCOUNTER_COLLISIONS, CSR_READ_4(sc, LGE_STATSVAL));
1040 CSR_WRITE_4(sc, LGE_STATSIDX, LGE_STATS_MULTI_COLL_PKTS);
1040 CSR_WRITE_4(sc, LGE_STATSIDX, LGE_STATS_MULTI_COLL_PKTS);
1041 ifp->if_collisions += CSR_READ_4(sc, LGE_STATSVAL);
1041 if_inc_counter(ifp, IFCOUNTER_COLLISIONS, CSR_READ_4(sc, LGE_STATSVAL));
1042
1043 if (!sc->lge_link) {
1044 mii = device_get_softc(sc->lge_miibus);
1045 mii_tick(mii);
1046 if (mii->mii_media_status & IFM_ACTIVE &&
1047 IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) {
1048 sc->lge_link++;
1049 if (bootverbose &&

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

1499lge_watchdog(sc)
1500 struct lge_softc *sc;
1501{
1502 struct ifnet *ifp;
1503
1504 LGE_LOCK_ASSERT(sc);
1505 ifp = sc->lge_ifp;
1506
1042
1043 if (!sc->lge_link) {
1044 mii = device_get_softc(sc->lge_miibus);
1045 mii_tick(mii);
1046 if (mii->mii_media_status & IFM_ACTIVE &&
1047 IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) {
1048 sc->lge_link++;
1049 if (bootverbose &&

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

1499lge_watchdog(sc)
1500 struct lge_softc *sc;
1501{
1502 struct ifnet *ifp;
1503
1504 LGE_LOCK_ASSERT(sc);
1505 ifp = sc->lge_ifp;
1506
1507 ifp->if_oerrors++;
1507 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
1508 if_printf(ifp, "watchdog timeout\n");
1509
1510 lge_stop(sc);
1511 lge_reset(sc);
1512 ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
1513 lge_init_locked(sc);
1514
1515 if (ifp->if_snd.ifq_head != NULL)

--- 73 unchanged lines hidden ---
1508 if_printf(ifp, "watchdog timeout\n");
1509
1510 lge_stop(sc);
1511 lge_reset(sc);
1512 ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
1513 lge_init_locked(sc);
1514
1515 if (ifp->if_snd.ifq_head != NULL)

--- 73 unchanged lines hidden ---