From owner-svn-src-all@FreeBSD.ORG Thu May 17 15:03:17 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 34EA6106564A; Thu, 17 May 2012 15:03:17 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 158408FC20; Thu, 17 May 2012 15:03:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q4HF3GFN003974; Thu, 17 May 2012 15:03:16 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q4HF3G5H003972; Thu, 17 May 2012 15:03:16 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201205171503.q4HF3G5H003972@svn.freebsd.org> From: Luigi Rizzo Date: Thu, 17 May 2012 15:03:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235550 - stable/9/sys/dev/re X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 May 2012 15:03:17 -0000 Author: luigi Date: Thu May 17 15:03:16 2012 New Revision: 235550 URL: http://svn.freebsd.org/changeset/base/235550 Log: MFC: netmap support for the 're' driver Modified: stable/9/sys/dev/re/if_re.c Modified: stable/9/sys/dev/re/if_re.c ============================================================================== --- stable/9/sys/dev/re/if_re.c Thu May 17 15:02:51 2012 (r235549) +++ stable/9/sys/dev/re/if_re.c Thu May 17 15:03:16 2012 (r235550) @@ -296,6 +296,10 @@ static void re_setwol (struct rl_softc static void re_clrwol (struct rl_softc *); static void re_set_linkspeed (struct rl_softc *); +#ifdef DEV_NETMAP /* see ixgbe.c for details */ +#include +#endif /* !DEV_NETMAP */ + #ifdef RE_DIAG static int re_diag (struct rl_softc *); #endif @@ -1641,6 +1645,9 @@ re_attach(device_t dev) */ ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header); +#ifdef DEV_NETMAP + re_netmap_attach(sc); +#endif /* DEV_NETMAP */ #ifdef RE_DIAG /* * Perform hardware diagnostic on the original RTL8169. @@ -1836,6 +1843,9 @@ re_detach(device_t dev) bus_dma_tag_destroy(sc->rl_ldata.rl_stag); } +#ifdef DEV_NETMAP + netmap_detach(ifp); +#endif /* DEV_NETMAP */ if (sc->rl_parent_tag) bus_dma_tag_destroy(sc->rl_parent_tag); @@ -2010,6 +2020,9 @@ re_tx_list_init(struct rl_softc *sc) sc->rl_ldata.rl_tx_desc_cnt * sizeof(struct rl_desc)); for (i = 0; i < sc->rl_ldata.rl_tx_desc_cnt; i++) sc->rl_ldata.rl_tx_desc[i].tx_m = NULL; +#ifdef DEV_NETMAP + re_netmap_tx_init(sc); +#endif /* DEV_NETMAP */ /* Set EOR. */ desc = &sc->rl_ldata.rl_tx_list[sc->rl_ldata.rl_tx_desc_cnt - 1]; desc->rl_cmdstat |= htole32(RL_TDESC_CMD_EOR); @@ -2037,6 +2050,9 @@ re_rx_list_init(struct rl_softc *sc) if ((error = re_newbuf(sc, i)) != 0) return (error); } +#ifdef DEV_NETMAP + re_netmap_rx_init(sc); +#endif /* DEV_NETMAP */ /* Flush the RX descriptors */ @@ -2093,6 +2109,13 @@ re_rxeof(struct rl_softc *sc, int *rx_np RL_LOCK_ASSERT(sc); ifp = sc->rl_ifp; +#ifdef DEV_NETMAP + if (ifp->if_capenable & IFCAP_NETMAP) { + NA(ifp)->rx_rings->nr_kflags |= NKR_PENDINTR; + selwakeuppri(&NA(ifp)->rx_rings->si, PI_NET); + return 0; + } +#endif /* DEV_NETMAP */ if (ifp->if_mtu > RL_MTU && (sc->rl_flags & RL_FLAG_JUMBOV2) != 0) jumbo = 1; else @@ -2334,6 +2357,12 @@ re_txeof(struct rl_softc *sc) return; ifp = sc->rl_ifp; +#ifdef DEV_NETMAP + if (ifp->if_capenable & IFCAP_NETMAP) { + selwakeuppri(&NA(ifp)->tx_rings[0].si, PI_NET); + return; + } +#endif /* DEV_NETMAP */ /* Invalidate the TX descriptor list */ bus_dmamap_sync(sc->rl_ldata.rl_tx_list_tag, sc->rl_ldata.rl_tx_list_map, @@ -2852,6 +2881,21 @@ re_start_locked(struct ifnet *ifp) sc = ifp->if_softc; +#ifdef DEV_NETMAP + /* XXX is this necessary ? */ + if (ifp->if_capenable & IFCAP_NETMAP) { + struct netmap_kring *kring = &NA(ifp)->tx_rings[0]; + if (sc->rl_ldata.rl_tx_prodidx != kring->nr_hwcur) { + /* kick the tx unit */ + CSR_WRITE_1(sc, sc->rl_txstart, RL_TXSTART_START); +#ifdef RE_TX_MODERATION + CSR_WRITE_4(sc, RL_TIMERCNT, 1); +#endif + sc->rl_watchdog_timer = 5; + } + return; + } +#endif /* DEV_NETMAP */ if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING || (sc->rl_flags & RL_FLAG_LINK) == 0) return;