vlan_dev.c (cdccfc8dc0bf62a1da327324a8d639139acc9279) vlan_dev.c (8a0427bb688eae86a8bb939b6a74e5aa00aa035a)
1/* -*- linux-c -*-
2 * INET 802.1Q VLAN
3 * Ethernet-type device handling.
4 *
5 * Authors: Ben Greear <greearb@candelatech.com>
6 * Please send support related email to: netdev@vger.kernel.org
7 * VLAN Home Page: http://www.candelatech.com/~greear/vlan.html
8 *

--- 690 unchanged lines hidden (view full) ---

699 /* IFF_BROADCAST|IFF_MULTICAST; ??? */
700 dev->flags = real_dev->flags & ~(IFF_UP | IFF_PROMISC | IFF_ALLMULTI |
701 IFF_MASTER | IFF_SLAVE);
702 dev->iflink = real_dev->ifindex;
703 dev->state = (real_dev->state & ((1<<__LINK_STATE_NOCARRIER) |
704 (1<<__LINK_STATE_DORMANT))) |
705 (1<<__LINK_STATE_PRESENT);
706
1/* -*- linux-c -*-
2 * INET 802.1Q VLAN
3 * Ethernet-type device handling.
4 *
5 * Authors: Ben Greear <greearb@candelatech.com>
6 * Please send support related email to: netdev@vger.kernel.org
7 * VLAN Home Page: http://www.candelatech.com/~greear/vlan.html
8 *

--- 690 unchanged lines hidden (view full) ---

699 /* IFF_BROADCAST|IFF_MULTICAST; ??? */
700 dev->flags = real_dev->flags & ~(IFF_UP | IFF_PROMISC | IFF_ALLMULTI |
701 IFF_MASTER | IFF_SLAVE);
702 dev->iflink = real_dev->ifindex;
703 dev->state = (real_dev->state & ((1<<__LINK_STATE_NOCARRIER) |
704 (1<<__LINK_STATE_DORMANT))) |
705 (1<<__LINK_STATE_PRESENT);
706
707 dev->features |= real_dev->features & real_dev->vlan_features;
708 dev->features |= NETIF_F_LLTX;
707 dev->hw_features = real_dev->vlan_features & NETIF_F_ALL_TX_OFFLOADS;
708 dev->features |= real_dev->vlan_features | NETIF_F_LLTX;
709 dev->gso_max_size = real_dev->gso_max_size;
710
711 /* ipv6 shared card related stuff */
712 dev->dev_id = real_dev->dev_id;
713
714 if (is_zero_ether_addr(dev->dev_addr))
715 memcpy(dev->dev_addr, real_dev->dev_addr, dev->addr_len);
716 if (is_zero_ether_addr(dev->broadcast))

--- 37 unchanged lines hidden (view full) ---

754 for (i = 0; i < ARRAY_SIZE(vlan->egress_priority_map); i++) {
755 while ((pm = vlan->egress_priority_map[i]) != NULL) {
756 vlan->egress_priority_map[i] = pm->next;
757 kfree(pm);
758 }
759 }
760}
761
709 dev->gso_max_size = real_dev->gso_max_size;
710
711 /* ipv6 shared card related stuff */
712 dev->dev_id = real_dev->dev_id;
713
714 if (is_zero_ether_addr(dev->dev_addr))
715 memcpy(dev->dev_addr, real_dev->dev_addr, dev->addr_len);
716 if (is_zero_ether_addr(dev->broadcast))

--- 37 unchanged lines hidden (view full) ---

