Lines Matching refs:vlan
61 struct macvlan_dev *vlan; member
127 struct macvlan_dev *vlan; in macvlan_hash_lookup() local
130 hlist_for_each_entry_rcu(vlan, &port->vlan_hash[idx], hlist, in macvlan_hash_lookup()
132 if (ether_addr_equal_64bits(vlan->dev->dev_addr, addr)) in macvlan_hash_lookup()
133 return vlan; in macvlan_hash_lookup()
139 const struct macvlan_dev *vlan, in macvlan_hash_lookup_source() argument
144 struct hlist_head *h = &vlan->port->vlan_source_hash[idx]; in macvlan_hash_lookup_source()
148 entry->vlan == vlan) in macvlan_hash_lookup_source()
154 static int macvlan_hash_add_source(struct macvlan_dev *vlan, in macvlan_hash_add_source() argument
157 struct macvlan_port *port = vlan->port; in macvlan_hash_add_source()
161 entry = macvlan_hash_lookup_source(vlan, addr); in macvlan_hash_add_source()
170 entry->vlan = vlan; in macvlan_hash_add_source()
173 vlan->macaddr_count++; in macvlan_hash_add_source()
178 static void macvlan_hash_add(struct macvlan_dev *vlan) in macvlan_hash_add() argument
180 struct macvlan_port *port = vlan->port; in macvlan_hash_add()
181 const unsigned char *addr = vlan->dev->dev_addr; in macvlan_hash_add()
184 hlist_add_head_rcu(&vlan->hlist, &port->vlan_hash[idx]); in macvlan_hash_add()
193 static void macvlan_hash_del(struct macvlan_dev *vlan, bool sync) in macvlan_hash_del() argument
195 hlist_del_rcu(&vlan->hlist); in macvlan_hash_del()
200 static void macvlan_hash_change_addr(struct macvlan_dev *vlan, in macvlan_hash_change_addr() argument
203 macvlan_hash_del(vlan, true); in macvlan_hash_change_addr()
207 eth_hw_addr_set(vlan->dev, addr); in macvlan_hash_change_addr()
208 macvlan_hash_add(vlan); in macvlan_hash_change_addr()
230 const struct macvlan_dev *vlan, in macvlan_broadcast_one() argument
233 struct net_device *dev = vlan->dev; in macvlan_broadcast_one()
247 static u32 macvlan_hash_mix(const struct macvlan_dev *vlan) in macvlan_hash_mix() argument
249 return (u32)(((unsigned long)vlan) >> L1_CACHE_SHIFT); in macvlan_hash_mix()
253 static unsigned int mc_hash(const struct macvlan_dev *vlan, in mc_hash() argument
258 val ^= macvlan_hash_mix(vlan); in mc_hash()
268 const struct macvlan_dev *vlan; in macvlan_broadcast() local
277 hash_for_each_rcu(port->vlan_hash, i, vlan, hlist) { in macvlan_broadcast()
278 if (vlan->dev == src || !(vlan->mode & mode)) in macvlan_broadcast()
281 hash = mc_hash(vlan, eth->h_dest); in macvlan_broadcast()
282 if (!test_bit(hash, vlan->mc_filter)) in macvlan_broadcast()
288 err = macvlan_broadcast_one(nskb, vlan, eth, in macvlan_broadcast()
291 macvlan_count_rx(vlan, skb->len + ETH_HLEN, in macvlan_broadcast()
385 struct macvlan_dev *vlan) in macvlan_flush_sources() argument
392 if (entry->vlan == vlan) in macvlan_flush_sources()
395 vlan->macaddr_count = 0; in macvlan_flush_sources()
399 struct macvlan_dev *vlan) in macvlan_forward_source_one() argument
406 dev = vlan->dev; in macvlan_forward_source_one()
421 macvlan_count_rx(vlan, len, ret == NET_RX_SUCCESS, false); in macvlan_forward_source_one()
435 if (entry->vlan->flags & MACVLAN_FLAG_NODST) in macvlan_forward_source()
437 macvlan_forward_source_one(skb, entry->vlan); in macvlan_forward_source()
450 const struct macvlan_dev *vlan; in macvlan_handle_frame() local
478 vlan = src; in macvlan_handle_frame()
479 ret = macvlan_broadcast_one(skb, vlan, eth, 0) ?: in macvlan_handle_frame()
499 vlan = list_first_or_null_rcu(&port->vlans, in macvlan_handle_frame()
502 vlan = macvlan_hash_lookup(port, eth->h_dest); in macvlan_handle_frame()
503 if (!vlan || vlan->mode == MACVLAN_MODE_SOURCE) in macvlan_handle_frame()
506 dev = vlan->dev; in macvlan_handle_frame()
526 macvlan_count_rx(vlan, len, ret == NET_RX_SUCCESS, false); in macvlan_handle_frame()
532 const struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_queue_xmit() local
533 const struct macvlan_port *port = vlan->port; in macvlan_queue_xmit()
536 if (vlan->mode == MACVLAN_MODE_BRIDGE) { in macvlan_queue_xmit()
549 dev_forward_skb(vlan->lowerdev, skb); in macvlan_queue_xmit()
555 skb->dev = vlan->lowerdev; in macvlan_queue_xmit()
560 static inline netdev_tx_t macvlan_netpoll_send_skb(struct macvlan_dev *vlan, struct sk_buff *skb) in macvlan_netpoll_send_skb() argument
563 return netpoll_send_skb(vlan->netpoll, skb); in macvlan_netpoll_send_skb()
573 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_start_xmit() local
578 return macvlan_netpoll_send_skb(vlan, skb); in macvlan_start_xmit()
585 pcpu_stats = this_cpu_ptr(vlan->pcpu_stats); in macvlan_start_xmit()
591 this_cpu_inc(vlan->pcpu_stats->tx_dropped); in macvlan_start_xmit()
600 const struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_hard_header() local
601 struct net_device *lowerdev = vlan->lowerdev; in macvlan_hard_header()
617 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_open() local
618 struct net_device *lowerdev = vlan->lowerdev; in macvlan_open()
621 if (macvlan_passthru(vlan->port)) { in macvlan_open()
622 if (!(vlan->flags & MACVLAN_FLAG_NOPROMISC)) { in macvlan_open()
631 if (macvlan_addr_busy(vlan->port, dev->dev_addr)) in macvlan_open()
638 vlan->accel_priv = in macvlan_open()
644 if (IS_ERR_OR_NULL(vlan->accel_priv)) { in macvlan_open()
645 vlan->accel_priv = NULL; in macvlan_open()
664 macvlan_hash_add(vlan); in macvlan_open()
671 if (vlan->accel_priv) { in macvlan_open()
673 vlan->accel_priv); in macvlan_open()
674 vlan->accel_priv = NULL; in macvlan_open()
684 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_stop() local
685 struct net_device *lowerdev = vlan->lowerdev; in macvlan_stop()
687 if (vlan->accel_priv) { in macvlan_stop()
689 vlan->accel_priv); in macvlan_stop()
690 vlan->accel_priv = NULL; in macvlan_stop()
696 if (macvlan_passthru(vlan->port)) { in macvlan_stop()
697 if (!(vlan->flags & MACVLAN_FLAG_NOPROMISC)) in macvlan_stop()
711 macvlan_hash_del(vlan, !dev->dismantle); in macvlan_stop()
718 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_sync_address() local
719 struct net_device *lowerdev = vlan->lowerdev; in macvlan_sync_address()
720 struct macvlan_port *port = vlan->port; in macvlan_sync_address()
728 if (macvlan_addr_busy(vlan->port, addr)) in macvlan_sync_address()
739 macvlan_hash_change_addr(vlan, addr); in macvlan_sync_address()
746 ether_addr_copy(vlan->port->perm_addr, in macvlan_sync_address()
755 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_set_mac_address() local
765 if (vlan->mode == MACVLAN_MODE_PASSTHRU) { in macvlan_set_mac_address()
766 macvlan_set_addr_change(vlan->port); in macvlan_set_mac_address()
767 return dev_set_mac_address(vlan->lowerdev, addr, NULL); in macvlan_set_mac_address()
770 if (macvlan_addr_busy(vlan->port, addr->sa_data)) in macvlan_set_mac_address()
778 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_change_rx_flags() local
779 struct net_device *lowerdev = vlan->lowerdev; in macvlan_change_rx_flags()
784 if (!macvlan_passthru(vlan->port) && change & IFF_PROMISC) in macvlan_change_rx_flags()
793 struct macvlan_dev *vlan, int cutoff) in macvlan_compute_filter() argument
803 if (!vlan && ha->synced <= cutoff) in macvlan_compute_filter()
806 __set_bit(mc_hash(vlan, ha->addr), filter); in macvlan_compute_filter()
809 __set_bit(mc_hash(vlan, dev->broadcast), filter); in macvlan_compute_filter()
815 static void macvlan_recompute_bc_filter(struct macvlan_dev *vlan) in macvlan_recompute_bc_filter() argument
817 if (vlan->port->bc_cutoff < 0) { in macvlan_recompute_bc_filter()
818 bitmap_zero(vlan->port->bc_filter, MACVLAN_MC_FILTER_SZ); in macvlan_recompute_bc_filter()
822 macvlan_compute_filter(vlan->port->bc_filter, vlan->lowerdev, NULL, in macvlan_recompute_bc_filter()
823 vlan->port->bc_cutoff); in macvlan_recompute_bc_filter()
828 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_set_mac_lists() local
830 macvlan_compute_filter(vlan->mc_filter, dev, vlan, 0); in macvlan_set_mac_lists()
832 dev_uc_sync(vlan->lowerdev, dev); in macvlan_set_mac_lists()
833 dev_mc_sync(vlan->lowerdev, dev); in macvlan_set_mac_lists()
848 macvlan_compute_filter(vlan->port->mc_filter, vlan->lowerdev, NULL, in macvlan_set_mac_lists()
850 macvlan_recompute_bc_filter(vlan); in macvlan_set_mac_lists()
853 static void update_port_bc_cutoff(struct macvlan_dev *vlan, int cutoff) in update_port_bc_cutoff() argument
855 if (vlan->port->bc_cutoff == cutoff) in update_port_bc_cutoff()
858 vlan->port->bc_cutoff = cutoff; in update_port_bc_cutoff()
859 macvlan_recompute_bc_filter(vlan); in update_port_bc_cutoff()
864 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_change_mtu() local
866 if (vlan->lowerdev->mtu < new_mtu) in macvlan_change_mtu()
923 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_init() local
924 struct net_device *lowerdev = vlan->lowerdev; in macvlan_init()
925 struct macvlan_port *port = vlan->port; in macvlan_init()
940 vlan->pcpu_stats = netdev_alloc_pcpu_stats(struct vlan_pcpu_stats); in macvlan_init()
941 if (!vlan->pcpu_stats) in macvlan_init()
947 netdev_hold(lowerdev, &vlan->dev_tracker, GFP_KERNEL); in macvlan_init()
954 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_uninit() local
955 struct macvlan_port *port = vlan->port; in macvlan_uninit()
957 free_percpu(vlan->pcpu_stats); in macvlan_uninit()
959 macvlan_flush_sources(port, vlan); in macvlan_uninit()
968 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_dev_get_stats64() local
970 if (vlan->pcpu_stats) { in macvlan_dev_get_stats64()
978 p = per_cpu_ptr(vlan->pcpu_stats, i); in macvlan_dev_get_stats64()
1008 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_vlan_rx_add_vid() local
1009 struct net_device *lowerdev = vlan->lowerdev; in macvlan_vlan_rx_add_vid()
1017 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_vlan_rx_kill_vid() local
1018 struct net_device *lowerdev = vlan->lowerdev; in macvlan_vlan_rx_kill_vid()
1030 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_fdb_add() local
1036 if (!macvlan_passthru(vlan->port) && is_unicast_ether_addr(addr)) in macvlan_fdb_add()
1055 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_fdb_del() local
1061 if (!macvlan_passthru(vlan->port) && is_unicast_ether_addr(addr)) in macvlan_fdb_del()
1082 const struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_ethtool_get_link_ksettings() local
1084 return __ethtool_get_link_ksettings(vlan->lowerdev, cmd); in macvlan_ethtool_get_link_ksettings()
1098 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_fix_features() local
1099 netdev_features_t lowerdev_features = vlan->lowerdev->features; in macvlan_fix_features()
1103 features &= (vlan->set_features | ~MACVLAN_FEATURES); in macvlan_fix_features()
1122 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_dev_netpoll_setup() local
1123 struct net_device *real_dev = vlan->lowerdev; in macvlan_dev_netpoll_setup()
1138 vlan->netpoll = netpoll; in macvlan_dev_netpoll_setup()
1146 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_dev_netpoll_cleanup() local
1147 struct netpoll *netpoll = vlan->netpoll; in macvlan_dev_netpoll_cleanup()
1152 vlan->netpoll = NULL; in macvlan_dev_netpoll_cleanup()
1160 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_dev_get_iflink() local
1162 return READ_ONCE(vlan->lowerdev->ifindex); in macvlan_dev_get_iflink()
1203 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_dev_free() local
1206 netdev_put(vlan->lowerdev, &vlan->dev_tracker); in macvlan_dev_free()
1387 static int macvlan_changelink_sources(struct macvlan_dev *vlan, u32 mode, in macvlan_changelink_sources() argument
1402 return macvlan_hash_add_source(vlan, addr); in macvlan_changelink_sources()
1408 entry = macvlan_hash_lookup_source(vlan, addr); in macvlan_changelink_sources()
1411 vlan->macaddr_count--; in macvlan_changelink_sources()
1414 macvlan_flush_sources(vlan->port, vlan); in macvlan_changelink_sources()
1416 macvlan_flush_sources(vlan->port, vlan); in macvlan_changelink_sources()
1419 ret = macvlan_hash_add_source(vlan, addr); in macvlan_changelink_sources()
1432 ret = macvlan_hash_add_source(vlan, addr); in macvlan_changelink_sources()
1447 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_common_newlink() local
1496 vlan->lowerdev = lowerdev; in macvlan_common_newlink()
1497 vlan->dev = dev; in macvlan_common_newlink()
1498 vlan->port = port; in macvlan_common_newlink()
1499 vlan->set_features = MACVLAN_FEATURES; in macvlan_common_newlink()
1501 vlan->mode = MACVLAN_MODE_VEPA; in macvlan_common_newlink()
1503 vlan->mode = nla_get_u32(data[IFLA_MACVLAN_MODE]); in macvlan_common_newlink()
1506 vlan->flags = nla_get_u16(data[IFLA_MACVLAN_FLAGS]); in macvlan_common_newlink()
1508 if (vlan->mode == MACVLAN_MODE_PASSTHRU) { in macvlan_common_newlink()
1518 if (vlan->mode != MACVLAN_MODE_SOURCE) { in macvlan_common_newlink()
1523 err = macvlan_changelink_sources(vlan, macmode, data); in macvlan_common_newlink()
1528 vlan->bc_queue_len_req = MACVLAN_DEFAULT_BC_QUEUE_LEN; in macvlan_common_newlink()
1530 vlan->bc_queue_len_req = nla_get_u32(data[IFLA_MACVLAN_BC_QUEUE_LEN]); in macvlan_common_newlink()
1534 vlan, nla_get_s32(data[IFLA_MACVLAN_BC_CUTOFF])); in macvlan_common_newlink()
1545 list_add_tail_rcu(&vlan->list, &port->vlans); in macvlan_common_newlink()
1546 update_port_bc_queue_len(vlan->port); in macvlan_common_newlink()
1561 macvlan_flush_sources(port, vlan); in macvlan_common_newlink()
1577 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_dellink() local
1579 if (vlan->mode == MACVLAN_MODE_SOURCE) in macvlan_dellink()
1580 macvlan_flush_sources(vlan->port, vlan); in macvlan_dellink()
1581 list_del_rcu(&vlan->list); in macvlan_dellink()
1582 update_port_bc_queue_len(vlan->port); in macvlan_dellink()
1584 netdev_upper_dev_unlink(vlan->lowerdev, dev); in macvlan_dellink()
1592 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_changelink() local
1604 (vlan->mode == MACVLAN_MODE_PASSTHRU)) in macvlan_changelink()
1606 if (vlan->mode == MACVLAN_MODE_SOURCE && in macvlan_changelink()
1607 vlan->mode != mode) in macvlan_changelink()
1608 macvlan_flush_sources(vlan->port, vlan); in macvlan_changelink()
1613 bool promisc = (flags ^ vlan->flags) & MACVLAN_FLAG_NOPROMISC; in macvlan_changelink()
1614 if (macvlan_passthru(vlan->port) && promisc) { in macvlan_changelink()
1618 err = dev_set_promiscuity(vlan->lowerdev, -1); in macvlan_changelink()
1620 err = dev_set_promiscuity(vlan->lowerdev, 1); in macvlan_changelink()
1624 vlan->flags = flags; in macvlan_changelink()
1628 vlan->bc_queue_len_req = nla_get_u32(data[IFLA_MACVLAN_BC_QUEUE_LEN]); in macvlan_changelink()
1629 update_port_bc_queue_len(vlan->port); in macvlan_changelink()
1634 vlan, nla_get_s32(data[IFLA_MACVLAN_BC_CUTOFF])); in macvlan_changelink()
1637 vlan->mode = mode; in macvlan_changelink()
1639 if (vlan->mode != MACVLAN_MODE_SOURCE) in macvlan_changelink()
1642 ret = macvlan_changelink_sources(vlan, macmode, data); in macvlan_changelink()
1649 static size_t macvlan_get_size_mac(const struct macvlan_dev *vlan) in macvlan_get_size_mac() argument
1651 if (vlan->macaddr_count == 0) in macvlan_get_size_mac()
1654 + vlan->macaddr_count * nla_total_size(sizeof(u8) * ETH_ALEN); in macvlan_get_size_mac()
1659 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_get_size() local
1665 + macvlan_get_size_mac(vlan) /* IFLA_MACVLAN_MACADDR */ in macvlan_get_size()
1672 const struct macvlan_dev *vlan, in macvlan_fill_info_macaddr() argument
1675 struct hlist_head *h = &vlan->port->vlan_source_hash[i]; in macvlan_fill_info_macaddr()
1679 if (entry->vlan != vlan) in macvlan_fill_info_macaddr()
1690 struct macvlan_dev *vlan = netdev_priv(dev); in macvlan_fill_info() local
1691 struct macvlan_port *port = vlan->port; in macvlan_fill_info()
1695 if (nla_put_u32(skb, IFLA_MACVLAN_MODE, vlan->mode)) in macvlan_fill_info()
1697 if (nla_put_u16(skb, IFLA_MACVLAN_FLAGS, vlan->flags)) in macvlan_fill_info()
1699 if (nla_put_u32(skb, IFLA_MACVLAN_MACADDR_COUNT, vlan->macaddr_count)) in macvlan_fill_info()
1701 if (vlan->macaddr_count > 0) { in macvlan_fill_info()
1707 if (macvlan_fill_info_macaddr(skb, vlan, i)) in macvlan_fill_info()
1712 if (nla_put_u32(skb, IFLA_MACVLAN_BC_QUEUE_LEN, vlan->bc_queue_len_req)) in macvlan_fill_info()
1768 struct macvlan_dev *vlan; in update_port_bc_queue_len() local
1770 list_for_each_entry(vlan, &port->vlans, list) { in update_port_bc_queue_len()
1771 if (vlan->bc_queue_len_req > max_bc_queue_len_req) in update_port_bc_queue_len()
1772 max_bc_queue_len_req = vlan->bc_queue_len_req; in update_port_bc_queue_len()
1781 struct macvlan_dev *vlan, *next; in macvlan_device_event() local
1794 list_for_each_entry(vlan, &port->vlans, list) in macvlan_device_event()
1795 netif_stacked_transfer_operstate(vlan->lowerdev, in macvlan_device_event()
1796 vlan->dev); in macvlan_device_event()
1799 list_for_each_entry(vlan, &port->vlans, list) { in macvlan_device_event()
1800 netif_inherit_tso_max(vlan->dev, dev); in macvlan_device_event()
1801 netdev_update_features(vlan->dev); in macvlan_device_event()
1805 list_for_each_entry(vlan, &port->vlans, list) { in macvlan_device_event()
1806 if (vlan->dev->mtu <= dev->mtu) in macvlan_device_event()
1808 dev_set_mtu(vlan->dev, dev->mtu); in macvlan_device_event()
1815 vlan = list_first_entry_or_null(&port->vlans, in macvlan_device_event()
1819 if (vlan && macvlan_sync_address(vlan->dev, dev->dev_addr)) in macvlan_device_event()
1828 list_for_each_entry_safe(vlan, next, &port->vlans, list) in macvlan_device_event()
1829 vlan->dev->rtnl_link_ops->dellink(vlan->dev, &list_kill); in macvlan_device_event()
1840 list_for_each_entry(vlan, &port->vlans, list) in macvlan_device_event()
1841 call_netdevice_notifiers(event, vlan->dev); in macvlan_device_event()