From owner-svn-src-projects@FreeBSD.ORG Fri Oct 8 11:16:48 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6D59D106566B; Fri, 8 Oct 2010 11:16:48 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5C0788FC17; Fri, 8 Oct 2010 11:16:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o98BGm3Q091575; Fri, 8 Oct 2010 11:16:48 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o98BGmrs091572; Fri, 8 Oct 2010 11:16:48 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201010081116.o98BGmrs091572@svn.freebsd.org> From: Attilio Rao Date: Fri, 8 Oct 2010 11:16:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213570 - projects/sv/sys/dev/ixgb X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 11:16:48 -0000 Author: attilio Date: Fri Oct 8 11:16:48 2010 New Revision: 213570 URL: http://svn.freebsd.org/changeset/base/213570 Log: Add netdump support for ixgb(4) interface. Modified: projects/sv/sys/dev/ixgb/if_ixgb.c projects/sv/sys/dev/ixgb/if_ixgb.h Modified: projects/sv/sys/dev/ixgb/if_ixgb.c ============================================================================== --- projects/sv/sys/dev/ixgb/if_ixgb.c Fri Oct 8 10:42:16 2010 (r213569) +++ projects/sv/sys/dev/ixgb/if_ixgb.c Fri Oct 8 11:16:48 2010 (r213570) @@ -35,10 +35,24 @@ POSSIBILITY OF SUCH DAMAGE. #ifdef HAVE_KERNEL_OPTION_HEADERS #include "opt_device_polling.h" +#include "opt_netdump.h" #endif #include +#if defined(DEVICE_POLLING) || defined(NETDUMP_CLIENT) + +#define IXGB_LOCK_COND(adapter, locking) do { \ + if ((locking) != 0) \ + IXGB_LOCK(adapter); \ +} while (0) +#define IXGB_UNLOCK_COND(adapter, locking) do { \ + if ((locking) != 0) \ + IXGB_UNLOCK(adapter); \ +} while (0) + +#endif + /********************************************************************* * Set this to one to display debug statistics *********************************************************************/ @@ -145,14 +159,32 @@ static int ixgb_dma_malloc(struct adapter *, bus_size_t, struct ixgb_dma_alloc *, int); static void ixgb_dma_free(struct adapter *, struct ixgb_dma_alloc *); -#ifdef DEVICE_POLLING +#if defined(DEVICE_POLLING) || defined(NETDUMP_CLIENT) +static int _ixgb_poll_generic(struct ifnet *ifp, enum poll_cmd cmd, + int count, int locking); static poll_handler_t ixgb_poll; #endif +#ifdef NETDUMP_CLIENT +static poll_handler_t ixgb_poll_unlocked; +static ndumplock_handler_t ixgb_ndump_disable_intr; +static ndumplock_handler_t ixgb_ndump_enable_intr; +#endif /********************************************************************* * FreeBSD Device Interface Entry Points *********************************************************************/ +#ifdef NETDUMP_CLIENT + +static struct netdump_methods ixgb_ndump_methods = { + .ne_poll_locked = ixgb_poll, + .ne_poll_unlocked = ixgb_poll_unlocked, + .ne_disable_intr = ixgb_ndump_disable_intr, + .ne_enable_intr = ixgb_ndump_enable_intr +}; + +#endif + static device_method_t ixgb_methods[] = { /* Device interface */ DEVMETHOD(device_probe, ixgb_probe), @@ -750,7 +782,7 @@ ixgb_init(void *arg) return; } -#ifdef DEVICE_POLLING +#if defined(DEVICE_POLLING) || defined(NETDUMP_CLIENT) static int ixgb_poll_locked(struct ifnet * ifp, enum poll_cmd cmd, int count) { @@ -776,18 +808,57 @@ ixgb_poll_locked(struct ifnet * ifp, enu } static int -ixgb_poll(struct ifnet * ifp, enum poll_cmd cmd, int count) +_ixgb_poll_generic(struct ifnet * ifp, enum poll_cmd cmd, int count, + int locking) { struct adapter *adapter = ifp->if_softc; int rx_npkts = 0; - IXGB_LOCK(adapter); + IXGB_LOCK_COND(adapter, locking); if (ifp->if_drv_flags & IFF_DRV_RUNNING) rx_npkts = ixgb_poll_locked(ifp, cmd, count); - IXGB_UNLOCK(adapter); + IXGB_UNLOCK_COND(adapter, locking); return (rx_npkts); } -#endif /* DEVICE_POLLING */ + +static int +ixgb_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) +{ + + return (_ixgb_poll_generic(ifp, cmd, count, 1)); +} +#endif /* !DEVICE_POLLING && !NETDUMP_CLIENT */ + +#ifdef NETDUMP_CLIENT +static int +ixgb_poll_unlocked(struct ifnet *ifp, enum poll_cmd cmd, int count) +{ + + return (_ixgb_poll_generic(ifp, cmd, count, 0)); +} + +static void +ixgb_ndump_disable_intr(struct ifnet *ifp) +{ + struct adapter *adapter; + + adapter = ifp->if_softc; + IXGB_LOCK(adapter); + ixgb_disable_intr(adapter); + IXGB_UNLOCK(adapter); +} + +static void +ixgb_ndump_enable_intr(struct ifnet *ifp) +{ + struct adapter *adapter; + + adapter = ifp->if_softc; + IXGB_LOCK(adapter); + ixgb_enable_intr(adapter); + IXGB_UNLOCK(adapter); +} +#endif /* !NETDUMP_CLIENT */ /********************************************************************* * @@ -1362,6 +1433,9 @@ ixgb_setup_interface(device_t dev, struc ifp->if_ioctl = ixgb_ioctl; ifp->if_start = ixgb_start; ifp->if_snd.ifq_maxlen = adapter->num_tx_desc - 1; +#ifdef NETDUMP_CLIENT + ifp->if_ndumpfuncs = &ixgb_ndump_methods; +#endif #if __FreeBSD_version < 500000 ether_ifattach(ifp, ETHER_BPF_SUPPORTED); Modified: projects/sv/sys/dev/ixgb/if_ixgb.h ============================================================================== --- projects/sv/sys/dev/ixgb/if_ixgb.h Fri Oct 8 10:42:16 2010 (r213569) +++ projects/sv/sys/dev/ixgb/if_ixgb.h Fri Oct 8 11:16:48 2010 (r213570) @@ -60,6 +60,9 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include +#ifdef NETDUMP_CLIENT +#include +#endif #include #include