Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 31 Jul 2012 10:46:59 -0700
From:      Jack Vogel <jfvogel@gmail.com>
To:        Garrett Cooper <yanegomi@gmail.com>
Cc:        Adrian Chadd <adrian@freebsd.org>, src-committers@freebsd.org, John Baldwin <jhb@freebsd.org>, svn-src-all@freebsd.org, Andrey Zonov <andrey@zonov.org>, Luigi Rizzo <luigi@freebsd.org>, svn-src-head@freebsd.org
Subject:   Re: svn commit: r238765 - head/sys/dev/e1000
Message-ID:  <CAFOYbc=qp8Gun0E--Lf45oFgwm-pNOfv_RtBFwgUsaz0na7TzQ@mail.gmail.com>
In-Reply-To: <CAGH67wQGddoNHwQmNrw0J3YspCvn33rWVKzezoi48_9YH%2B9E3A@mail.gmail.com>
References:  <201207251128.q6PBSFlt052575@svn.freebsd.org> <5017F614.1010304@zonov.org> <CAGH67wSTfQwAZVpYtBQSs0iaZ7RhqLVu3DFVp9R5R7qXMra-RQ@mail.gmail.com> <201207311212.21496.jhb@freebsd.org> <CAFOYbck2f5%2B6-8ObjERKEdUo%2Bpw3bx4tqxO1SxngNwuDDC6PLA@mail.gmail.com> <CAGH67wQGddoNHwQmNrw0J3YspCvn33rWVKzezoi48_9YH%2B9E3A@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--20cf307ca184df215a04c623c32a
Content-Type: text/plain; charset=ISO-8859-1

No, like so:

--- if_lem.c    2012-07-31 18:32:50.000000000 -0700
+++ if_lem.jfv.c    2012-07-31 18:31:25.000000000 -0700
@@ -1,6 +1,6 @@
 /******************************************************************************

-  Copyright (c) 2001-2011, Intel Corporation
+  Copyright (c) 2001-2012, Intel Corporation
   All rights reserved.

   Redistribution and use in source and binary forms, with or without
@@ -85,7 +85,7 @@
 /*********************************************************************
  *  Legacy Em Driver version:
  *********************************************************************/
-char lem_driver_version[] = "1.0.4";
+char lem_driver_version[] = "1.0.5";

 /*********************************************************************
  *  PCI Device ID Table
@@ -239,16 +239,12 @@
 static int    lem_enable_phy_wakeup(struct adapter *);
 static void    lem_led_func(void *, int);

-#define EM_LEGACY_IRQ    /* slightly faster, at least in qemu */
-#ifdef EM_LEGACY_IRQ
 static void    lem_intr(void *);
-#else /* FAST IRQ */
 static int    lem_irq_fast(void *);
 static void    lem_handle_rxtx(void *context, int pending);
 static void    lem_handle_link(void *context, int pending);
 static void    lem_add_rx_process_limit(struct adapter *, const char *,
             const char *, int *, int);
-#endif /* ~EM_LEGACY_IRQ */

 #ifdef DEVICE_POLLING
 static poll_handler_t lem_poll;
@@ -305,11 +301,13 @@
 TUNABLE_INT("hw.em.smart_pwr_down", &lem_smart_pwr_down);
 TUNABLE_INT("hw.em.sbp", &lem_debug_sbp);

-#ifndef EM_LEGACY_IRQ
+/* Interrupt style - default to fast */
+static int lem_use_legacy_irq = 0;
+TUNABLE_INT("hw.em.use_legacy_irq", &lem_use_legacy_irq);
+
 /* How many packets rxeof tries to clean at a time */
 static int lem_rx_process_limit = 100;
 TUNABLE_INT("hw.em.rx_process_limit", &lem_rx_process_limit);
-#endif

 /* Flow control setting - default to FULL */
 static int lem_fc_setting = e1000_fc_full;
@@ -451,12 +449,10 @@
             lem_tx_abs_int_delay_dflt);
     }

-#ifndef EM_LEGACY_IRQ
     /* Sysctls for limiting the amount of work done in the taskqueue */
     lem_add_rx_process_limit(adapter, "rx_processing_limit",
         "max number of rx packets to process", &adapter->rx_process_limit,
         lem_rx_process_limit);
