[etherlab-dev] Updating e1000e driver to kernel 3.16

Thomas Bitsky Jr tbj at automateddesign.com
Wed Jun 24 21:53:43 CEST 2015


Hello, everyone. I recently updated the embedded computers we use to a 3.16 kernel. I first applied the patch from Henry Bausely (http://comments.gmane.org/gmane.network.etherlab.devel/345) for kernel 3.8.13, but that left a little work to do. I’m no expert on  Linux drivers, so I made notes of my changes instead of creating a patch in hopes someone might catch any errors I made. Other than that, if you need to run the e1000e driver on a 3.16 kernel, 15 minutes with a text editor should get you going.

When configuring, use the flags:  --enable-e1000e --with-e1000e-kernel=3.8 

These changes will break the driver for kernels older than 3.16. 


First, apply Mr. Bausley's patch, downloading it from the link above. It downloads as a .bin file; I simply renamed it.


# cd ethercat-1.5.2

# patch -p1 < /path/to/patch/e1001_3.8.patch


After that, navigate to ethercat-1.5.2/devices/e1000e and make the following changes.


File
Line
Description
===========

---------
ethtool-3.8-ethercat.c
2101
---------
The driver makes a deprecated call to SET_ETHTOOL_OPS
 
Replace:
  SET_ETHTOOL_OPS( netdev, &e1000_ethtool_ops)
 
With:
  netdev->ethtool_ops = &e1000_ethtool_ops;


---------
netdev-3.8-ethercat.c
THROUGHOUT
---------
Replace: NETIF_F_HW_VLAN_RX
    With: NETIF_F_HW_VLAN_CTAG_RX
 
Replace: NETIF_F_HW_VLAN_TX
    With: NETIF_F_HW_VLAN_CTAG_TX
 
 
Replace: NETIF_F_HW_VLAN_FILTER
    With: NETIF_F_HW_VLAN_CTAG_FILTER


---------
netdev-3.8-ethercat.c
507
---------
The API changed for __vlan_hwaccel_put_tag
There is now an extra argument.
 
6 static inline struct sk_buff *__vlan_hwaccel_put_tag(struct sk_buff *skb,
357                                                      __be16 vlan_proto,
358                                                      u16 vlan_tci)
359 {
360         skb->vlan_proto = vlan_proto;
361         skb->vlan_tci = VLAN_TAG_PRESENT | vlan_tci;
362         return skb;
363 }
 
 
What we’re missing is the protocol, which appears to be retrieved a few lines above:
   skb->protocol = eth_type_trans( skb, netdev )
 
So, change the line:
    __vlan_hwaccel_put_tag( skb, tag );
With:
    __vlan_hwaccel_put_tag( skb, skb->protocol, tag );



---------
netdev-3.8-ethercat.c
837
---------
struct sk_buff has not member named ‘rxhash’
 
The field name was changed simply to “hash”
 
Change the line:
    skb->rxhash = …
To:
    skb->hash = …

--------- 
netdev-3.8-ethercat.c
6146
(Change occurs on line 2679)
---------

Initialization from incompatible pointer type.
 
.ndo_vlan_rx_add_vid = e1000_vlan_rx_add_vid
 
The function pointer is currently:
int (*ndo_vlan_rx_add_vid)(struct net_device *dev, __be16 proto, u16t vid);
841  *      If device support VLAN filtering this function is called when a
842  *      VLAN id is registered.
 
The implementation is missing the __be16 proto argument.
 
On line 2679, change parameter list to:
static int e1000_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16t vid)
 
The function body doesn’t seem to care about the protocol argument, so I didn’t implement any changes to the function.
 
But the calls to the function need to be updated in the subsequent steps. Note that I didn’t make any effort to capture the actual protocol; the function doesn’t use the new argument. If it becomes necessary in the future, there is an example on getting the protocol around line 507 of this file.


---------
2810
---------
Change:
    e1000_vlan_rx_add_vid( netdev, vid );
To:
  e1000_vlan_rx_add_vid( netdev, (__be16)0, vid );
 
————
2822
————

Change:
    e1000_vlan_rx_add_vid( adapter->netdev, vid );
To:
  e1000_vlan_rx_add_vid( adapter->netdev, (__be16)0, vid );

 
---------
2825
---------
Change:
    e1000_vlan_rx_add_vid( adapter->netdev, 0 );
To:
  e1000_vlan_rx_add_vid( adapter->netdev, (__be16)0, 0 );
 

---------
netdev-3.8-ethercat.c
6147
(Change occurs on line 2704)
---------
Initialization from incompatible pointer type.
 
int (*ndo_vlan_rx_kill_vid)(struct net_device *dev, unsigned short vid);
845  *      If device support VLAN filtering this function is called when a
846  *      VLAN id is unregistered.
 
At line 2704, the vid argument is of u16 type, but now it should be of unsigned short. Which is the same type, but I changed it so long as I was editing the code.
 
Once again, we’re missing the __be16 proto argument
 
e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
 
becomes
 
e1000_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto, unsigned short vid)
 
 

And once again we have to correct calls to the function later.
 
---------
2748
---------
e1000_vlan_rx_kill_vid( netdev, adapter->mng_vlan_id )
 
to
 
e1000_vlan_rx_kill_vid( netdev, (__be16)0, adapter->mng_vlan_id )
 
————
2816
————

e1000_vlan_rx_kill_vid( netdev, old_vid )
 
to
 
e1000_vlan_rx_kill_vid( netdev, (__be16)0, old_vid )
 

---------
4120
---------
e1000_vlan_rx_kill_vid( netdev, adapter->mng_vlan_id )
 
to
 
e1000_vlan_rx_kill_vid( netdev, (__be16)0, adapter->mng_vlan_id )




More information about the etherlab-dev mailing list