if_re.c (217868) | if_re.c (217902) |
---|---|
1/*- 2 * Copyright (c) 1997, 1998-2003 3 * Bill Paul <wpaul@windriver.com>. 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 --- 17 unchanged lines hidden (view full) --- 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 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1997, 1998-2003 3 * Bill Paul <wpaul@windriver.com>. 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 --- 17 unchanged lines hidden (view full) --- 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 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/dev/re/if_re.c 217868 2011-01-25 23:27:28Z yongari $"); | 34__FBSDID("$FreeBSD: head/sys/dev/re/if_re.c 217902 2011-01-26 20:25:40Z yongari $"); |
35 36/* 37 * RealTek 8139C+/8169/8169S/8110S/8168/8111/8101E PCI NIC driver 38 * 39 * Written by Bill Paul <wpaul@windriver.com> 40 * Senior Networking Software Engineer 41 * Wind River Systems 42 */ --- 109 unchanged lines hidden (view full) --- 152MODULE_DEPEND(re, pci, 1, 1, 1); 153MODULE_DEPEND(re, ether, 1, 1, 1); 154MODULE_DEPEND(re, miibus, 1, 1, 1); 155 156/* "device miibus" required. See GENERIC if you get errors here. */ 157#include "miibus_if.h" 158 159/* Tunables. */ | 35 36/* 37 * RealTek 8139C+/8169/8169S/8110S/8168/8111/8101E PCI NIC driver 38 * 39 * Written by Bill Paul <wpaul@windriver.com> 40 * Senior Networking Software Engineer 41 * Wind River Systems 42 */ --- 109 unchanged lines hidden (view full) --- 152MODULE_DEPEND(re, pci, 1, 1, 1); 153MODULE_DEPEND(re, ether, 1, 1, 1); 154MODULE_DEPEND(re, miibus, 1, 1, 1); 155 156/* "device miibus" required. See GENERIC if you get errors here. */ 157#include "miibus_if.h" 158 159/* Tunables. */ |
160static int intr_filter = 0; 161TUNABLE_INT("hw.re.intr_filter", &intr_filter); |
|
160static int msi_disable = 0; 161TUNABLE_INT("hw.re.msi_disable", &msi_disable); 162static int msix_disable = 0; 163TUNABLE_INT("hw.re.msix_disable", &msix_disable); 164static int prefer_iomap = 0; 165TUNABLE_INT("hw.re.prefer_iomap", &prefer_iomap); 166 167#define RE_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP) --- 80 unchanged lines hidden (view full) --- 248#endif 249static int re_rxeof (struct rl_softc *, int *); 250static void re_txeof (struct rl_softc *); 251#ifdef DEVICE_POLLING 252static int re_poll (struct ifnet *, enum poll_cmd, int); 253static int re_poll_locked (struct ifnet *, enum poll_cmd, int); 254#endif 255static int re_intr (void *); | 162static int msi_disable = 0; 163TUNABLE_INT("hw.re.msi_disable", &msi_disable); 164static int msix_disable = 0; 165TUNABLE_INT("hw.re.msix_disable", &msix_disable); 166static int prefer_iomap = 0; 167TUNABLE_INT("hw.re.prefer_iomap", &prefer_iomap); 168 169#define RE_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP) --- 80 unchanged lines hidden (view full) --- 250#endif 251static int re_rxeof (struct rl_softc *, int *); 252static void re_txeof (struct rl_softc *); 253#ifdef DEVICE_POLLING 254static int re_poll (struct ifnet *, enum poll_cmd, int); 255static int re_poll_locked (struct ifnet *, enum poll_cmd, int); 256#endif 257static int re_intr (void *); |
258static void re_intr_msi (void *); |
|
256static void re_tick (void *); 257static void re_int_task (void *, int); 258static void re_start (struct ifnet *); 259static void re_start_locked (struct ifnet *); 260static int re_ioctl (struct ifnet *, u_long, caddr_t); 261static void re_init (void *); 262static void re_init_locked (struct rl_softc *); 263static void re_stop (struct rl_softc *); --- 21 unchanged lines hidden (view full) --- 285static void re_clrwol (struct rl_softc *); 286 287#ifdef RE_DIAG 288static int re_diag (struct rl_softc *); 289#endif 290 291static void re_add_sysctls (struct rl_softc *); 292static int re_sysctl_stats (SYSCTL_HANDLER_ARGS); | 259static void re_tick (void *); 260static void re_int_task (void *, int); 261static void re_start (struct ifnet *); 262static void re_start_locked (struct ifnet *); 263static int re_ioctl (struct ifnet *, u_long, caddr_t); 264static void re_init (void *); 265static void re_init_locked (struct rl_softc *); 266static void re_stop (struct rl_softc *); --- 21 unchanged lines hidden (view full) --- 288static void re_clrwol (struct rl_softc *); 289 290#ifdef RE_DIAG 291static int re_diag (struct rl_softc *); 292#endif 293 294static void re_add_sysctls (struct rl_softc *); 295static int re_sysctl_stats (SYSCTL_HANDLER_ARGS); |
296static int sysctl_int_range (SYSCTL_HANDLER_ARGS, int, int); 297static int sysctl_hw_re_int_mod (SYSCTL_HANDLER_ARGS); |
|
293 294static device_method_t re_methods[] = { 295 /* Device interface */ 296 DEVMETHOD(device_probe, re_probe), 297 DEVMETHOD(device_attach, re_attach), 298 DEVMETHOD(device_detach, re_detach), 299 DEVMETHOD(device_suspend, re_suspend), 300 DEVMETHOD(device_resume, re_resume), --- 1268 unchanged lines hidden (view full) --- 1569 device_printf(dev, 1570 "attach aborted due to hardware diag failure\n"); 1571 ether_ifdetach(ifp); 1572 goto fail; 1573 } 1574 } 1575#endif 1576 | 298 299static device_method_t re_methods[] = { 300 /* Device interface */ 301 DEVMETHOD(device_probe, re_probe), 302 DEVMETHOD(device_attach, re_attach), 303 DEVMETHOD(device_detach, re_detach), 304 DEVMETHOD(device_suspend, re_suspend), 305 DEVMETHOD(device_resume, re_resume), --- 1268 unchanged lines hidden (view full) --- 1574 device_printf(dev, 1575 "attach aborted due to hardware diag failure\n"); 1576 ether_ifdetach(ifp); 1577 goto fail; 1578 } 1579 } 1580#endif 1581 |
1582#ifdef RE_TX_MODERATION 1583 intr_filter = 1; 1584#endif |
|
1577 /* Hook interrupt last to avoid having to lock softc */ | 1585 /* Hook interrupt last to avoid having to lock softc */ |
1578 if ((sc->rl_flags & (RL_FLAG_MSI | RL_FLAG_MSIX)) == 0) | 1586 if ((sc->rl_flags & (RL_FLAG_MSI | RL_FLAG_MSIX)) != 0 && 1587 intr_filter == 0) { |
1579 error = bus_setup_intr(dev, sc->rl_irq[0], | 1588 error = bus_setup_intr(dev, sc->rl_irq[0], |
1589 INTR_TYPE_NET | INTR_MPSAFE, NULL, re_intr_msi, sc, 1590 &sc->rl_intrhand[0]); 1591 } else { 1592 error = bus_setup_intr(dev, sc->rl_irq[0], |
|
1580 INTR_TYPE_NET | INTR_MPSAFE, re_intr, NULL, sc, 1581 &sc->rl_intrhand[0]); | 1593 INTR_TYPE_NET | INTR_MPSAFE, re_intr, NULL, sc, 1594 &sc->rl_intrhand[0]); |
1582 else { 1583 for (i = 0; i < RL_MSI_MESSAGES; i++) { 1584 error = bus_setup_intr(dev, sc->rl_irq[i], 1585 INTR_TYPE_NET | INTR_MPSAFE, re_intr, NULL, sc, 1586 &sc->rl_intrhand[i]); 1587 if (error != 0) 1588 break; 1589 } | |
1590 } 1591 if (error) { 1592 device_printf(dev, "couldn't set up irq\n"); 1593 ether_ifdetach(ifp); 1594 } 1595 1596fail: 1597 --- 54 unchanged lines hidden (view full) --- 1652 device_delete_child(dev, sc->rl_miibus); 1653 bus_generic_detach(dev); 1654 1655 /* 1656 * The rest is resource deallocation, so we should already be 1657 * stopped here. 1658 */ 1659 | 1595 } 1596 if (error) { 1597 device_printf(dev, "couldn't set up irq\n"); 1598 ether_ifdetach(ifp); 1599 } 1600 1601fail: 1602 --- 54 unchanged lines hidden (view full) --- 1657 device_delete_child(dev, sc->rl_miibus); 1658 bus_generic_detach(dev); 1659 1660 /* 1661 * The rest is resource deallocation, so we should already be 1662 * stopped here. 1663 */ 1664 |
1660 for (i = 0; i < RL_MSI_MESSAGES; i++) { 1661 if (sc->rl_intrhand[i] != NULL) { 1662 bus_teardown_intr(dev, sc->rl_irq[i], 1663 sc->rl_intrhand[i]); 1664 sc->rl_intrhand[i] = NULL; 1665 } | 1665 if (sc->rl_intrhand[0] != NULL) { 1666 bus_teardown_intr(dev, sc->rl_irq[0], sc->rl_intrhand[0]); 1667 sc->rl_intrhand[0] = NULL; |
1666 } 1667 if (ifp != NULL) 1668 if_free(ifp); | 1668 } 1669 if (ifp != NULL) 1670 if_free(ifp); |
1669 if ((sc->rl_flags & (RL_FLAG_MSI | RL_FLAG_MSIX)) == 0) { 1670 if (sc->rl_irq[0] != NULL) { 1671 bus_release_resource(dev, SYS_RES_IRQ, 0, 1672 sc->rl_irq[0]); 1673 sc->rl_irq[0] = NULL; 1674 } 1675 } else { 1676 for (i = 0, rid = 1; i < RL_MSI_MESSAGES; i++, rid++) { 1677 if (sc->rl_irq[i] != NULL) { 1678 bus_release_resource(dev, SYS_RES_IRQ, rid, 1679 sc->rl_irq[i]); 1680 sc->rl_irq[i] = NULL; 1681 } 1682 } 1683 pci_release_msi(dev); | 1671 if ((sc->rl_flags & (RL_FLAG_MSI | RL_FLAG_MSIX)) == 0) 1672 rid = 0; 1673 else 1674 rid = 1; 1675 if (sc->rl_irq[0] != NULL) { 1676 bus_release_resource(dev, SYS_RES_IRQ, rid, sc->rl_irq[0]); 1677 sc->rl_irq[0] = NULL; |
1684 } | 1678 } |
1679 if ((sc->rl_flags & (RL_FLAG_MSI | RL_FLAG_MSIX)) != 0) 1680 pci_release_msi(dev); |
|
1685 if (sc->rl_res_pba) { 1686 rid = PCIR_BAR(4); 1687 bus_release_resource(dev, SYS_RES_MEMORY, rid, sc->rl_res_pba); 1688 } 1689 if (sc->rl_res) 1690 bus_release_resource(dev, sc->rl_res_type, sc->rl_res_id, 1691 sc->rl_res); 1692 --- 272 unchanged lines hidden (view full) --- 1965 /* Flush the RX descriptors */ 1966 1967 bus_dmamap_sync(sc->rl_ldata.rl_rx_list_tag, 1968 sc->rl_ldata.rl_rx_list_map, 1969 BUS_DMASYNC_PREWRITE|BUS_DMASYNC_PREREAD); 1970 1971 sc->rl_ldata.rl_rx_prodidx = 0; 1972 sc->rl_head = sc->rl_tail = NULL; | 1681 if (sc->rl_res_pba) { 1682 rid = PCIR_BAR(4); 1683 bus_release_resource(dev, SYS_RES_MEMORY, rid, sc->rl_res_pba); 1684 } 1685 if (sc->rl_res) 1686 bus_release_resource(dev, sc->rl_res_type, sc->rl_res_id, 1687 sc->rl_res); 1688 --- 272 unchanged lines hidden (view full) --- 1961 /* Flush the RX descriptors */ 1962 1963 bus_dmamap_sync(sc->rl_ldata.rl_rx_list_tag, 1964 sc->rl_ldata.rl_rx_list_map, 1965 BUS_DMASYNC_PREWRITE|BUS_DMASYNC_PREREAD); 1966 1967 sc->rl_ldata.rl_rx_prodidx = 0; 1968 sc->rl_head = sc->rl_tail = NULL; |
1969 sc->rl_int_rx_act = 0; |
|
1973 1974 return (0); 1975} 1976 1977static int 1978re_jrx_list_init(struct rl_softc *sc) 1979{ 1980 int error, i; --- 7 unchanged lines hidden (view full) --- 1988 } 1989 1990 bus_dmamap_sync(sc->rl_ldata.rl_rx_list_tag, 1991 sc->rl_ldata.rl_rx_list_map, 1992 BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); 1993 1994 sc->rl_ldata.rl_rx_prodidx = 0; 1995 sc->rl_head = sc->rl_tail = NULL; | 1970 1971 return (0); 1972} 1973 1974static int 1975re_jrx_list_init(struct rl_softc *sc) 1976{ 1977 int error, i; --- 7 unchanged lines hidden (view full) --- 1985 } 1986 1987 bus_dmamap_sync(sc->rl_ldata.rl_rx_list_tag, 1988 sc->rl_ldata.rl_rx_list_map, 1989 BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); 1990 1991 sc->rl_ldata.rl_rx_prodidx = 0; 1992 sc->rl_head = sc->rl_tail = NULL; |
1993 sc->rl_int_rx_act = 0; |
|
1996 1997 return (0); 1998} 1999 2000/* 2001 * RX handler for C+ and 8169. For the gigE chips, we support 2002 * the reception of jumbo frames that have been fragmented 2003 * across multiple 2K mbuf cluster buffers. --- 469 unchanged lines hidden (view full) --- 2473 if ((CSR_READ_2(sc, RL_ISR) & RL_INTRS_CPLUS) || rval) { 2474 taskqueue_enqueue_fast(taskqueue_fast, &sc->rl_inttask); 2475 return; 2476 } 2477 2478 CSR_WRITE_2(sc, RL_IMR, RL_INTRS_CPLUS); 2479} 2480 | 1994 1995 return (0); 1996} 1997 1998/* 1999 * RX handler for C+ and 8169. For the gigE chips, we support 2000 * the reception of jumbo frames that have been fragmented 2001 * across multiple 2K mbuf cluster buffers. --- 469 unchanged lines hidden (view full) --- 2471 if ((CSR_READ_2(sc, RL_ISR) & RL_INTRS_CPLUS) || rval) { 2472 taskqueue_enqueue_fast(taskqueue_fast, &sc->rl_inttask); 2473 return; 2474 } 2475 2476 CSR_WRITE_2(sc, RL_IMR, RL_INTRS_CPLUS); 2477} 2478 |
2479static void 2480re_intr_msi(void *xsc) 2481{ 2482 struct rl_softc *sc; 2483 struct ifnet *ifp; 2484 uint16_t intrs, status; 2485 2486 sc = xsc; 2487 RL_LOCK(sc); 2488 2489 ifp = sc->rl_ifp; 2490#ifdef DEVICE_POLLING 2491 if (ifp->if_capenable & IFCAP_POLLING) { 2492 RL_UNLOCK(sc); 2493 return; 2494 } 2495#endif 2496 /* Disable interrupts. */ 2497 CSR_WRITE_2(sc, RL_IMR, 0); 2498 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { 2499 RL_UNLOCK(sc); 2500 return; 2501 } 2502 2503 intrs = RL_INTRS_CPLUS; 2504 status = CSR_READ_2(sc, RL_ISR); 2505 CSR_WRITE_2(sc, RL_ISR, status); 2506 if (sc->rl_int_rx_act > 0) { 2507 intrs &= ~(RL_ISR_RX_OK | RL_ISR_RX_ERR | RL_ISR_FIFO_OFLOW | 2508 RL_ISR_RX_OVERRUN); 2509 status &= ~(RL_ISR_RX_OK | RL_ISR_RX_ERR | RL_ISR_FIFO_OFLOW | 2510 RL_ISR_RX_OVERRUN); 2511 } 2512 2513 if (status & (RL_ISR_TIMEOUT_EXPIRED | RL_ISR_RX_OK | RL_ISR_RX_ERR | 2514 RL_ISR_FIFO_OFLOW | RL_ISR_RX_OVERRUN)) { 2515 re_rxeof(sc, NULL); 2516 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { 2517 if (sc->rl_int_rx_mod != 0 && 2518 (status & (RL_ISR_RX_OK | RL_ISR_RX_ERR | 2519 RL_ISR_FIFO_OFLOW | RL_ISR_RX_OVERRUN)) != 0) { 2520 /* Rearm one-shot timer. */ 2521 CSR_WRITE_4(sc, RL_TIMERCNT, 1); 2522 intrs &= ~(RL_ISR_RX_OK | RL_ISR_RX_ERR | 2523 RL_ISR_FIFO_OFLOW | RL_ISR_RX_OVERRUN); 2524 sc->rl_int_rx_act = 1; 2525 } else { 2526 intrs |= RL_ISR_RX_OK | RL_ISR_RX_ERR | 2527 RL_ISR_FIFO_OFLOW | RL_ISR_RX_OVERRUN; 2528 sc->rl_int_rx_act = 0; 2529 } 2530 } 2531 } 2532 2533 /* 2534 * Some chips will ignore a second TX request issued 2535 * while an existing transmission is in progress. If 2536 * the transmitter goes idle but there are still 2537 * packets waiting to be sent, we need to restart the 2538 * channel here to flush them out. This only seems to 2539 * be required with the PCIe devices. 2540 */ 2541 if ((status & (RL_ISR_TX_OK | RL_ISR_TX_DESC_UNAVAIL)) && 2542 (sc->rl_flags & RL_FLAG_PCIE)) 2543 CSR_WRITE_1(sc, sc->rl_txstart, RL_TXSTART_START); 2544 if (status & (RL_ISR_TX_OK | RL_ISR_TX_ERR | RL_ISR_TX_DESC_UNAVAIL)) 2545 re_txeof(sc); 2546 2547 if (status & RL_ISR_SYSTEM_ERR) { 2548 ifp->if_drv_flags &= ~IFF_DRV_RUNNING; 2549 re_init_locked(sc); 2550 } 2551 2552 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { 2553 if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) 2554 re_start_locked(ifp); 2555 CSR_WRITE_2(sc, RL_IMR, intrs); 2556 } 2557 RL_UNLOCK(sc); 2558} 2559 |
|
2481static int 2482re_encap(struct rl_softc *sc, struct mbuf **m_head) 2483{ 2484 struct rl_txdesc *txd, *txd_last; 2485 bus_dma_segment_t segs[RL_NTXSEGS]; 2486 bus_dmamap_t map; 2487 struct mbuf *m_new; 2488 struct rl_desc *desc; --- 513 unchanged lines hidden (view full) --- 3002 3003 /* Start RX/TX process. */ 3004 CSR_WRITE_4(sc, RL_MISSEDPKT, 0); 3005#ifdef notdef 3006 /* Enable receiver and transmitter. */ 3007 CSR_WRITE_1(sc, RL_COMMAND, RL_CMD_TX_ENB|RL_CMD_RX_ENB); 3008#endif 3009 | 2560static int 2561re_encap(struct rl_softc *sc, struct mbuf **m_head) 2562{ 2563 struct rl_txdesc *txd, *txd_last; 2564 bus_dma_segment_t segs[RL_NTXSEGS]; 2565 bus_dmamap_t map; 2566 struct mbuf *m_new; 2567 struct rl_desc *desc; --- 513 unchanged lines hidden (view full) --- 3081 3082 /* Start RX/TX process. */ 3083 CSR_WRITE_4(sc, RL_MISSEDPKT, 0); 3084#ifdef notdef 3085 /* Enable receiver and transmitter. */ 3086 CSR_WRITE_1(sc, RL_COMMAND, RL_CMD_TX_ENB|RL_CMD_RX_ENB); 3087#endif 3088 |
3010#ifdef RE_TX_MODERATION | |
3011 /* 3012 * Initialize the timer interrupt register so that 3013 * a timer interrupt will be generated once the timer 3014 * reaches a certain number of ticks. The timer is | 3089 /* 3090 * Initialize the timer interrupt register so that 3091 * a timer interrupt will be generated once the timer 3092 * reaches a certain number of ticks. The timer is |
3015 * reloaded on each transmit. This gives us TX interrupt | 3093 * reloaded on each transmit. 3094 */ 3095#ifdef RE_TX_MODERATION 3096 /* 3097 * Use timer interrupt register to moderate TX interrupt |
3016 * moderation, which dramatically improves TX frame rate. 3017 */ 3018 if (sc->rl_type == RL_8169) 3019 CSR_WRITE_4(sc, RL_TIMERINT_8169, 0x800); 3020 else 3021 CSR_WRITE_4(sc, RL_TIMERINT, 0x400); | 3098 * moderation, which dramatically improves TX frame rate. 3099 */ 3100 if (sc->rl_type == RL_8169) 3101 CSR_WRITE_4(sc, RL_TIMERINT_8169, 0x800); 3102 else 3103 CSR_WRITE_4(sc, RL_TIMERINT, 0x400); |
3104#else 3105 /* 3106 * Use timer interrupt register to moderate RX interrupt 3107 * moderation. 3108 */ 3109 if ((sc->rl_flags & (RL_FLAG_MSI | RL_FLAG_MSIX)) != 0 && 3110 intr_filter == 0) { 3111 if (sc->rl_type == RL_8169) 3112 CSR_WRITE_4(sc, RL_TIMERINT_8169, 3113 RL_USECS(sc->rl_int_rx_mod)); 3114 } else { 3115 if (sc->rl_type == RL_8169) 3116 CSR_WRITE_4(sc, RL_TIMERINT_8169, RL_USECS(0)); 3117 } |
|
3022#endif 3023 3024 /* 3025 * For 8169 gigE NICs, set the max allowed RX packet 3026 * size so we can receive jumbo frames. 3027 */ 3028 if (sc->rl_type == RL_8169) { 3029 if ((sc->rl_flags & RL_FLAG_JUMBOV2) != 0) { --- 500 unchanged lines hidden (view full) --- 3530 CSR_WRITE_1(sc, RL_CFG5, v); 3531} 3532 3533static void 3534re_add_sysctls(struct rl_softc *sc) 3535{ 3536 struct sysctl_ctx_list *ctx; 3537 struct sysctl_oid_list *children; | 3118#endif 3119 3120 /* 3121 * For 8169 gigE NICs, set the max allowed RX packet 3122 * size so we can receive jumbo frames. 3123 */ 3124 if (sc->rl_type == RL_8169) { 3125 if ((sc->rl_flags & RL_FLAG_JUMBOV2) != 0) { --- 500 unchanged lines hidden (view full) --- 3626 CSR_WRITE_1(sc, RL_CFG5, v); 3627} 3628 3629static void 3630re_add_sysctls(struct rl_softc *sc) 3631{ 3632 struct sysctl_ctx_list *ctx; 3633 struct sysctl_oid_list *children; |
3634 int error; |
|
3538 3539 ctx = device_get_sysctl_ctx(sc->rl_dev); 3540 children = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->rl_dev)); 3541 3542 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "stats", 3543 CTLTYPE_INT | CTLFLAG_RW, sc, 0, re_sysctl_stats, "I", 3544 "Statistics Information"); | 3635 3636 ctx = device_get_sysctl_ctx(sc->rl_dev); 3637 children = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->rl_dev)); 3638 3639 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "stats", 3640 CTLTYPE_INT | CTLFLAG_RW, sc, 0, re_sysctl_stats, "I", 3641 "Statistics Information"); |
3642 if ((sc->rl_flags & (RL_FLAG_MSI | RL_FLAG_MSIX)) == 0) 3643 return; 3644 3645 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "int_rx_mod", 3646 CTLTYPE_INT | CTLFLAG_RW, &sc->rl_int_rx_mod, 0, 3647 sysctl_hw_re_int_mod, "I", "re RX interrupt moderation"); 3648 /* Pull in device tunables. */ 3649 sc->rl_int_rx_mod = RL_TIMER_DEFAULT; 3650 error = resource_int_value(device_get_name(sc->rl_dev), 3651 device_get_unit(sc->rl_dev), "int_rx_mod", &sc->rl_int_rx_mod); 3652 if (error == 0) { 3653 if (sc->rl_int_rx_mod < RL_TIMER_MIN || 3654 sc->rl_int_rx_mod > RL_TIMER_MAX) { 3655 device_printf(sc->rl_dev, "int_rx_mod value out of " 3656 "range; using default: %d\n", 3657 RL_TIMER_DEFAULT); 3658 sc->rl_int_rx_mod = RL_TIMER_DEFAULT; 3659 } 3660 } 3661 |
|
3545} 3546 3547static int 3548re_sysctl_stats(SYSCTL_HANDLER_ARGS) 3549{ 3550 struct rl_softc *sc; 3551 struct rl_stats *stats; 3552 int error, i, result; --- 61 unchanged lines hidden (view full) --- 3614 printf("Tx aborts : %u\n", 3615 (uint32_t)le16toh(stats->rl_tx_aborts)); 3616 printf("Tx underruns : %u\n", 3617 (uint32_t)le16toh(stats->rl_rx_underruns)); 3618 } 3619 3620 return (error); 3621} | 3662} 3663 3664static int 3665re_sysctl_stats(SYSCTL_HANDLER_ARGS) 3666{ 3667 struct rl_softc *sc; 3668 struct rl_stats *stats; 3669 int error, i, result; --- 61 unchanged lines hidden (view full) --- 3731 printf("Tx aborts : %u\n", 3732 (uint32_t)le16toh(stats->rl_tx_aborts)); 3733 printf("Tx underruns : %u\n", 3734 (uint32_t)le16toh(stats->rl_rx_underruns)); 3735 } 3736 3737 return (error); 3738} |
3739 3740static int 3741sysctl_int_range(SYSCTL_HANDLER_ARGS, int low, int high) 3742{ 3743 int error, value; 3744 3745 if (arg1 == NULL) 3746 return (EINVAL); 3747 value = *(int *)arg1; 3748 error = sysctl_handle_int(oidp, &value, 0, req); 3749 if (error || req->newptr == NULL) 3750 return (error); 3751 if (value < low || value > high) 3752 return (EINVAL); 3753 *(int *)arg1 = value; 3754 3755 return (0); 3756} 3757 3758static int 3759sysctl_hw_re_int_mod(SYSCTL_HANDLER_ARGS) 3760{ 3761 3762 return (sysctl_int_range(oidp, arg1, arg2, req, RL_TIMER_MIN, 3763 RL_TIMER_MAX)); 3764} |
|