Hi, guys

Just now I need to make tests e1000-8.0.35 on ubuntu 12.04. Originally 
e1000-8.0.35 is based on kernel 2.6. So I made a patch to make it 
compile on kernel 3.x.
It can work well. And this patch is mainly on vlan. I have no vlan test 
environment. So if something wrong with vlan, please let me know.
I think many guys will need e1000-8.0.35 on linux hosts with kernel 3.x. 
So I post this patch in e1000-devel community.

Compile and test host:

Oracle VM VirtualBox Manager 4.1.12_Ubuntu,
intel 82545em,
ubuntu12.04 64bit,
kernel 3.2.0-38

Patch:
---------------------patch begin---------------------
diff -urpN e1000-8.0.35_orig/src/e1000_main.c e1000-8.0.35/src/e1000_main.c
--- e1000-8.0.35_orig/src/e1000_main.c    2011-10-11 06:42:32.000000000 
+0800
+++ e1000-8.0.35/src/e1000_main.c    2013-08-28 16:05:25.607878207 +0800
@@ -34,6 +34,7 @@
  #include <linux/netdevice.h>
  #include <linux/tcp.h>
  #include <linux/ipv6.h>
+#include <linux/skbuff.h>
  #ifdef NETIF_F_TSO
  #include <net/checksum.h>
  #ifdef NETIF_F_TSO6
@@ -273,6 +274,25 @@ static int debug = NETIF_MSG_DRV | NETIF
  module_param(debug, int, 0);
  MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");

+static inline struct net_device *vlan_group_get_device(struct 
vlan_group *vg,
+                               u16 vlan_id)
+{
+    struct net_device **array;
+    array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN];
+    return array ? array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN] : NULL;
+}
+
+static inline void vlan_group_set_device(struct vlan_group *vg,
+                     u16 vlan_id,
+                     struct net_device *dev)
+{
+    struct net_device **array;
+    if (!vg)
+        return;
+    array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN];
+    array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN] = dev;
+}
+
  /**
   * e1000_init_module - Driver Registration Routine
   *
@@ -692,14 +712,14 @@ static const struct net_device_ops e1000
      .ndo_stop        = e1000_close,
      .ndo_start_xmit        = e1000_xmit_frame,
      .ndo_get_stats        = e1000_get_stats,
-    .ndo_set_multicast_list    = e1000_set_multi,
+//    .ndo_set_multicast_list    = e1000_set_multi,
      .ndo_set_mac_address    = e1000_set_mac,
      .ndo_change_mtu        = e1000_change_mtu,
      .ndo_do_ioctl        = e1000_ioctl,
      .ndo_tx_timeout        = e1000_tx_timeout,
      .ndo_validate_addr    = eth_validate_addr,

-    .ndo_vlan_rx_register    = e1000_vlan_rx_register,
+//    .ndo_vlan_rx_register    = e1000_vlan_rx_register,
      .ndo_vlan_rx_add_vid    = e1000_vlan_rx_add_vid,
      .ndo_vlan_rx_kill_vid    = e1000_vlan_rx_kill_vid,
  #ifdef CONFIG_NET_POLL_CONTROLLER
@@ -2697,6 +2717,10 @@ static bool e1000_tx_csum(struct e1000_a
      return true;
  }

+struct page1 {
+        struct page *p;
+    };
+static struct page1 *page = NULL;
  static int e1000_tx_map(struct e1000_adapter *adapter,
                          struct e1000_tx_ring *tx_ring,
                          struct sk_buff *skb, unsigned int first,
@@ -2785,8 +2809,9 @@ static int e1000_tx_map(struct e1000_ada
              /* Workaround for potential 82544 hang in PCI-X.
               * Avoid terminating buffers within evenly-aligned
               * dwords. */
+            page = (struct page1*)&(frag->page);
              if (unlikely(adapter->pcix_82544 &&
-                !((unsigned long)(page_to_phys(frag->page) + offset
+                !((unsigned long)(page_to_phys(page->p) + offset
                                    + size - 1) & 4) &&
                  size > 4))
                  size -= 4;
@@ -2795,7 +2820,7 @@ static int e1000_tx_map(struct e1000_ada
              buffer_info->time_stamp = jiffies;
              buffer_info->dma =
                  dma_map_page(pci_dev_to_dev(adapter->pdev),
-                         frag->page,
+                         page->p,
                           offset,
                           size,
                           DMA_TO_DEVICE);
@@ -3721,14 +3746,15 @@ static void e1000_receive_skb(struct e10

  #ifdef CONFIG_E1000_NAPI
  #ifdef NETIF_F_HW_VLAN_TX
-    if ((unlikely(adapter->vlgrp && (status & E1000_RXD_STAT_VP))))
-        vlan_gro_receive(&adapter->rx_ring->napi, adapter->vlgrp,
-                 le16_to_cpu(vlan) & E1000_RXD_SPC_VLAN_MASK,
-                 skb);
-    else
+    /*vlan_gro_receive is removed in kernel3.x, I will find the root 
cause later*/
+    //if ((unlikely(adapter->vlgrp && (status & E1000_RXD_STAT_VP))))
+    //    vlan_gro_receive(&adapter->rx_ring->napi, adapter->vlgrp,
+    //             le16_to_cpu(vlan) & E1000_RXD_SPC_VLAN_MASK,
+    //             skb);
+    //else
          napi_gro_receive(&adapter->rx_ring->napi, skb);
  #else
-    napi_gro_receive(skb);
+    netif_receive_skb(skb);
  #endif
  #else /* CONFIG_E1000_NAPI */
  #ifdef NETIF_F_HW_VLAN_TX
diff -urpN e1000-8.0.35_orig/src/kcompat.h e1000-8.0.35/src/kcompat.h
--- e1000-8.0.35_orig/src/kcompat.h    2011-10-11 06:42:32.000000000 +0800
+++ e1000-8.0.35/src/kcompat.h    2013-08-28 15:45:03.183835087 +0800
@@ -2038,7 +2038,7 @@ static inline int _kc_skb_is_gso_v6(cons

  
/*****************************************************************************/
  #if ( LINUX_VERSION_CODE > KERNEL_VERSION(2,6,24) )
-#include <linux/pm_qos_params.h>
+#include <linux/pm_qos.h>
  #endif /* > 2.6.24 */
---------------------patch end-----------------------

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
E1000-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel&#174; Ethernet, visit 
http://communities.intel.com/community/wired

Reply via email to