--- zzzz-none-000/linux-4.4.60/net/8021q/vlan_core.c 2017-04-08 07:53:53.000000000 +0000 +++ scorpion-7490-727/linux-4.4.60/net/8021q/vlan_core.c 2021-02-04 17:41:59.000000000 +0000 @@ -5,6 +5,14 @@ #include #include "vlan.h" +#if defined(CONFIG_LTQ_ETH_OAM) || defined(CONFIG_LTQ_ETH_OAM_MODULE) +/* Support for ethernet OAM with VLAN */ +#include + +struct net_device * (*fp_ltq_eth_oam_dev)(void)=NULL; +EXPORT_SYMBOL(fp_ltq_eth_oam_dev); +#endif + bool vlan_do_receive(struct sk_buff **skbp) { struct sk_buff *skb = *skbp; @@ -61,9 +69,54 @@ rx_stats->rx_multicast++; u64_stats_update_end(&rx_stats->syncp); +#if IS_ENABLED(CONFIG_LTQ_ETH_OAM) + if (skb->protocol == ETH_P_CFM && fp_ltq_eth_oam_dev != NULL) + skb->dev = fp_ltq_eth_oam_dev(); +#endif + return true; } +/* Update the VLAN device with statistics from network offload engines */ +void __vlan_dev_update_accel_stats(struct net_device *dev, + struct rtnl_link_stats64 *nlstats) +{ + struct vlan_pcpu_stats *stats; + + if (!is_vlan_dev(dev)) + return; + + stats = per_cpu_ptr(vlan_dev_priv(dev)->vlan_pcpu_stats, 0); + + u64_stats_update_begin(&stats->syncp); + stats->rx_packets += nlstats->rx_packets; + stats->rx_bytes += nlstats->rx_bytes; + stats->tx_packets += nlstats->tx_packets; + stats->tx_bytes += nlstats->tx_bytes; + u64_stats_update_end(&stats->syncp); +} +EXPORT_SYMBOL(__vlan_dev_update_accel_stats); + +/* Lookup the 802.1p egress_map table and return the 802.1p value */ +u16 vlan_dev_get_egress_prio(struct net_device *dev, u32 skb_prio) +{ + struct vlan_priority_tci_mapping *mp; + + mp = vlan_dev_priv(dev)->egress_priority_map[(skb_prio & 0xf)]; + while (mp) { + if (mp->priority == skb_prio) { + /* This should already be shifted + * to mask correctly with the + * VLAN's TCI + */ + return mp->vlan_qos; + } + mp = mp->next; + } + return 0; +} +EXPORT_SYMBOL(vlan_dev_get_egress_prio); + /* Must be invoked with rcu_read_lock. */ struct net_device *__vlan_find_dev_deep_rcu(struct net_device *dev, __be16 vlan_proto, u16 vlan_id) @@ -102,6 +155,12 @@ } EXPORT_SYMBOL(vlan_dev_real_dev); +struct net_device *vlan_dev_next_dev(const struct net_device *dev) +{ + return vlan_dev_priv(dev)->real_dev; +} +EXPORT_SYMBOL(vlan_dev_next_dev); + u16 vlan_dev_vlan_id(const struct net_device *dev) { return vlan_dev_priv(dev)->vlan_id;