if_ae.c (4e27d36d38f4c3b12bcc1855c5d41527d08d1ce0) if_ae.c (c8dfaf382fa6df9dc6fd1e1c3356e0c8bf607e6a)
1/*-
2 * Copyright (c) 2008 Stanislav Sedov <stas@FreeBSD.org>.
3 * 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

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

1847
1848 /*
1849 * Move txd ack and align on 4-byte boundary.
1850 */
1851 sc->txd_ack = ((sc->txd_ack + le16toh(txd->len) +
1852 sizeof(ae_txs_t) + 3) & ~3) % AE_TXD_BUFSIZE_DEFAULT;
1853
1854 if ((flags & AE_TXS_SUCCESS) != 0)
1/*-
2 * Copyright (c) 2008 Stanislav Sedov <stas@FreeBSD.org>.
3 * 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

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

1847
1848 /*
1849 * Move txd ack and align on 4-byte boundary.
1850 */
1851 sc->txd_ack = ((sc->txd_ack + le16toh(txd->len) +
1852 sizeof(ae_txs_t) + 3) & ~3) % AE_TXD_BUFSIZE_DEFAULT;
1853
1854 if ((flags & AE_TXS_SUCCESS) != 0)
1855 ifp->if_opackets++;
1855 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
1856 else
1856 else
1857 ifp->if_oerrors++;
1857 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
1858
1859 sc->tx_inproc--;
1860 }
1861
1862 if ((sc->flags & AE_FLAG_TXAVAIL) != 0)
1863 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
1864 if (sc->tx_inproc < 0) {
1865 if_printf(ifp, "Received stray Tx interrupt(s).\n");

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

1892 flags = le16toh(rxd->flags);
1893
1894#ifdef AE_DEBUG
1895 if_printf(ifp, "Rx interrupt occuried.\n");
1896#endif
1897 size = le16toh(rxd->len) - ETHER_CRC_LEN;
1898 if (size < (ETHER_MIN_LEN - ETHER_CRC_LEN - ETHER_VLAN_ENCAP_LEN)) {
1899 if_printf(ifp, "Runt frame received.");
1858
1859 sc->tx_inproc--;
1860 }
1861
1862 if ((sc->flags & AE_FLAG_TXAVAIL) != 0)
1863 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
1864 if (sc->tx_inproc < 0) {
1865 if_printf(ifp, "Received stray Tx interrupt(s).\n");

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

1892 flags = le16toh(rxd->flags);
1893
1894#ifdef AE_DEBUG
1895 if_printf(ifp, "Rx interrupt occuried.\n");
1896#endif
1897 size = le16toh(rxd->len) - ETHER_CRC_LEN;
1898 if (size < (ETHER_MIN_LEN - ETHER_CRC_LEN - ETHER_VLAN_ENCAP_LEN)) {
1899 if_printf(ifp, "Runt frame received.");
1900 ifp->if_ierrors++;
1900 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
1901 return;
1902 }
1903
1904 m = m_devget(&rxd->data[0], size, ETHER_ALIGN, ifp, NULL);
1905 if (m == NULL) {
1901 return;
1902 }
1903
1904 m = m_devget(&rxd->data[0], size, ETHER_ALIGN, ifp, NULL);
1905 if (m == NULL) {
1906 ifp->if_iqdrops++;
1906 if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
1907 return;
1908 }
1909
1910 if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0 &&
1911 (flags & AE_RXD_HAS_VLAN) != 0) {
1912 m->m_pkthdr.ether_vtag = AE_RXD_VLAN(le16toh(rxd->vlan));
1913 m->m_flags |= M_VLANTAG;
1914 }
1915
1907 return;
1908 }
1909
1910 if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0 &&
1911 (flags & AE_RXD_HAS_VLAN) != 0) {
1912 m->m_pkthdr.ether_vtag = AE_RXD_VLAN(le16toh(rxd->vlan));
1913 m->m_flags |= M_VLANTAG;
1914 }
1915
1916 ifp->if_ipackets++;
1916 if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
1917 /*
1918 * Pass it through.
1919 */
1920 AE_UNLOCK(sc);
1921 (*ifp->if_input)(ifp, m);
1922 AE_LOCK(sc);
1923}
1924

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

1954 /*
1955 * Update position index.
1956 */
1957 sc->rxd_cur = (sc->rxd_cur + 1) % AE_RXD_COUNT_DEFAULT;
1958
1959 if ((flags & AE_RXD_SUCCESS) != 0)
1960 ae_rxeof(sc, rxd);
1961 else
1917 /*
1918 * Pass it through.
1919 */
1920 AE_UNLOCK(sc);
1921 (*ifp->if_input)(ifp, m);
1922 AE_LOCK(sc);
1923}
1924

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

1954 /*
1955 * Update position index.
1956 */
1957 sc->rxd_cur = (sc->rxd_cur + 1) % AE_RXD_COUNT_DEFAULT;
1958
1959 if ((flags & AE_RXD_SUCCESS) != 0)
1960 ae_rxeof(sc, rxd);
1961 else
1962 ifp->if_ierrors++;
1962 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
1963 }
1964
1965 if (count > 0) {
1966 bus_dmamap_sync(sc->dma_rxd_tag, sc->dma_rxd_map,
1967 BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
1968 /*
1969 * Update Rx index.
1970 */

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

1984 if (sc->wd_timer == 0 || --sc->wd_timer != 0)
1985 return; /* Noting to do. */
1986
1987 if ((sc->flags & AE_FLAG_LINK) == 0)
1988 if_printf(ifp, "watchdog timeout (missed link).\n");
1989 else
1990 if_printf(ifp, "watchdog timeout - resetting.\n");
1991
1963 }
1964
1965 if (count > 0) {
1966 bus_dmamap_sync(sc->dma_rxd_tag, sc->dma_rxd_map,
1967 BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
1968 /*
1969 * Update Rx index.
1970 */

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

1984 if (sc->wd_timer == 0 || --sc->wd_timer != 0)
1985 return; /* Noting to do. */
1986
1987 if ((sc->flags & AE_FLAG_LINK) == 0)
1988 if_printf(ifp, "watchdog timeout (missed link).\n");
1989 else
1990 if_printf(ifp, "watchdog timeout - resetting.\n");
1991
1992 ifp->if_oerrors++;
1992 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
1993 ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
1994 ae_init_locked(sc);
1995 if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
1996 ae_start_locked(ifp);
1997}
1998
1999static void
2000ae_tick(void *arg)

--- 255 unchanged lines hidden ---
1993 ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
1994 ae_init_locked(sc);
1995 if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
1996 ae_start_locked(ifp);
1997}
1998
1999static void
2000ae_tick(void *arg)

--- 255 unchanged lines hidden ---