Advertisement
zhubr

Untitled

Jun 13th, 2021
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.92 KB | None | 0 0
  1. --- 8139too.c.orig  2021-06-07 23:26:50.000000000 +0300
  2. +++ 8139too.c   2021-06-13 16:01:10.961650399 +0300
  3. @@ -140,6 +140,7 @@
  4.          }
  5.  #endif
  6.  
  7. +#define TUNE8139_BIG_LOOP 1
  8.  
  9.  /* A few user-configurable values. */
  10.  /* media options */
  11. @@ -356,6 +357,7 @@
  12.     RxOK        = 0x01,
  13.  
  14.     RxAckBits   = RxFIFOOver | RxOverflow | RxOK,
  15. +   OtherAckBits    = PCIErr | PCSTimeout | RxUnderrun | RxErr | TxOK | TxErr,
  16.  };
  17.  
  18.  enum TxStatusBits {
  19. @@ -2128,21 +2130,62 @@
  20.     struct rtl8139_private *tp = container_of(napi, struct rtl8139_private, napi);
  21.     struct net_device *dev = tp->dev;
  22.     void __iomem *ioaddr = tp->mmio_addr;
  23. +   int link_changed = 0; /* avoid bogus "uninit" warning */
  24. +   unsigned long flags;
  25. +   u32 status;
  26. +   u16 ackstat;
  27. +#if TUNE8139_BIG_LOOP
  28. +   int boguscnt = max(NUM_TX_DESC, 4 /* Implying PCIErr, PCSTimeout, RxUnderrun, RxErr */);
  29. +#endif
  30.     int work_done;
  31.  
  32.     spin_lock(&tp->rx_lock);
  33. +   spin_lock_irqsave(&tp->lock, flags);
  34.     work_done = 0;
  35. -   if (likely(RTL_R16(IntrStatus) & RxAckBits))
  36. -       work_done += rtl8139_rx(dev, tp, budget);
  37.  
  38. -   if (work_done < budget) {
  39. -       unsigned long flags;
  40. +   status = RTL_R16(IntrStatus);
  41. +#if TUNE8139_BIG_LOOP
  42. +   while (((status & RxAckBits) && (work_done < budget)) || ((status & OtherAckBits) && (boguscnt > 0))) {
  43. +#endif
  44. +       if (status & RxAckBits)
  45. +           work_done += rtl8139_rx(dev, tp, budget);
  46. +
  47. +       if (status & OtherAckBits) {
  48. +           /* Acknowledge all of the current interrupt sources ASAP, but
  49. +              an first get an additional status bit from CSCR. */
  50. +           if (unlikely(status & RxUnderrun))
  51. +               link_changed = RTL_R16 (CSCR) & CSCR_LinkChangeBit;
  52. +
  53. +           ackstat = status & ~(RxAckBits | TxErr);
  54. +           if (ackstat)
  55. +               RTL_W16 (IntrStatus, ackstat);
  56. +
  57. +           /* Check uncommon events with one test. */
  58. +           if (unlikely(status & (PCIErr | PCSTimeout | RxUnderrun | RxErr)))
  59. +               rtl8139_weird_interrupt (dev, tp, ioaddr,
  60. +                        status, link_changed);
  61. +
  62. +           if (status & (TxOK | TxErr)) {
  63. +               rtl8139_tx_interrupt (dev, tp, ioaddr);
  64. +               if (status & TxErr)
  65. +                   RTL_W16 (IntrStatus, TxErr);
  66. +           }
  67. +#if TUNE8139_BIG_LOOP
  68. +           boguscnt--;
  69. +#endif
  70. +       }
  71. +#if TUNE8139_BIG_LOOP
  72. +       status = RTL_R16 (IntrStatus);
  73. +   }
  74. +#endif
  75.  
  76. -       spin_lock_irqsave(&tp->lock, flags);
  77. -       if (napi_complete_done(napi, work_done))
  78. +   if (work_done < budget) {
  79. +       if (napi_complete_done(napi, work_done)) {
  80.             RTL_W16_F(IntrMask, rtl8139_intr_mask);
  81. -       spin_unlock_irqrestore(&tp->lock, flags);
  82. +       }
  83.     }
  84. +
  85. +   spin_unlock_irqrestore(&tp->lock, flags);
  86.     spin_unlock(&tp->rx_lock);
  87.  
  88.     return work_done;
  89. @@ -2155,8 +2198,7 @@
  90.     struct net_device *dev = (struct net_device *) dev_instance;
  91.     struct rtl8139_private *tp = netdev_priv(dev);
  92.     void __iomem *ioaddr = tp->mmio_addr;
  93. -   u16 status, ackstat;
  94. -   int link_changed = 0; /* avoid bogus "uninit" warning */
  95. +   u16 status;
  96.     int handled = 0;
  97.  
  98.     spin_lock (&tp->lock);
  99. @@ -2178,33 +2220,9 @@
  100.         goto out;
  101.     }
  102.  
  103. -   /* Acknowledge all of the current interrupt sources ASAP, but
  104. -      an first get an additional status bit from CSCR. */
  105. -   if (unlikely(status & RxUnderrun))
  106. -       link_changed = RTL_R16 (CSCR) & CSCR_LinkChangeBit;
  107. -
  108. -   ackstat = status & ~(RxAckBits | TxErr);
  109. -   if (ackstat)
  110. -       RTL_W16 (IntrStatus, ackstat);
  111. -
  112. -   /* Receive packets are processed by poll routine.
  113. -      If not running start it now. */
  114. -   if (status & RxAckBits){
  115. -       if (napi_schedule_prep(&tp->napi)) {
  116. -           RTL_W16_F (IntrMask, rtl8139_norx_intr_mask);
  117. -           __napi_schedule(&tp->napi);
  118. -       }
  119. -   }
  120. -
  121. -   /* Check uncommon events with one test. */
  122. -   if (unlikely(status & (PCIErr | PCSTimeout | RxUnderrun | RxErr)))
  123. -       rtl8139_weird_interrupt (dev, tp, ioaddr,
  124. -                    status, link_changed);
  125. -
  126. -   if (status & (TxOK | TxErr)) {
  127. -       rtl8139_tx_interrupt (dev, tp, ioaddr);
  128. -       if (status & TxErr)
  129. -           RTL_W16 (IntrStatus, TxErr);
  130. +   if (napi_schedule_prep(&tp->napi)) {
  131. +       RTL_W16_F (IntrMask, 0);
  132. +       __napi_schedule(&tp->napi);
  133.     }
  134.   out:
  135.     spin_unlock (&tp->lock);
  136.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement