Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- 8139too.c.orig 2021-06-07 23:26:50.000000000 +0300
- +++ 8139too.c 2021-06-12 19:23:47.908493342 +0300
- @@ -140,6 +140,10 @@
- }
- #endif
- +#define TUNE8139_TX_WORK_IN_IRQ 0
- +#define TUNE8139_TX_WORK_IN_POLL 1
- +#define TUNE8139_LOOP_IN_IRQ 0
- +#define TUNE8139_LOOP_IN_POLL 0
- /* A few user-configurable values. */
- /* media options */
- @@ -604,6 +608,7 @@
- unsigned int watchdog_fired : 1;
- unsigned int default_port : 4; /* Last dev->if_port value. */
- unsigned int have_thread : 1;
- + int poll_active;
- spinlock_t lock;
- spinlock_t rx_lock;
- @@ -1398,6 +1403,7 @@
- RTL_W32_F (MAC0 + 4, le16_to_cpu (*(__le16 *) (dev->dev_addr + 4)));
- tp->cur_rx = 0;
- + tp->poll_active = 0;
- /* init Rx ring buffer DMA address */
- RTL_W32_F (RxBuf, tp->rx_ring_dma);
- @@ -2123,24 +2129,85 @@
- }
- }
- +static void rtl8139_tx_and_stuff(struct net_device *dev, struct rtl8139_private *tp, u16 status, int do_schedule)
- +{
- + void __iomem *ioaddr = tp->mmio_addr;
- + int link_changed = 0; /* avoid bogus "uninit" warning */
- + u16 ackstat;
- +
- + /* Acknowledge all of the current interrupt sources ASAP, but
- + an first get an additional status bit from CSCR. */
- + if (unlikely(status & RxUnderrun))
- + link_changed = RTL_R16 (CSCR) & CSCR_LinkChangeBit;
- +
- + ackstat = status & ~(RxAckBits | TxErr);
- + if (ackstat)
- + RTL_W16 (IntrStatus, ackstat);
- +
- + /* Process interrupts in poll routine.
- + If not running start it now. */
- + if (do_schedule && !tp->poll_active){ // zhubr
- + if (napi_schedule_prep(&tp->napi)) {
- + tp->poll_active = 1;
- + RTL_W16_F (IntrMask, rtl8139_norx_intr_mask);
- + __napi_schedule(&tp->napi);
- + }
- + }
- +
- + /* Check uncommon events with one test. */
- + if (unlikely(status & (PCIErr | PCSTimeout | RxUnderrun | RxErr)))
- + rtl8139_weird_interrupt (dev, tp, ioaddr,
- + status, link_changed);
- +
- + if (status & (TxOK | TxErr)) {
- + rtl8139_tx_interrupt (dev, tp, ioaddr);
- + if (status & TxErr)
- + RTL_W16 (IntrStatus, TxErr);
- + }
- +}
- +
- static int rtl8139_poll(struct napi_struct *napi, int budget)
- {
- struct rtl8139_private *tp = container_of(napi, struct rtl8139_private, napi);
- struct net_device *dev = tp->dev;
- void __iomem *ioaddr = tp->mmio_addr;
- + u32 status;
- int work_done;
- spin_lock(&tp->rx_lock);
- work_done = 0;
- - if (likely(RTL_R16(IntrStatus) & RxAckBits))
- + status = RTL_R16(IntrStatus);
- +#if (TUNE8139_TX_WORK_IN_POLL)
- + if (status & (PCIErr | PCSTimeout | RxUnderrun | RxErr | TxOK | TxErr)) { // zhubr
- + unsigned long flags;
- +#if (TUNE8139_LOOP_IN_POLL)
- + int boguscnt = max(NUM_TX_DESC, 4 /* Implying PCIErr, PCSTimeout, RxUnderrun, RxErr */);
- +#endif
- + spin_lock_irqsave(&tp->lock, flags);
- + status = RTL_R16(IntrStatus);
- +#if (TUNE8139_LOOP_IN_POLL)
- + while ((boguscnt > 0) && (status & (PCIErr | PCSTimeout | RxUnderrun | RxErr | TxOK | TxErr))) {
- +#endif
- + rtl8139_tx_and_stuff(dev, tp, status, 0);
- +#if (TUNE8139_LOOP_IN_POLL)
- + status = RTL_R16 (IntrStatus);
- + boguscnt--;
- + }
- +#endif
- + spin_unlock_irqrestore(&tp->lock, flags);
- + }
- +#endif
- + if (likely(status & RxAckBits))
- work_done += rtl8139_rx(dev, tp, budget);
- if (work_done < budget) {
- unsigned long flags;
- spin_lock_irqsave(&tp->lock, flags);
- - if (napi_complete_done(napi, work_done))
- + if (napi_complete_done(napi, work_done)) {
- RTL_W16_F(IntrMask, rtl8139_intr_mask);
- + tp->poll_active = 0;
- + }
- spin_unlock_irqrestore(&tp->lock, flags);
- }
- spin_unlock(&tp->rx_lock);
- @@ -2155,10 +2222,11 @@
- struct net_device *dev = (struct net_device *) dev_instance;
- struct rtl8139_private *tp = netdev_priv(dev);
- void __iomem *ioaddr = tp->mmio_addr;
- - u16 status, ackstat;
- - int link_changed = 0; /* avoid bogus "uninit" warning */
- + u16 status;
- int handled = 0;
- -
- +#if (TUNE8139_LOOP_IN_IRQ && (TUNE8139_TX_WORK_IN_IRQ || !TUNE8139_TX_WORK_IN_POLL))
- + int boguscnt = max(NUM_TX_DESC, 4 /* Implying PCIErr, PCSTimeout, RxUnderrun, RxErr */);
- +#endif
- spin_lock (&tp->lock);
- status = RTL_R16 (IntrStatus);
- @@ -2178,34 +2246,31 @@
- goto out;
- }
- - /* Acknowledge all of the current interrupt sources ASAP, but
- - an first get an additional status bit from CSCR. */
- - if (unlikely(status & RxUnderrun))
- - link_changed = RTL_R16 (CSCR) & CSCR_LinkChangeBit;
- -
- - ackstat = status & ~(RxAckBits | TxErr);
- - if (ackstat)
- - RTL_W16 (IntrStatus, ackstat);
- -
- - /* Receive packets are processed by poll routine.
- - If not running start it now. */
- - if (status & RxAckBits){
- +#if (TUNE8139_TX_WORK_IN_IRQ || !TUNE8139_TX_WORK_IN_POLL)
- +#if (TUNE8139_LOOP_IN_IRQ)
- + do {
- +#endif
- + rtl8139_tx_and_stuff(dev, tp, status, (status & RxAckBits)); // zhubr
- +#if (TUNE8139_LOOP_IN_IRQ)
- + boguscnt--;
- + status = RTL_R16 (IntrStatus);
- + } while ((boguscnt > 0) && ((status & ~RxAckBits) || ((status & RxAckBits) && !tp->poll_active)));
- +#endif
- +#else
- + if (!tp->poll_active){ // zhubr
- if (napi_schedule_prep(&tp->napi)) {
- - RTL_W16_F (IntrMask, rtl8139_norx_intr_mask);
- + tp->poll_active = 1;
- + RTL_W16_F (IntrMask,
- +#if (TUNE8139_TX_WORK_IN_IRQ)
- + rtl8139_norx_intr_mask
- +#else
- + 0
- +#endif
- + );
- __napi_schedule(&tp->napi);
- }
- }
- -
- - /* Check uncommon events with one test. */
- - if (unlikely(status & (PCIErr | PCSTimeout | RxUnderrun | RxErr)))
- - rtl8139_weird_interrupt (dev, tp, ioaddr,
- - status, link_changed);
- -
- - if (status & (TxOK | TxErr)) {
- - rtl8139_tx_interrupt (dev, tp, ioaddr);
- - if (status & TxErr)
- - RTL_W16 (IntrStatus, TxErr);
- - }
- +#endif
- out:
- spin_unlock (&tp->lock);
Add Comment
Please, Sign In to add comment