-#endif

         /* Sysctl for setting the interface flow control */
     lem_set_flow_cntrl(adapter, "flow_control",
@@ -1198,22 +1194,6 @@
     callout_reset(&adapter->timer, hz, lem_local_timer, adapter);
     e1000_clear_hw_cntrs_base_generic(&adapter->hw);

-    /* MSI/X configuration for 82574 */
-    if (adapter->hw.mac.type == e1000_82574) {
-        int tmp;
-        tmp = E1000_READ_REG(&adapter->hw, E1000_CTRL_EXT);
-        tmp |= E1000_CTRL_EXT_PBA_CLR;
-        E1000_WRITE_REG(&adapter->hw, E1000_CTRL_EXT, tmp);
-        /*
-        ** Set the IVAR - interrupt vector routing.
-        ** Each nibble represents a vector, high bit
-        ** is enable, other 3 bits are the MSIX table
-        ** entry, we map RXQ0 to 0, TXQ0 to 1, and
-        ** Link (other) to 2, hence the magic number.
-        */
-        E1000_WRITE_REG(&adapter->hw, E1000_IVAR, 0x800A0908);
-    }
-
 #ifdef DEVICE_POLLING
     /*
      * Only enable interrupts if we are not polling, make sure
@@ -1282,7 +1262,6 @@
 }
 #endif /* DEVICE_POLLING */

-#ifdef EM_LEGACY_IRQ
 /*********************************************************************
  *
  *  Legacy Interrupt Service routine
@@ -1296,7 +1275,8 @@
     u32        reg_icr;


-    if (ifp->if_capenable & IFCAP_POLLING)
+    if ((ifp->if_capenable & IFCAP_POLLING) ||
+        ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0))
         return;

     EM_CORE_LOCK(adapter);
@@ -1304,11 +1284,10 @@
     if (reg_icr & E1000_ICR_RXO)
         adapter->rx_overruns++;

-    if ((reg_icr == 0xffffffff) || (reg_icr == 0))
-            goto out;
-
-    if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
-            goto out;
+    if ((reg_icr == 0xffffffff) || (reg_icr == 0)) {
+        EM_CORE_UNLOCK(adapter);
+        return;
+    }

     if (reg_icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
         callout_stop(&adapter->timer);
@@ -1318,23 +1297,22 @@
         lem_tx_purge(adapter);
         callout_reset(&adapter->timer, hz,
             lem_local_timer, adapter);
-        goto out;
+        EM_CORE_UNLOCK(adapter);
+        return;
     }

-    EM_TX_LOCK(adapter);
+    EM_CORE_UNLOCK(adapter);
     lem_rxeof(adapter, -1, NULL);
+
+    EM_TX_LOCK(adapter);
     lem_txeof(adapter);
     if (ifp->if_drv_flags & IFF_DRV_RUNNING &&
         !IFQ_DRV_IS_EMPTY(&ifp->if_snd))
         lem_start_locked(ifp);
     EM_TX_UNLOCK(adapter);
-
-out:
-    EM_CORE_UNLOCK(adapter);
     return;
 }

-#else /* EM_FAST_IRQ, then fast interrupt routines only */

 static void
 lem_handle_link(void *context, int pending)
@@ -1418,7 +1396,6 @@
         adapter->rx_overruns++;
     return FILTER_HANDLED;
 }
-#endif /* ~EM_LEGACY_IRQ */


 /*********************************************************************
@@ -2215,19 +2192,21 @@
         return (ENXIO);
     }

-#ifdef EM_LEGACY_IRQ
-    /* We do Legacy setup */
-    if ((error = bus_setup_intr(dev, adapter->res[0],
-        INTR_TYPE_NET | INTR_MPSAFE, NULL, lem_intr, adapter,
-        &adapter->tag[0])) != 0) {
-        device_printf(dev, "Failed to register interrupt handler");
-        return (error);
+    /* Do Legacy setup? */
+    if (lem_use_legacy_irq) {
+        if ((error = bus_setup_intr(dev, adapter->res[0],
+                INTR_TYPE_NET | INTR_MPSAFE, NULL, lem_intr, adapter,
+                &adapter->tag[0])) != 0) {
+            device_printf(dev,
+                "Failed to register interrupt handler");
+            return (error);
+        }
+        return (0);
     }

-#else /* FAST_IRQ */
     /*
-     * Try allocating a fast interrupt and the associated deferred
-     * processing contexts.
+     * Use a Fast interrupt and the associated
+     * deferred processing contexts.
      */
     TASK_INIT(&adapter->rxtx_task, 0, lem_handle_rxtx, adapter);
     TASK_INIT(&adapter->link_task, 0, lem_handle_link, adapter);
@@ -2244,7 +2223,6 @@
         adapter->tq = NULL;
         return (error);
     }
