svn commit: r213296 - projects/sv/sys/dev/e1000
Attilio Rao
attilio at FreeBSD.org
Thu Sep 30 11:43:55 UTC 2010
Author: attilio
Date: Thu Sep 30 11:43:54 2010
New Revision: 213296
URL: http://svn.freebsd.org/changeset/base/213296
Log:
Add netdump support for if_igb.
Modified:
projects/sv/sys/dev/e1000/if_igb.c
Modified: projects/sv/sys/dev/e1000/if_igb.c
==============================================================================
--- projects/sv/sys/dev/e1000/if_igb.c Thu Sep 30 10:09:52 2010 (r213295)
+++ projects/sv/sys/dev/e1000/if_igb.c Thu Sep 30 11:43:54 2010 (r213296)
@@ -37,6 +37,7 @@
#include "opt_device_polling.h"
#include "opt_inet.h"
#include "opt_altq.h"
+#include "opt_netdump.h"
#endif
#include <sys/param.h>
@@ -78,6 +79,9 @@
#include <netinet/if_ether.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
+#ifdef NETDUMP_CLIENT
+#include <netinet/netdump.h>
+#endif
#include <netinet/tcp.h>
#include <netinet/tcp_lro.h>
#include <netinet/udp.h>
@@ -91,6 +95,27 @@
#include "e1000_82575.h"
#include "if_igb.h"
+#if defined(DEVICE_POLLING) || defined(NETDUMP_CLIENT)
+
+#define IGB_CORE_LOCK_COND(adapter, locking) do { \
+ if ((locking) != 0) \
+ IGB_CORE_LOCK(adapter); \
+} while (0)
+#define IGB_CORE_UNLOCK_COND(adapter, locking) do { \
+ if ((locking) != 0) \
+ IGB_CORE_UNLOCK(adapter); \
+} while (0)
+#define IGB_TX_LOCK_COND(txr, locking) do { \
+ if ((locking) != 0) \
+ IGB_TX_LOCK(txr); \
+} while (0)
+#define IGB_TX_UNLOCK_COND(txr, locking) do { \
+ if ((locking) != 0) \
+ IGB_TX_UNLOCK(txr); \
+} while (0)
+
+#endif
+
/*********************************************************************
* Set this to one to display debug statistics
*********************************************************************/
@@ -252,14 +277,32 @@ static void igb_handle_link(void *contex
static void igb_msix_que(void *);
static void igb_msix_link(void *);
-#ifdef DEVICE_POLLING
+#if defined(DEVICE_POLLING) || defined(NETDUMP_CLIENT)
+static int _igb_poll_generic(struct ifnet *ifp, enum poll_cmd cmd,
+ int count, int locking);
static poll_handler_t igb_poll;
-#endif /* POLLING */
+#endif
+#ifdef NETDUMP_CLIENT
+static poll_handler_t igb_poll_unlocked;
+static ndumplock_handler_t igb_ndump_disable_intr;
+static ndumplock_handler_t igb_ndump_enable_intr;
+#endif
/*********************************************************************
* FreeBSD Device Interface Entry Points
*********************************************************************/
+#ifdef NETDUMP_CLIENT
+
+static struct netdump_methods igb_ndump_methods = {
+ .ne_poll_locked = igb_poll,
+ .ne_poll_unlocked = igb_poll_unlocked,
+ .ne_disable_intr = igb_ndump_disable_intr,
+ .ne_enable_intr = igb_ndump_enable_intr
+};
+
+#endif
+
static device_method_t igb_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, igb_probe),
@@ -1354,7 +1397,7 @@ igb_irq_fast(void *arg)
return FILTER_HANDLED;
}
-#ifdef DEVICE_POLLING
+#if defined(DEVICE_POLLING) || defined(NETDUMP_CLIENT)
/*********************************************************************
*
* Legacy polling routine : if using this code you MUST be sure that
@@ -1368,7 +1411,7 @@ static int
#define POLL_RETURN_COUNT(a)
static void
#endif
-igb_poll(struct ifnet *ifp, enum poll_cmd cmd, int count)
+_igb_poll_generic(struct ifnet *ifp, enum poll_cmd cmd, int count, int locking)
{
struct adapter *adapter = ifp->if_softc;
struct igb_queue *que = adapter->queues;
@@ -1377,9 +1420,9 @@ igb_poll(struct ifnet *ifp, enum poll_cm
u32 loop = IGB_MAX_LOOP;
bool more;
- IGB_CORE_LOCK(adapter);
+ IGB_CORE_LOCK_COND(adapter, locking);
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
- IGB_CORE_UNLOCK(adapter);
+ IGB_CORE_UNLOCK_COND(adapter, locking);
return POLL_RETURN_COUNT(rx_done);
}
@@ -1392,11 +1435,11 @@ igb_poll(struct ifnet *ifp, enum poll_cm
if (reg_icr & E1000_ICR_RXO)
adapter->rx_overruns++;
}
- IGB_CORE_UNLOCK(adapter);
+ IGB_CORE_UNLOCK_COND(adapter, locking);
igb_rxeof(que, count, &rx_done);
- IGB_TX_LOCK(txr);
+ IGB_TX_LOCK_COND(txr, locking);
do {
more = igb_txeof(txr);
} while (loop-- && more);
@@ -1407,10 +1450,48 @@ igb_poll(struct ifnet *ifp, enum poll_cm
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
igb_start_locked(txr, ifp);
#endif
- IGB_TX_UNLOCK(txr);
+ IGB_TX_UNLOCK_COND(txr, locking);
return POLL_RETURN_COUNT(rx_done);
}
-#endif /* DEVICE_POLLING */
+
+static int
+igb_poll(struct ifnet *ifp, enum poll_cmd cmd, int count)
+{
+
+ return (_igb_poll_generic(ifp, cmd, count, 1));
+}
+#endif /* !DEVICE_POLLING && !NETDUMP_CLIENT */
+
+#ifdef NETDUMP_CLIENT
+static int
+igb_poll_unlocked(struct ifnet *ifp, enum poll_cmd cmd, int count)
+{
+
+ return (_igb_poll_generic(ifp, cmd, count, 0));
+}
+
+static void
+igb_ndump_disable_intr(struct ifnet *ifp)
+{
+ struct adapter *adapter;
+
+ adapter = ifp->if_softc;
+ IGB_CORE_LOCK(adapter);
+ igb_disable_intr(adapter);
+ IGB_CORE_UNLOCK(adapter);
+}
+
+static void
+igb_ndump_enable_intr(struct ifnet *ifp)
+{
+ struct adapter *adapter;
+
+ adapter = ifp->if_softc;
+ IGB_CORE_LOCK(adapter);
+ igb_enable_intr(adapter);
+ IGB_CORE_UNLOCK(adapter);
+}
+#endif /* !NETDUMP_CLIENT */
/*********************************************************************
*
@@ -2713,6 +2794,9 @@ igb_setup_interface(device_t dev, struct
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = igb_ioctl;
ifp->if_start = igb_start;
+#ifdef NETDUMP_CLIENT
+ ifp->if_ndumpfuncs = &igb_ndump_methods;
+#endif
#if __FreeBSD_version >= 800000
ifp->if_transmit = igb_mq_start;
ifp->if_qflush = igb_qflush;
More information about the svn-src-projects
mailing list