svn commit: r213207 - projects/sv/sys/dev/e1000
Attilio Rao
attilio at FreeBSD.org
Mon Sep 27 16:48:56 UTC 2010
Author: attilio
Date: Mon Sep 27 16:48:56 2010
New Revision: 213207
URL: http://svn.freebsd.org/changeset/base/213207
Log:
Mask the conditional locking with appropriate macros.
Don't make them in the headers because their usage should be just local.
Requested by: rstone
Modified:
projects/sv/sys/dev/e1000/if_em.c
projects/sv/sys/dev/e1000/if_lem.c
Modified: projects/sv/sys/dev/e1000/if_em.c
==============================================================================
--- projects/sv/sys/dev/e1000/if_em.c Mon Sep 27 16:29:46 2010 (r213206)
+++ projects/sv/sys/dev/e1000/if_em.c Mon Sep 27 16:48:56 2010 (r213207)
@@ -89,6 +89,27 @@
#include "e1000_82571.h"
#include "if_em.h"
+#if defined(DEVICE_POLLING) || defined(NETDUMP_CLIENT)
+
+#define EM_CORE_LOCK_COND(adapter, locking) do { \
+ if ((locking) != 0) \
+ EM_CORE_LOCK(adapter); \
+} while (0)
+#define EM_CORE_UNLOCK_COND(adapter, locking) do { \
+ if ((locking) != 0) \
+ EM_CORE_UNLOCK(adapter); \
+} while (0)
+#define EM_TX_LOCK_COND(txr, locking) do { \
+ if ((locking) != 0) \
+ EM_TX_LOCK(txr); \
+} while (0)
+#define EM_TX_UNLOCK_COND(txr, locking) do { \
+ if ((locking) != 0) \
+ EM_CORE_UNLOCK(txr); \
+} while (0)
+
+#endif
+
/*********************************************************************
* Set this to one to display debug statistics
*********************************************************************/
@@ -1392,11 +1413,9 @@ _em_poll_generic(struct ifnet *ifp, enum
u32 reg_icr;
int rx_done;
- if (locking != 0)
- EM_CORE_LOCK(adapter);
+ EM_CORE_LOCK_COND(adapter, locking);
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
- if (locking != 0)
- EM_CORE_UNLOCK(adapter);
+ EM_CORE_UNLOCK_COND(adapter, locking);
return (0);
}
@@ -1410,13 +1429,11 @@ _em_poll_generic(struct ifnet *ifp, enum
em_local_timer, adapter);
}
}
- if (locking != 0)
- EM_CORE_UNLOCK(adapter);
+ EM_CORE_UNLOCK_COND(adapter, locking);
em_rxeof(rxr, count, &rx_done);
- if (locking != 0)
- EM_TX_LOCK(txr);
+ EM_TX_LOCK_COND(txr, locking);
em_txeof(txr);
#ifdef EM_MULTIQUEUE
if (!drbr_empty(ifp, txr->br))
@@ -1425,8 +1442,7 @@ _em_poll_generic(struct ifnet *ifp, enum
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
em_start_locked(ifp, txr);
#endif
- if (locking != 0)
- EM_TX_UNLOCK(txr);
+ EM_TX_UNLOCK_COND(txr, locking);
return (rx_done);
}
Modified: projects/sv/sys/dev/e1000/if_lem.c
==============================================================================
--- projects/sv/sys/dev/e1000/if_lem.c Mon Sep 27 16:29:46 2010 (r213206)
+++ projects/sv/sys/dev/e1000/if_lem.c Mon Sep 27 16:48:56 2010 (r213207)
@@ -87,6 +87,27 @@
#include "e1000_api.h"
#include "if_lem.h"
+#if defined(DEVICE_POLLING) || defined(NETDUMP_CLIENT)
+
+#define EM_CORE_LOCK_COND(adapter, locking) do { \
+ if ((locking) != 0) \
+ EM_CORE_LOCK(adapter); \
+} while (0)
+#define EM_CORE_UNLOCK_COND(adapter, locking) do { \
+ if ((locking) != 0) \
+ EM_CORE_UNLOCK(adapter); \
+} while (0)
+#define EM_TX_LOCK_COND(adapter, locking) do { \
+ if ((locking) != 0) \
+ EM_TX_LOCK(adapter); \
+} while (0)
+#define EM_TX_UNLOCK_COND(adapter, locking) do { \
+ if ((locking) != 0) \
+ EM_CORE_UNLOCK(adapter); \
+} while (0)
+
+#endif
+
/*********************************************************************
* Legacy Em Driver version:
*********************************************************************/
@@ -1263,11 +1284,9 @@ _lem_poll_generic(struct ifnet *ifp, enu
struct adapter *adapter = ifp->if_softc;
u32 reg_icr, rx_done = 0;
- if (locking != 0)
- EM_CORE_LOCK(adapter);
+ EM_CORE_LOCK_COND(adapter, locking);
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
- if (locking != 0)
- EM_CORE_UNLOCK(adapter);
+ EM_CORE_UNLOCK_COND(adapter, locking);
return (rx_done);
}
@@ -1281,18 +1300,15 @@ _lem_poll_generic(struct ifnet *ifp, enu
lem_local_timer, adapter);
}
}
- if (locking != 0)
- EM_CORE_UNLOCK(adapter);
+ EM_CORE_UNLOCK_COND(adapter, locking);
lem_rxeof(adapter, count, &rx_done);
- if (locking != 0)
- EM_TX_LOCK(adapter);
+ EM_TX_LOCK_COND(adapter, locking);
lem_txeof(adapter);
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
lem_start_locked(ifp);
- if (locking != 0)
- EM_TX_UNLOCK(adapter);
+ EM_TX_UNLOCK_COND(adapter, locking);
return (rx_done);
}
More information about the svn-src-projects
mailing list