118 lines
2.9 KiB
Plaintext
118 lines
2.9 KiB
Plaintext
|
diff --git a/r8169.c b/r8169.c
|
||
|
index 0fe2fc9..efee0a4 100644
|
||
|
--- a/r8169.c
|
||
|
+++ b/r8169.c
|
||
|
@@ -537,6 +537,10 @@ static int rtl8169_poll(struct napi_struct *napi, int budget);
|
||
|
static const unsigned int rtl8169_rx_config =
|
||
|
(RX_FIFO_THRESH << RxCfgFIFOShift) | (RX_DMA_BURST << RxCfgDMAShift);
|
||
|
|
||
|
+#if defined(CONFIG_NETMAP) || defined(CONFIG_NETMAP_MODULE)
|
||
|
+#include <if_re_netmap_linux.h>
|
||
|
+#endif
|
||
|
+
|
||
|
static void mdio_write(void __iomem *ioaddr, int reg_addr, int value)
|
||
|
{
|
||
|
int i;
|
||
|
@@ -3210,6 +3214,10 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||
|
|
||
|
device_set_wakeup_enable(&pdev->dev, tp->features & RTL_FEATURE_WOL);
|
||
|
|
||
|
+#ifdef DEV_NETMAP
|
||
|
+ re_netmap_attach(tp);
|
||
|
+#endif /* DEV_NETMAP */
|
||
|
+
|
||
|
out:
|
||
|
return rc;
|
||
|
|
||
|
@@ -3236,6 +3244,10 @@ static void __devexit rtl8169_remove_one(struct pci_dev *pdev)
|
||
|
|
||
|
unregister_netdev(dev);
|
||
|
|
||
|
+#ifdef DEV_NETMAP
|
||
|
+ netmap_detach(dev);
|
||
|
+#endif /* DEV_NETMAP */
|
||
|
+
|
||
|
/* restore original MAC address */
|
||
|
rtl_rar_set(tp, dev->perm_addr);
|
||
|
|
||
|
@@ -3291,6 +3303,10 @@ static int rtl8169_open(struct net_device *dev)
|
||
|
|
||
|
napi_enable(&tp->napi);
|
||
|
|
||
|
+#ifdef DEV_NETMAP
|
||
|
+ netmap_enable_all_rings(dev);
|
||
|
+#endif /* DEV_NETMAP */
|
||
|
+
|
||
|
rtl_hw_start(dev);
|
||
|
|
||
|
rtl8169_request_timer(dev);
|
||
|
@@ -3993,6 +4009,11 @@ err_out:
|
||
|
static void rtl8169_rx_clear(struct rtl8169_private *tp)
|
||
|
{
|
||
|
unsigned int i;
|
||
|
+#ifdef DEV_NETMAP
|
||
|
+ re_netmap_tx_init(tp);
|
||
|
+ if (re_netmap_rx_init(tp))
|
||
|
+ return 0; // success
|
||
|
+#endif /* DEV_NETMAP */
|
||
|
|
||
|
for (i = 0; i < NUM_RX_DESC; i++) {
|
||
|
if (tp->Rx_skbuff[i]) {
|
||
|
@@ -4112,11 +4133,19 @@ static void rtl8169_wait_for_quiescence(struct net_device *dev)
|
||
|
/* Wait for any pending NAPI task to complete */
|
||
|
napi_disable(&tp->napi);
|
||
|
|
||
|
+#ifdef DEV_NETMAP
|
||
|
+ netmap_disable_all_rings(dev);
|
||
|
+#endif /* DEV_NETMAP */
|
||
|
+
|
||
|
rtl8169_irq_mask_and_ack(ioaddr);
|
||
|
|
||
|
tp->intr_mask = 0xffff;
|
||
|
RTL_W16(IntrMask, tp->intr_event);
|
||
|
napi_enable(&tp->napi);
|
||
|
+
|
||
|
+#ifdef DEV_NETMAP
|
||
|
+ netmap_enable_all_rings(dev);
|
||
|
+#endif /* DEV_NETMAP */
|
||
|
}
|
||
|
|
||
|
static void rtl8169_reinit_task(struct work_struct *work)
|
||
|
@@ -4372,6 +4401,11 @@ static void rtl8169_tx_interrupt(struct net_device *dev,
|
||
|
{
|
||
|
unsigned int dirty_tx, tx_left;
|
||
|
|
||
|
+#ifdef DEV_NETMAP
|
||
|
+ if (netmap_tx_irq(dev, 0))
|
||
|
+ return;
|
||
|
+#endif /* DEV_NETMAP */
|
||
|
+
|
||
|
dirty_tx = tp->dirty_tx;
|
||
|
smp_rmb();
|
||
|
tx_left = tp->cur_tx - dirty_tx;
|
||
|
@@ -4468,6 +4502,11 @@ static int rtl8169_rx_interrupt(struct net_device *dev,
|
||
|
unsigned int cur_rx, rx_left;
|
||
|
unsigned int delta, count;
|
||
|
|
||
|
+#ifdef DEV_NETMAP
|
||
|
+ if (netmap_rx_irq(dev, 0, &count))
|
||
|
+ return count;
|
||
|
+#endif /* DEV_NETMAP */
|
||
|
+
|
||
|
cur_rx = tp->cur_rx;
|
||
|
rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx;
|
||
|
rx_left = min(rx_left, budget);
|
||
|
@@ -4687,7 +4726,12 @@ static void rtl8169_down(struct net_device *dev)
|
||
|
|
||
|
napi_disable(&tp->napi);
|
||
|
|
||
|
+#ifdef DEV_NETMAP
|
||
|
+ netmap_disable_all_rings(dev);
|
||
|
+#endif /* DEV_NETMAP */
|
||
|
+
|
||
|
core_down:
|
||
|
+
|
||
|
spin_lock_irq(&tp->lock);
|
||
|
|
||
|
rtl8169_asic_down(ioaddr);
|