From d61ba7524722fc20d8f0b53e0923b50521ae6cd3 Mon Sep 17 00:00:00 2001 From: Luigi Rizzo Date: Tue, 30 Apr 2013 16:18:29 +0000 Subject: [PATCH] use netmap_rx_irq() / netmap_tx_irq() to handle interrupts in netmap mode, removing the logic from individual drivers. (note: if_lem.c not updated yet due to some other pending modifications) --- sys/dev/e1000/if_em.c | 25 ++++--------------------- sys/dev/e1000/if_igb.c | 27 +++++---------------------- sys/dev/ixgbe/ixgbe.c | 27 ++++----------------------- sys/dev/re/if_re.c | 10 +++------- 4 files changed, 16 insertions(+), 73 deletions(-) diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index 466145e6a091..eedc0fab199f 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -3828,17 +3828,9 @@ em_txeof(struct tx_ring *txr) EM_TX_LOCK_ASSERT(txr); #ifdef DEV_NETMAP - if (ifp->if_capenable & IFCAP_NETMAP) { - struct netmap_adapter *na = NA(ifp); - - selwakeuppri(&na->tx_rings[txr->me].si, PI_NET); - EM_TX_UNLOCK(txr); - EM_CORE_LOCK(adapter); - selwakeuppri(&na->tx_si, PI_NET); - EM_CORE_UNLOCK(adapter); - EM_TX_LOCK(txr); + if (netmap_tx_irq(ifp, txr->me | + (NETMAP_LOCKED_ENTER | NETMAP_LOCKED_EXIT))) return; - } #endif /* DEV_NETMAP */ /* No work, make sure watchdog is off */ @@ -4440,17 +4432,8 @@ em_rxeof(struct rx_ring *rxr, int count, int *done) EM_RX_LOCK(rxr); #ifdef DEV_NETMAP - if (ifp->if_capenable & IFCAP_NETMAP) { - struct netmap_adapter *na = NA(ifp); - - na->rx_rings[rxr->me].nr_kflags |= NKR_PENDINTR; - selwakeuppri(&na->rx_rings[rxr->me].si, PI_NET); - EM_RX_UNLOCK(rxr); - EM_CORE_LOCK(adapter); - selwakeuppri(&na->rx_si, PI_NET); - EM_CORE_UNLOCK(adapter); - return (0); - } + if (netmap_rx_irq(ifp, rxr->me | NETMAP_LOCKED_ENTER, &processed)) + return (FALSE); #endif /* DEV_NETMAP */ for (i = rxr->next_to_check, processed = 0; count != 0;) { diff --git a/sys/dev/e1000/if_igb.c b/sys/dev/e1000/if_igb.c index 21ed4ba0e1a6..3b3c75eff46d 100644 --- a/sys/dev/e1000/if_igb.c +++ b/sys/dev/e1000/if_igb.c @@ -3897,17 +3897,9 @@ igb_txeof(struct tx_ring *txr) IGB_TX_LOCK_ASSERT(txr); #ifdef DEV_NETMAP - if (ifp->if_capenable & IFCAP_NETMAP) { - struct netmap_adapter *na = NA(ifp); - - selwakeuppri(&na->tx_rings[txr->me].si, PI_NET); - IGB_TX_UNLOCK(txr); - IGB_CORE_LOCK(adapter); - selwakeuppri(&na->tx_si, PI_NET); - IGB_CORE_UNLOCK(adapter); - IGB_TX_LOCK(txr); - return FALSE; - } + if (netmap_tx_irq(ifp, txr->me | + (NETMAP_LOCKED_ENTER|NETMAP_LOCKED_EXIT))) + return (FALSE); #endif /* DEV_NETMAP */ if (txr->tx_avail == adapter->num_tx_desc) { txr->queue_status = IGB_QUEUE_IDLE; @@ -4761,17 +4753,8 @@ igb_rxeof(struct igb_queue *que, int count, int *done) BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); #ifdef DEV_NETMAP - if (ifp->if_capenable & IFCAP_NETMAP) { - struct netmap_adapter *na = NA(ifp); - - na->rx_rings[rxr->me].nr_kflags |= NKR_PENDINTR; - selwakeuppri(&na->rx_rings[rxr->me].si, PI_NET); - IGB_RX_UNLOCK(rxr); - IGB_CORE_LOCK(adapter); - selwakeuppri(&na->rx_si, PI_NET); - IGB_CORE_UNLOCK(adapter); - return (0); - } + if (netmap_rx_irq(ifp, rxr->me | NETMAP_LOCKED_ENTER, &processed)) + return (FALSE); #endif /* DEV_NETMAP */ /* Main clean loop */ diff --git a/sys/dev/ixgbe/ixgbe.c b/sys/dev/ixgbe/ixgbe.c index 2ca62f02347f..686e52370a7f 100644 --- a/sys/dev/ixgbe/ixgbe.c +++ b/sys/dev/ixgbe/ixgbe.c @@ -3597,13 +3597,8 @@ ixgbe_txeof(struct tx_ring *txr) if (!netmap_mitigate || (kring->nr_kflags < kring->nkr_num_slots && txd[kring->nr_kflags].wb.status & IXGBE_TXD_STAT_DD)) { - kring->nr_kflags = kring->nkr_num_slots; - selwakeuppri(&na->tx_rings[txr->me].si, PI_NET); - IXGBE_TX_UNLOCK(txr); - IXGBE_CORE_LOCK(adapter); - selwakeuppri(&na->tx_si, PI_NET); - IXGBE_CORE_UNLOCK(adapter); - IXGBE_TX_LOCK(txr); + netmap_tx_irq(ifp, txr->me | + (NETMAP_LOCKED_ENTER|NETMAP_LOCKED_EXIT)); } return FALSE; } @@ -4388,23 +4383,9 @@ ixgbe_rxeof(struct ix_queue *que) IXGBE_RX_LOCK(rxr); #ifdef DEV_NETMAP - if (ifp->if_capenable & IFCAP_NETMAP) { - /* - * Same as the txeof routine: only wakeup clients on intr. - * NKR_PENDINTR in nr_kflags is used to implement interrupt - * mitigation (ixgbe_rxsync() will not look for new packets - * unless NKR_PENDINTR is set). - */ - struct netmap_adapter *na = NA(ifp); - - na->rx_rings[rxr->me].nr_kflags |= NKR_PENDINTR; - selwakeuppri(&na->rx_rings[rxr->me].si, PI_NET); - IXGBE_RX_UNLOCK(rxr); - IXGBE_CORE_LOCK(adapter); - selwakeuppri(&na->rx_si, PI_NET); - IXGBE_CORE_UNLOCK(adapter); + /* Same as the txeof routine: wakeup clients on intr. */ + if (netmap_rx_irq(ifp, rxr->me | NETMAP_LOCKED_ENTER, &processed)) return (FALSE); - } #endif /* DEV_NETMAP */ for (i = rxr->next_to_check; count != 0;) { struct mbuf *sendmp, *mp; diff --git a/sys/dev/re/if_re.c b/sys/dev/re/if_re.c index d9df41a29a4c..44b4d28b4600 100644 --- a/sys/dev/re/if_re.c +++ b/sys/dev/re/if_re.c @@ -2112,11 +2112,9 @@ re_rxeof(struct rl_softc *sc, int *rx_npktsp) ifp = sc->rl_ifp; #ifdef DEV_NETMAP - if (ifp->if_capenable & IFCAP_NETMAP) { - NA(ifp)->rx_rings[0].nr_kflags |= NKR_PENDINTR; - selwakeuppri(&NA(ifp)->rx_rings[0].si, PI_NET); + if (netmap_rx_irq(ifp, 0 | (NETMAP_LOCKED_ENTER|NETMAP_LOCKED_EXIT), + &rx_npkts)) return 0; - } #endif /* DEV_NETMAP */ if (ifp->if_mtu > RL_MTU && (sc->rl_flags & RL_FLAG_JUMBOV2) != 0) jumbo = 1; @@ -2360,10 +2358,8 @@ re_txeof(struct rl_softc *sc) ifp = sc->rl_ifp; #ifdef DEV_NETMAP - if (ifp->if_capenable & IFCAP_NETMAP) { - selwakeuppri(&NA(ifp)->tx_rings[0].si, PI_NET); + if (netmap_tx_irq(ifp, 0 | (NETMAP_LOCKED_ENTER|NETMAP_LOCKED_EXIT))) return; - } #endif /* DEV_NETMAP */ /* Invalidate the TX descriptor list */ bus_dmamap_sync(sc->rl_ldata.rl_tx_list_tag,