754 for (i = 0; i < ARRAY_SIZE(vlan->egress_priority_map); i++) {
755 while ((pm = vlan->egress_priority_map[i]) != NULL) {
756 vlan->egress_priority_map[i] = pm->next;
757 kfree(pm);
758 }
759 }
760}
761
762static u32 vlan_dev_fix_features(struct net_device *dev, u32 features)
763{
764 struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
765
766 features &= (real_dev->features | NETIF_F_LLTX);
767 if (dev_ethtool_get_rx_csum(real_dev))
768 features |= NETIF_F_RXCSUM;
769
770 return features;
771}
772
762static int vlan_ethtool_get_settings(struct net_device *dev,
763 struct ethtool_cmd *cmd)
764{
765 const struct vlan_dev_info *vlan = vlan_dev_info(dev);
766 return dev_ethtool_get_settings(vlan->real_dev, cmd);
767}
768
769static void vlan_ethtool_get_drvinfo(struct net_device *dev,
770 struct ethtool_drvinfo *info)
771{
772 strcpy(info->driver, vlan_fullname);
773 strcpy(info->version, vlan_version);
774 strcpy(info->fw_version, "N/A");
775}
776
773static int vlan_ethtool_get_settings(struct net_device *dev,
774 struct ethtool_cmd *cmd)
775{
776 const struct vlan_dev_info *vlan = vlan_dev_info(dev);
777 return dev_ethtool_get_settings(vlan->real_dev, cmd);
778}
779
780static void vlan_ethtool_get_drvinfo(struct net_device *dev,
781 struct ethtool_drvinfo *info)
782{
783 strcpy(info->driver, vlan_fullname);
784 strcpy(info->version, vlan_version);
785 strcpy(info->fw_version, "N/A");
786}
787
777static u32 vlan_ethtool_get_rx_csum(struct net_device *dev)
778{
779 const struct vlan_dev_info *vlan = vlan_dev_info(dev);
780 return dev_ethtool_get_rx_csum(vlan->real_dev);
781}
782
783static u32 vlan_ethtool_get_flags(struct net_device *dev)
784{
785 const struct vlan_dev_info *vlan = vlan_dev_info(dev);
786 return dev_ethtool_get_flags(vlan->real_dev);
787}
788
789static struct rtnl_link_stats64 *vlan_dev_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
790{
791
792 if (vlan_dev_info(dev)->vlan_pcpu_stats) {
793 struct vlan_pcpu_stats *p;
794 u32 rx_errors = 0, tx_dropped = 0;
795 int i;
796

--- 21 unchanged lines hidden (view full) ---

818 tx_dropped += p->tx_dropped;
819 }
820 stats->rx_errors = rx_errors;
821 stats->tx_dropped = tx_dropped;
822 }
823 return stats;
824}
825
788static struct rtnl_link_stats64 *vlan_dev_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
789{
790
791 if (vlan_dev_info(dev)->vlan_pcpu_stats) {
792 struct vlan_pcpu_stats *p;
793 u32 rx_errors = 0, tx_dropped = 0;
794 int i;
795

--- 21 unchanged lines hidden (view full) ---

817 tx_dropped += p->tx_dropped;
818 }
819 stats->rx_errors = rx_errors;
820 stats->tx_dropped = tx_dropped;
821 }
822 return stats;
823}
824
826static int vlan_ethtool_set_tso(struct net_device *dev, u32 data)
827{
828 if (data) {
829 struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
830
831 /* Underlying device must support TSO for VLAN-tagged packets
832 * and must have TSO enabled now.
833 */
834 if (!(real_dev->vlan_features & NETIF_F_TSO))
835 return -EOPNOTSUPP;
836 if (!(real_dev->features & NETIF_F_TSO))
837 return -EINVAL;
838 dev->features |= NETIF_F_TSO;
839 } else {
840 dev->features &= ~NETIF_F_TSO;
841 }
842 return 0;
843}
844
845static const struct ethtool_ops vlan_ethtool_ops = {
846 .get_settings = vlan_ethtool_get_settings,
847 .get_drvinfo = vlan_ethtool_get_drvinfo,
848 .get_link = ethtool_op_get_link,
825static const struct ethtool_ops vlan_ethtool_ops = {
826 .get_settings = vlan_ethtool_get_settings,
827 .get_drvinfo = vlan_ethtool_get_drvinfo,
828 .get_link = ethtool_op_get_link,
849 .get_rx_csum = vlan_ethtool_get_rx_csum,
850 .get_flags = vlan_ethtool_get_flags,
851 .set_tso = vlan_ethtool_set_tso,
852};
853
854static const struct net_device_ops vlan_netdev_ops = {
855 .ndo_change_mtu = vlan_dev_change_mtu,
856 .ndo_init = vlan_dev_init,
857 .ndo_uninit = vlan_dev_uninit,
858 .ndo_open = vlan_dev_open,
859 .ndo_stop = vlan_dev_stop,

--- 9 unchanged lines hidden (view full) ---

869#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
870 .ndo_fcoe_ddp_setup = vlan_dev_fcoe_ddp_setup,
871 .ndo_fcoe_ddp_done = vlan_dev_fcoe_ddp_done,
872 .ndo_fcoe_enable = vlan_dev_fcoe_enable,
873 .ndo_fcoe_disable = vlan_dev_fcoe_disable,
874 .ndo_fcoe_get_wwn = vlan_dev_fcoe_get_wwn,
875 .ndo_fcoe_ddp_target = vlan_dev_fcoe_ddp_target,
876#endif
829};
830
831static const struct net_device_ops vlan_netdev_ops = {
832 .ndo_change_mtu = vlan_dev_change_mtu,
833 .ndo_init = vlan_dev_init,
834 .ndo_uninit = vlan_dev_uninit,
835 .ndo_open = vlan_dev_open,
836 .ndo_stop = vlan_dev_stop,

--- 9 unchanged lines hidden (view full) ---

846#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
847 .ndo_fcoe_ddp_setup = vlan_dev_fcoe_ddp_setup,
848 .ndo_fcoe_ddp_done = vlan_dev_fcoe_ddp_done,
849 .ndo_fcoe_enable = vlan_dev_fcoe_enable,
850 .ndo_fcoe_disable = vlan_dev_fcoe_disable,
851 .ndo_fcoe_get_wwn = vlan_dev_fcoe_get_wwn,
852 .ndo_fcoe_ddp_target = vlan_dev_fcoe_ddp_target,
853#endif
854 .ndo_fix_features = vlan_dev_fix_features,
877};
878
879void vlan_setup(struct net_device *dev)
880{
881 ether_setup(dev);
882
883 dev->priv_flags |= IFF_802_1Q_VLAN;
884 dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
885 dev->tx_queue_len = 0;
886
887 dev->netdev_ops = &vlan_netdev_ops;
888 dev->destructor = free_netdev;
889 dev->ethtool_ops = &vlan_ethtool_ops;
890
891 memset(dev->broadcast, 0, ETH_ALEN);
892}
855};
856
857void vlan_setup(struct net_device *dev)
858{
859 ether_setup(dev);
860
861 dev->priv_flags |= IFF_802_1Q_VLAN;
862 dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
863 dev->tx_queue_len = 0;
864
865 dev->netdev_ops = &vlan_netdev_ops;
866 dev->destructor = free_netdev;
867 dev->ethtool_ops = &vlan_ethtool_ops;
868
869 memset(dev->broadcast, 0, ETH_ALEN);
870}