if_xl.c (3b8f08459569bf0faa21473e5cec2491e95c9349) | if_xl.c (ec4a89771940a2fc38cbfbbe97b0f8bc59893ff6) |
---|---|
1/*- 2 * Copyright (c) 1997, 1998, 1999 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 --- 1852 unchanged lines hidden (view full) --- 1861 1862 /* 1863 * If an error occurs, update stats, clear the 1864 * status word and leave the mbuf cluster in place: 1865 * it should simply get re-used next time this descriptor 1866 * comes up in the ring. 1867 */ 1868 if (rxstat & XL_RXSTAT_UP_ERROR) { | 1/*- 2 * Copyright (c) 1997, 1998, 1999 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 --- 1852 unchanged lines hidden (view full) --- 1861 1862 /* 1863 * If an error occurs, update stats, clear the 1864 * status word and leave the mbuf cluster in place: 1865 * it should simply get re-used next time this descriptor 1866 * comes up in the ring. 1867 */ 1868 if (rxstat & XL_RXSTAT_UP_ERROR) { |
1869 ifp->if_ierrors++; | 1869 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
1870 cur_rx->xl_ptr->xl_status = 0; 1871 bus_dmamap_sync(sc->xl_ldata.xl_rx_tag, 1872 sc->xl_ldata.xl_rx_dmamap, BUS_DMASYNC_PREWRITE); 1873 continue; 1874 } 1875 1876 /* 1877 * If the error bit was not set, the upload complete 1878 * bit should be set which means we have a valid packet. 1879 * If not, something truly strange has happened. 1880 */ 1881 if (!(rxstat & XL_RXSTAT_UP_CMPLT)) { 1882 device_printf(sc->xl_dev, 1883 "bad receive status -- packet dropped\n"); | 1870 cur_rx->xl_ptr->xl_status = 0; 1871 bus_dmamap_sync(sc->xl_ldata.xl_rx_tag, 1872 sc->xl_ldata.xl_rx_dmamap, BUS_DMASYNC_PREWRITE); 1873 continue; 1874 } 1875 1876 /* 1877 * If the error bit was not set, the upload complete 1878 * bit should be set which means we have a valid packet. 1879 * If not, something truly strange has happened. 1880 */ 1881 if (!(rxstat & XL_RXSTAT_UP_CMPLT)) { 1882 device_printf(sc->xl_dev, 1883 "bad receive status -- packet dropped\n"); |
1884 ifp->if_ierrors++; | 1884 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
1885 cur_rx->xl_ptr->xl_status = 0; 1886 bus_dmamap_sync(sc->xl_ldata.xl_rx_tag, 1887 sc->xl_ldata.xl_rx_dmamap, BUS_DMASYNC_PREWRITE); 1888 continue; 1889 } 1890 1891 /* No errors; receive the packet. */ 1892 bus_dmamap_sync(sc->xl_mtag, cur_rx->xl_map, 1893 BUS_DMASYNC_POSTREAD); 1894 m = cur_rx->xl_mbuf; 1895 1896 /* 1897 * Try to conjure up a new mbuf cluster. If that 1898 * fails, it means we have an out of memory condition and 1899 * should leave the buffer in place and continue. This will 1900 * result in a lost packet, but there's little else we 1901 * can do in this situation. 1902 */ 1903 if (xl_newbuf(sc, cur_rx)) { | 1885 cur_rx->xl_ptr->xl_status = 0; 1886 bus_dmamap_sync(sc->xl_ldata.xl_rx_tag, 1887 sc->xl_ldata.xl_rx_dmamap, BUS_DMASYNC_PREWRITE); 1888 continue; 1889 } 1890 1891 /* No errors; receive the packet. */ 1892 bus_dmamap_sync(sc->xl_mtag, cur_rx->xl_map, 1893 BUS_DMASYNC_POSTREAD); 1894 m = cur_rx->xl_mbuf; 1895 1896 /* 1897 * Try to conjure up a new mbuf cluster. If that 1898 * fails, it means we have an out of memory condition and 1899 * should leave the buffer in place and continue. This will 1900 * result in a lost packet, but there's little else we 1901 * can do in this situation. 1902 */ 1903 if (xl_newbuf(sc, cur_rx)) { |
1904 ifp->if_ierrors++; | 1904 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
1905 cur_rx->xl_ptr->xl_status = 0; 1906 bus_dmamap_sync(sc->xl_ldata.xl_rx_tag, 1907 sc->xl_ldata.xl_rx_dmamap, BUS_DMASYNC_PREWRITE); 1908 continue; 1909 } 1910 bus_dmamap_sync(sc->xl_ldata.xl_rx_tag, 1911 sc->xl_ldata.xl_rx_dmamap, BUS_DMASYNC_PREWRITE); 1912 | 1905 cur_rx->xl_ptr->xl_status = 0; 1906 bus_dmamap_sync(sc->xl_ldata.xl_rx_tag, 1907 sc->xl_ldata.xl_rx_dmamap, BUS_DMASYNC_PREWRITE); 1908 continue; 1909 } 1910 bus_dmamap_sync(sc->xl_ldata.xl_rx_tag, 1911 sc->xl_ldata.xl_rx_dmamap, BUS_DMASYNC_PREWRITE); 1912 |
1913 ifp->if_ipackets++; | 1913 if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); |
1914 m->m_pkthdr.rcvif = ifp; 1915 m->m_pkthdr.len = m->m_len = total_len; 1916 1917 if (ifp->if_capenable & IFCAP_RXCSUM) { 1918 /* Do IP checksum checking. */ 1919 if (rxstat & XL_RXSTAT_IPCKOK) 1920 m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; 1921 if (!(rxstat & XL_RXSTAT_IPCKERR)) --- 87 unchanged lines hidden (view full) --- 2009 break; 2010 2011 sc->xl_cdata.xl_tx_head = cur_tx->xl_next; 2012 bus_dmamap_sync(sc->xl_mtag, cur_tx->xl_map, 2013 BUS_DMASYNC_POSTWRITE); 2014 bus_dmamap_unload(sc->xl_mtag, cur_tx->xl_map); 2015 m_freem(cur_tx->xl_mbuf); 2016 cur_tx->xl_mbuf = NULL; | 1914 m->m_pkthdr.rcvif = ifp; 1915 m->m_pkthdr.len = m->m_len = total_len; 1916 1917 if (ifp->if_capenable & IFCAP_RXCSUM) { 1918 /* Do IP checksum checking. */ 1919 if (rxstat & XL_RXSTAT_IPCKOK) 1920 m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED; 1921 if (!(rxstat & XL_RXSTAT_IPCKERR)) --- 87 unchanged lines hidden (view full) --- 2009 break; 2010 2011 sc->xl_cdata.xl_tx_head = cur_tx->xl_next; 2012 bus_dmamap_sync(sc->xl_mtag, cur_tx->xl_map, 2013 BUS_DMASYNC_POSTWRITE); 2014 bus_dmamap_unload(sc->xl_mtag, cur_tx->xl_map); 2015 m_freem(cur_tx->xl_mbuf); 2016 cur_tx->xl_mbuf = NULL; |
2017 ifp->if_opackets++; | 2017 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); |
2018 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; 2019 2020 cur_tx->xl_next = sc->xl_cdata.xl_tx_free; 2021 sc->xl_cdata.xl_tx_free = cur_tx; 2022 } 2023 2024 if (sc->xl_cdata.xl_tx_head == NULL) { 2025 sc->xl_wdog_timer = 0; --- 30 unchanged lines hidden (view full) --- 2056 if (cur_tx->xl_mbuf != NULL) { 2057 bus_dmamap_sync(sc->xl_mtag, cur_tx->xl_map, 2058 BUS_DMASYNC_POSTWRITE); 2059 bus_dmamap_unload(sc->xl_mtag, cur_tx->xl_map); 2060 m_freem(cur_tx->xl_mbuf); 2061 cur_tx->xl_mbuf = NULL; 2062 } 2063 | 2018 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; 2019 2020 cur_tx->xl_next = sc->xl_cdata.xl_tx_free; 2021 sc->xl_cdata.xl_tx_free = cur_tx; 2022 } 2023 2024 if (sc->xl_cdata.xl_tx_head == NULL) { 2025 sc->xl_wdog_timer = 0; --- 30 unchanged lines hidden (view full) --- 2056 if (cur_tx->xl_mbuf != NULL) { 2057 bus_dmamap_sync(sc->xl_mtag, cur_tx->xl_map, 2058 BUS_DMASYNC_POSTWRITE); 2059 bus_dmamap_unload(sc->xl_mtag, cur_tx->xl_map); 2060 m_freem(cur_tx->xl_mbuf); 2061 cur_tx->xl_mbuf = NULL; 2062 } 2063 |
2064 ifp->if_opackets++; | 2064 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); |
2065 2066 sc->xl_cdata.xl_tx_cnt--; 2067 XL_INC(idx, XL_TX_LIST_CNT); 2068 } 2069 2070 if (sc->xl_cdata.xl_tx_cnt == 0) 2071 sc->xl_wdog_timer = 0; 2072 sc->xl_cdata.xl_tx_cons = idx; --- 107 unchanged lines hidden (view full) --- 2180 if (status & XL_STAT_DOWN_COMPLETE) { 2181 if (sc->xl_type == XL_TYPE_905B) 2182 xl_txeof_90xB(sc); 2183 else 2184 xl_txeof(sc); 2185 } 2186 2187 if (status & XL_STAT_TX_COMPLETE) { | 2065 2066 sc->xl_cdata.xl_tx_cnt--; 2067 XL_INC(idx, XL_TX_LIST_CNT); 2068 } 2069 2070 if (sc->xl_cdata.xl_tx_cnt == 0) 2071 sc->xl_wdog_timer = 0; 2072 sc->xl_cdata.xl_tx_cons = idx; --- 107 unchanged lines hidden (view full) --- 2180 if (status & XL_STAT_DOWN_COMPLETE) { 2181 if (sc->xl_type == XL_TYPE_905B) 2182 xl_txeof_90xB(sc); 2183 else 2184 xl_txeof(sc); 2185 } 2186 2187 if (status & XL_STAT_TX_COMPLETE) { |
2188 ifp->if_oerrors++; | 2188 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); |
2189 xl_txeoc(sc); 2190 } 2191 2192 if (status & XL_STAT_ADFAIL) { 2193 ifp->if_drv_flags &= ~IFF_DRV_RUNNING; 2194 xl_init_locked(sc); 2195 break; 2196 } --- 53 unchanged lines hidden (view full) --- 2250 u_int16_t status; 2251 2252 status = CSR_READ_2(sc, XL_STATUS); 2253 if (status & XL_INTRS && status != 0xFFFF) { 2254 CSR_WRITE_2(sc, XL_COMMAND, 2255 XL_CMD_INTR_ACK|(status & XL_INTRS)); 2256 2257 if (status & XL_STAT_TX_COMPLETE) { | 2189 xl_txeoc(sc); 2190 } 2191 2192 if (status & XL_STAT_ADFAIL) { 2193 ifp->if_drv_flags &= ~IFF_DRV_RUNNING; 2194 xl_init_locked(sc); 2195 break; 2196 } --- 53 unchanged lines hidden (view full) --- 2250 u_int16_t status; 2251 2252 status = CSR_READ_2(sc, XL_STATUS); 2253 if (status & XL_INTRS && status != 0xFFFF) { 2254 CSR_WRITE_2(sc, XL_COMMAND, 2255 XL_CMD_INTR_ACK|(status & XL_INTRS)); 2256 2257 if (status & XL_STAT_TX_COMPLETE) { |
2258 ifp->if_oerrors++; | 2258 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); |
2259 xl_txeoc(sc); 2260 } 2261 2262 if (status & XL_STAT_ADFAIL) { 2263 ifp->if_drv_flags &= ~IFF_DRV_RUNNING; 2264 xl_init_locked(sc); 2265 } 2266 --- 40 unchanged lines hidden (view full) --- 2307 p = (u_int8_t *)&xl_stats; 2308 2309 /* Read all the stats registers. */ 2310 XL_SEL_WIN(6); 2311 2312 for (i = 0; i < 16; i++) 2313 *p++ = CSR_READ_1(sc, XL_W6_CARRIER_LOST + i); 2314 | 2259 xl_txeoc(sc); 2260 } 2261 2262 if (status & XL_STAT_ADFAIL) { 2263 ifp->if_drv_flags &= ~IFF_DRV_RUNNING; 2264 xl_init_locked(sc); 2265 } 2266 --- 40 unchanged lines hidden (view full) --- 2307 p = (u_int8_t *)&xl_stats; 2308 2309 /* Read all the stats registers. */ 2310 XL_SEL_WIN(6); 2311 2312 for (i = 0; i < 16; i++) 2313 *p++ = CSR_READ_1(sc, XL_W6_CARRIER_LOST + i); 2314 |
2315 ifp->if_ierrors += xl_stats.xl_rx_overrun; | 2315 if_inc_counter(ifp, IFCOUNTER_IERRORS, xl_stats.xl_rx_overrun); |
2316 | 2316 |
2317 ifp->if_collisions += xl_stats.xl_tx_multi_collision + 2318 xl_stats.xl_tx_single_collision + xl_stats.xl_tx_late_collision; | 2317 if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 2318 xl_stats.xl_tx_multi_collision + 2319 xl_stats.xl_tx_single_collision + 2320 xl_stats.xl_tx_late_collision); |
2319 2320 /* 2321 * Boomerang and cyclone chips have an extra stats counter 2322 * in window 4 (BadSSD). We have to read this too in order 2323 * to clear out all the stats registers and avoid a statsoflow 2324 * interrupt. 2325 */ 2326 XL_SEL_WIN(4); --- 789 unchanged lines hidden (view full) --- 3116 misintr++; 3117 } 3118 if (misintr != 0) { 3119 device_printf(sc->xl_dev, 3120 "watchdog timeout (missed Tx interrupts) -- recovering\n"); 3121 return (0); 3122 } 3123 | 2321 2322 /* 2323 * Boomerang and cyclone chips have an extra stats counter 2324 * in window 4 (BadSSD). We have to read this too in order 2325 * to clear out all the stats registers and avoid a statsoflow 2326 * interrupt. 2327 */ 2328 XL_SEL_WIN(4); --- 789 unchanged lines hidden (view full) --- 3118 misintr++; 3119 } 3120 if (misintr != 0) { 3121 device_printf(sc->xl_dev, 3122 "watchdog timeout (missed Tx interrupts) -- recovering\n"); 3123 return (0); 3124 } 3125 |
3124 ifp->if_oerrors++; | 3126 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); |
3125 XL_SEL_WIN(4); 3126 status = CSR_READ_2(sc, XL_W4_MEDIA_STATUS); 3127 device_printf(sc->xl_dev, "watchdog timeout\n"); 3128 3129 if (status & XL_MEDIASTAT_CARRIER) 3130 device_printf(sc->xl_dev, 3131 "no carrier - transceiver cable problem?\n"); 3132 --- 163 unchanged lines hidden --- | 3127 XL_SEL_WIN(4); 3128 status = CSR_READ_2(sc, XL_W4_MEDIA_STATUS); 3129 device_printf(sc->xl_dev, "watchdog timeout\n"); 3130 3131 if (status & XL_MEDIASTAT_CARRIER) 3132 device_printf(sc->xl_dev, 3133 "no carrier - transceiver cable problem?\n"); 3134 --- 163 unchanged lines hidden --- |