6464#define DEFAULT_RX_CSUM_ENABLE (true)
6565#define DEFAULT_TSO_CSUM_ENABLE (true)
6666#define DEFAULT_VLAN_FILTER_ENABLE (true)
67+ #define DEFAULT_VLAN_RX_OFFLOAD (true)
6768#define TX_OVERHEAD (8)
6869#define RXW_PADDING 2
6970
@@ -2363,6 +2364,11 @@ static int lan78xx_set_features(struct net_device *netdev,
23632364 pdata -> rfe_ctl &= ~(RFE_CTL_ICMP_COE_ | RFE_CTL_IGMP_COE_ );
23642365 }
23652366
2367+ if (features & NETIF_F_HW_VLAN_CTAG_RX )
2368+ pdata -> rfe_ctl |= RFE_CTL_VLAN_STRIP_ ;
2369+ else
2370+ pdata -> rfe_ctl &= ~RFE_CTL_VLAN_STRIP_ ;
2371+
23662372 if (features & NETIF_F_HW_VLAN_CTAG_FILTER )
23672373 pdata -> rfe_ctl |= RFE_CTL_VLAN_FILTER_ ;
23682374 else
@@ -2976,6 +2982,9 @@ static int lan78xx_bind(struct lan78xx_net *dev, struct usb_interface *intf)
29762982 if (DEFAULT_TSO_CSUM_ENABLE )
29772983 dev -> net -> features |= NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_SG ;
29782984
2985+ if (DEFAULT_VLAN_RX_OFFLOAD )
2986+ dev -> net -> features |= NETIF_F_HW_VLAN_CTAG_RX ;
2987+
29792988 if (DEFAULT_VLAN_FILTER_ENABLE )
29802989 dev -> net -> features |= NETIF_F_HW_VLAN_CTAG_FILTER ;
29812990
@@ -3052,6 +3061,16 @@ static void lan78xx_rx_csum_offload(struct lan78xx_net *dev,
30523061 }
30533062}
30543063
3064+ static void lan78xx_rx_vlan_offload (struct lan78xx_net * dev ,
3065+ struct sk_buff * skb ,
3066+ u32 rx_cmd_a , u32 rx_cmd_b )
3067+ {
3068+ if ((dev -> net -> features & NETIF_F_HW_VLAN_CTAG_RX ) &&
3069+ (rx_cmd_a & RX_CMD_A_FVTG_ ))
3070+ __vlan_hwaccel_put_tag (skb , htons (ETH_P_8021Q ),
3071+ (rx_cmd_b & 0xffff ));
3072+ }
3073+
30553074static void lan78xx_skb_return (struct lan78xx_net * dev , struct sk_buff * skb )
30563075{
30573076 int status ;
@@ -3116,6 +3135,8 @@ static int lan78xx_rx(struct lan78xx_net *dev, struct sk_buff *skb)
31163135 if (skb -> len == size ) {
31173136 lan78xx_rx_csum_offload (dev , skb ,
31183137 rx_cmd_a , rx_cmd_b );
3138+ lan78xx_rx_vlan_offload (dev , skb ,
3139+ rx_cmd_a , rx_cmd_b );
31193140
31203141 skb_trim (skb , skb -> len - 4 ); /* remove fcs */
31213142 skb -> truesize = size + sizeof (struct sk_buff );
@@ -3134,6 +3155,7 @@ static int lan78xx_rx(struct lan78xx_net *dev, struct sk_buff *skb)
31343155 skb_set_tail_pointer (skb2 , size );
31353156
31363157 lan78xx_rx_csum_offload (dev , skb2 , rx_cmd_a , rx_cmd_b );
3158+ lan78xx_rx_vlan_offload (dev , skb2 , rx_cmd_a , rx_cmd_b );
31373159
31383160 skb_trim (skb2 , skb2 -> len - 4 ); /* remove fcs */
31393161 skb2 -> truesize = size + sizeof (struct sk_buff );
0 commit comments