Skip to content

Commit bea7d74

Browse files
marckleinebuddeNipaLocal
authored andcommitted
net: fec: fec_enet_rx_queue(): factor out VLAN handling into separate function fec_enet_rx_vlan()
In order to clean up of the VLAN handling, factor out the VLAN handling into separate function fec_enet_rx_vlan(). Reviewed-by: Frank Li <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 48df65b commit bea7d74

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

drivers/net/ethernet/freescale/fec_main.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,6 +1706,22 @@ fec_enet_run_xdp(struct fec_enet_private *fep, struct bpf_prog *prog,
17061706
return ret;
17071707
}
17081708

1709+
static void fec_enet_rx_vlan(const struct net_device *ndev, struct sk_buff *skb)
1710+
{
1711+
if (ndev->features & NETIF_F_HW_VLAN_CTAG_RX) {
1712+
const struct vlan_ethhdr *vlan_header = skb_vlan_eth_hdr(skb);
1713+
const u16 vlan_tag = ntohs(vlan_header->h_vlan_TCI);
1714+
1715+
/* Push and remove the vlan tag */
1716+
1717+
memmove(skb->data + VLAN_HLEN, skb->data, ETH_ALEN * 2);
1718+
skb_pull(skb, VLAN_HLEN);
1719+
__vlan_hwaccel_put_tag(skb,
1720+
htons(ETH_P_8021Q),
1721+
vlan_tag);
1722+
}
1723+
}
1724+
17091725
/* During a receive, the bd_rx.cur points to the current incoming buffer.
17101726
* When we update through the ring, if the next incoming buffer has
17111727
* not been given to the system, we just set the empty indicator,
@@ -1852,19 +1868,9 @@ fec_enet_rx_queue(struct net_device *ndev, u16 queue_id, int budget)
18521868
ebdp = (struct bufdesc_ex *)bdp;
18531869

18541870
/* If this is a VLAN packet remove the VLAN Tag */
1855-
if ((ndev->features & NETIF_F_HW_VLAN_CTAG_RX) &&
1856-
fep->bufdesc_ex &&
1857-
(ebdp->cbd_esc & cpu_to_fec32(BD_ENET_RX_VLAN))) {
1858-
/* Push and remove the vlan tag */
1859-
struct vlan_ethhdr *vlan_header = skb_vlan_eth_hdr(skb);
1860-
u16 vlan_tag = ntohs(vlan_header->h_vlan_TCI);
1861-
1862-
memmove(skb->data + VLAN_HLEN, skb->data, ETH_ALEN * 2);
1863-
skb_pull(skb, VLAN_HLEN);
1864-
__vlan_hwaccel_put_tag(skb,
1865-
htons(ETH_P_8021Q),
1866-
vlan_tag);
1867-
}
1871+
if (fep->bufdesc_ex &&
1872+
(ebdp->cbd_esc & cpu_to_fec32(BD_ENET_RX_VLAN)))
1873+
fec_enet_rx_vlan(ndev, skb);
18681874

18691875
skb->protocol = eth_type_trans(skb, ndev);
18701876

0 commit comments

Comments
 (0)