Skip to contentSkip to conversation

stmmac: Add vlan rx for better GRO performance.

PATCH Superseded Vince Bridgers 3 participants 3 messages Jan 14, 2014

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 stmmac: Add vlan rx for better GRO performance.

GRO requires VLANs to be removed before aggregation can occur. The Synopsys EMAC does not strip VLAN tags so this must be done by the driver.

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +18 -0
index b8e3a4c..e3ff84e 100644
@@ -1951,6 +1951,22 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 	return NETDEV_TX_OK;
 }
 
+static inline void stmmac_rx_vlan(struct net_device *dev, struct sk_buff *skb)
+{
+	struct ethhdr *ehdr;
+	u16 vlanid;
+	if ((dev->features & NETIF_F_HW_VLAN_CTAG_RX) ==
+		NETIF_F_HW_VLAN_CTAG_RX &&
+		!__vlan_get_tag(skb, &vlanid)) {
+		/* pop the vlan tag */
+		ehdr = (struct ethhdr *)skb->data;
+		memmove(skb->data + VLAN_HLEN, ehdr, ETH_ALEN * 2);
+		skb_pull(skb, VLAN_HLEN);
+		__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlanid);
+	}
+}
+
+
 /**
  * stmmac_rx_refill: refill used skb preallocated buffers
  * @priv: driver private structure
@@ -2102,6 +2118,8 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit)
 				print_pkt(skb->data, frame_len);
 			}
 
+			stmmac_rx_vlan(priv->dev, skb);
+
 			skb->protocol = eth_type_trans(skb, priv->dev);
 
 			if (unlikely(!coe))
Signature · 1 line
1.7.9.5
#1 lore raw

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) · line 1955

Quoted 2 lines · On Tue, 14 Jan 2014 11:34:06 -0600 Vince Bridgers <[email protected]>…
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -0
+static inline void stmmac_rx_vlan(struct net_device *dev, struct sk_buff *skb)
+{

No need for explicit inline, let the compiler decide to inline.

#2 lore raw
In reply to Vince Bridgers

Hello.

Quoted 14 lines · Vince Bridgers

GRO requires VLANs to be removed before aggregation can occur. The Synopsys EMAC does not strip VLAN tags so this must be done by the driver.

---
  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |   18 ++++++++++++++++++
  1 file changed, 18 insertions(+)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +0 -0
index b8e3a4c..e3ff84e 100644

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) · line 1957

Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +4 -0
@@ -1951,6 +1951,22 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
  	return NETDEV_TX_OK;
  }
 
+static inline void stmmac_rx_vlan(struct net_device *dev, struct sk_buff *skb)
+{
+	struct ethhdr *ehdr;
+	u16 vlanid;

Empty line after declarations wouldn't hurt.

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) · line 1959

Quoted 2 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -0
+	if ((dev->features & NETIF_F_HW_VLAN_CTAG_RX) ==
+		NETIF_F_HW_VLAN_CTAG_RX &&

Line should start right below the second paren on the previousl line.

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) · line 1960

Quoted 1 line
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -0
+		!__vlan_get_tag(skb, &vlanid)) {

This one too.

WBR, Sergei