-#endif  /* EM_LEGACY_IRQ */

     return (0);
 }
@@ -3302,20 +3280,6 @@
         E1000_WRITE_REG(&adapter->hw, E1000_ITR, DEFAULT_ITR);
     }

-    /*
-    ** When using MSIX interrupts we need to throttle
-    ** using the EITR register (82574 only)
-    */
-    if (adapter->msix)
-        for (int i = 0; i < 4; i++)
-            E1000_WRITE_REG(&adapter->hw,
-                E1000_EITR_82574(i), DEFAULT_ITR);
-
-    /* Disable accelerated ackknowledge */
-    if (adapter->hw.mac.type == e1000_82574)
-        E1000_WRITE_REG(&adapter->hw,
-            E1000_RFCTL, E1000_RFCTL_ACK_DIS);
-
     /* Setup the Base and Length of the Rx Descriptor Ring */
     bus_addr = adapter->rxdma.dma_paddr;
     E1000_WRITE_REG(&adapter->hw, E1000_RDLEN(0),
@@ -3835,10 +3799,6 @@
     struct e1000_hw *hw = &adapter->hw;
     u32 ims_mask = IMS_ENABLE_MASK;

-    if (adapter->msix) {
-        E1000_WRITE_REG(hw, EM_EIAC, EM_MSIX_MASK);
-        ims_mask |= EM_MSIX_MASK;
-    }
     E1000_WRITE_REG(hw, E1000_IMS, ims_mask);
 }

@@ -3847,9 +3807,7 @@
 {
     struct e1000_hw *hw = &adapter->hw;

-    if (adapter->msix)
-        E1000_WRITE_REG(hw, EM_EIAC, 0);
-    E1000_WRITE_REG(&adapter->hw, E1000_IMC, 0xffffffff);
+    E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
 }

 /*
@@ -4683,7 +4641,6 @@
         OID_AUTO, name, CTLTYPE_INT|CTLFLAG_RW, limit, value, description);
 }

-#ifndef EM_LEGACY_IRQ
 static void
 lem_add_rx_process_limit(struct adapter *adapter, const char *name,
     const char *description, int *limit, int value)
@@ -4693,4 +4650,3 @@
         SYSCTL_CHILDREN(device_get_sysctl_tree(adapter->dev)),
         OID_AUTO, name, CTLTYPE_INT|CTLFLAG_RW, limit, value, description);
 }
-#endif


On Tue, Jul 31, 2012 at 9:29 AM, Garrett Cooper <yanegomi@gmail.com> wrote:

> On Tue, Jul 31, 2012 at 9:20 AM, Jack Vogel <jfvogel@gmail.com> wrote:
> > Yes, I agree John, that was ugly, I'm already taking care of it with my
> > changes,
> > I'll send you a copy to check out.
>
> Like so:
>
> --- //depot/user/gcooper/atf-head/src/sys/dev/e1000/if_lem.c
> 2012-07-25 17:11:00.000000000 0000
> +++ /scratch/p4/user/gcooper/atf-head/src/sys/dev/e1000/if_lem.c
>  2012-07-25 17:11:00.000000000 0000
> @@ -1320,9 +1320,10 @@
>                     lem_local_timer, adapter);
>                 goto out;
>         }
> +       EM_CORE_UNLOCK(adapter);
>
> +       lem_rxeof(adapter, -1, NULL);
>         EM_TX_LOCK(adapter);
> -       lem_rxeof(adapter, -1, NULL);
>         lem_txeof(adapter);
>         if (ifp->if_drv_flags & IFF_DRV_RUNNING &&
>             !IFQ_DRV_IS_EMPTY(&ifp->if_snd))
> @@ -1330,8 +1331,8 @@
>         EM_TX_UNLOCK(adapter);
>
>  out:
> -       EM_CORE_UNLOCK(adapter);
> -       return;
> +       if (mtx_owned(&adapter->core_mtx))
> +               EM_CORE_UNLOCK(adapter);
>  }
>
>  #else /* EM_FAST_IRQ, then fast interrupt routines only */
>

--20cf307ca184df215a04c623c32a--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFOYbc=qp8Gun0E--Lf45oFgwm-pNOfv_RtBFwgUsaz0na7TzQ>