Skip to content

Instantly share code, notes, and snippets.

@nurse
Created September 26, 2011 03:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nurse/1241551 to your computer and use it in GitHub Desktop.
Save nurse/1241551 to your computer and use it in GitHub Desktop.
Patch for Realtek NIC sticks on QEMU against NetBSD current
Index: rtl8169.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/rtl8169.c,v
retrieving revision 1.133
diff -u -r1.133 rtl8169.c
--- rtl8169.c 28 Jul 2010 23:30:21 -0000 1.133
+++ rtl8169.c 19 Sep 2011 18:53:39 -0000
@@ -110,7 +110,10 @@
* jumbo frames larger than 7.5K, so the max MTU possible with this
* driver is 7500 bytes.
*/
-
+/*
+ * Support for timer interrupts isn't implemented in (most versions of) QEMU!!!
+ */
+#define RTK_QEMU
#include <sys/param.h>
#include <sys/endian.h>
@@ -1365,7 +1368,9 @@
* This is done in case the transmitter has gone idle.
*/
if (sc->re_ldata.re_txq_free < RE_TX_QLEN) {
+#ifndef RTK_QEMU
CSR_WRITE_4(sc, RTK_TIMERCNT, 1);
+#endif
if ((sc->sc_quirk & RTKQ_PCIE) != 0) {
/*
* Some chips will ignore a second TX request
@@ -1430,8 +1435,13 @@
if (status & (RTK_ISR_RX_OK | RTK_ISR_RX_ERR))
re_rxeof(sc);
- if (status & (RTK_ISR_TIMEOUT_EXPIRED | RTK_ISR_TX_ERR |
- RTK_ISR_TX_DESC_UNAVAIL))
+ if (status & (
+#ifdef RTK_QEMU
+ RTK_ISR_TX_OK |
+#else
+ RTK_ISR_TIMEOUT_EXPIRED |
+#endif
+ RTK_ISR_TX_ERR | RTK_ISR_TX_DESC_UNAVAIL))
re_txeof(sc);
if (status & RTK_ISR_SYSTEM_ERR) {
@@ -1691,6 +1701,7 @@
else
CSR_WRITE_1(sc, RTK_GTXSTART, RTK_TXSTART_START);
+#ifndef RTK_QEMU
/*
* Use the countdown timer for interrupt moderation.
* 'TX done' interrupts are disabled. Instead, we reset the
@@ -1700,6 +1711,7 @@
* the timer count is reset to 0.
*/
CSR_WRITE_4(sc, RTK_TIMERCNT, 1);
+#endif
/*
* Set a timeout in case the chip goes out to lunch.
@@ -1853,6 +1865,7 @@
CSR_WRITE_1(sc, RTK_COMMAND, RTK_CMD_TX_ENB | RTK_CMD_RX_ENB);
#endif
+#ifndef RTK_QEMU
/*
* Initialize the timer interrupt register so that
* a timer interrupt will be generated once the timer
@@ -1865,6 +1878,9 @@
CSR_WRITE_4(sc, RTK_TIMERINT, 0x400);
else {
CSR_WRITE_4(sc, RTK_TIMERINT_8169, 0x800);
+#else
+ if ((sc->sc_quirk & RTKQ_8139CPLUS) == 0) {
+#endif
/*
* For 8169 gigE NICs, set the max allowed RX packet
Index: rtl81x9reg.h
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/rtl81x9reg.h,v
retrieving revision 1.41
diff -u -r1.41 rtl81x9reg.h
--- rtl81x9reg.h 9 Apr 2010 10:40:59 -0000 1.41
+++ rtl81x9reg.h 19 Sep 2011 18:53:39 -0000
@@ -232,11 +232,17 @@
(RTK_ISR_TX_OK|RTK_ISR_RX_OK|RTK_ISR_RX_ERR|RTK_ISR_TX_ERR| \
RTK_ISR_RX_OVERRUN|RTK_ISR_PKT_UNDERRUN|RTK_ISR_FIFO_OFLOW| \
RTK_ISR_PCS_TIMEOUT|RTK_ISR_SYSTEM_ERR)
-
+#ifdef RTK_QEMU
+#define RTK_INTRS_CPLUS \
+ (RTK_ISR_RX_OK|RTK_ISR_RX_ERR|RTK_ISR_TX_ERR|RTK_ISR_TX_OK| \
+ RTK_ISR_RX_OVERRUN|RTK_ISR_PKT_UNDERRUN|RTK_ISR_FIFO_OFLOW| \
+ RTK_ISR_PCS_TIMEOUT|RTK_ISR_SYSTEM_ERR|RTK_ISR_TIMEOUT_EXPIRED)
+#else
#define RTK_INTRS_CPLUS \
(RTK_ISR_RX_OK|RTK_ISR_RX_ERR|RTK_ISR_TX_ERR| \
RTK_ISR_RX_OVERRUN|RTK_ISR_PKT_UNDERRUN|RTK_ISR_FIFO_OFLOW| \
RTK_ISR_PCS_TIMEOUT|RTK_ISR_SYSTEM_ERR|RTK_ISR_TIMEOUT_EXPIRED)
+#endif
/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment