Lines Matching +full:dp +full:- +full:bridge
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * net/dsa/user.c - user device handling
4 * Copyright (c) 2008-2009 Marvell Semiconductor
70 return ds->ops->port_fdb_add && ds->ops->port_fdb_del && in dsa_switch_supports_uc_filtering()
71 ds->fdb_isolation && !ds->vlan_filtering_is_global && in dsa_switch_supports_uc_filtering()
72 !ds->needs_standalone_vlan_filtering; in dsa_switch_supports_uc_filtering()
77 return ds->ops->port_mdb_add && ds->ops->port_mdb_del && in dsa_switch_supports_mc_filtering()
78 ds->fdb_isolation && !ds->vlan_filtering_is_global && in dsa_switch_supports_mc_filtering()
79 !ds->needs_standalone_vlan_filtering; in dsa_switch_supports_mc_filtering()
86 const unsigned char *addr = standalone_work->addr; in dsa_user_standalone_event_work()
87 struct net_device *dev = standalone_work->dev; in dsa_user_standalone_event_work()
88 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_standalone_event_work() local
90 struct dsa_switch *ds = dp->ds; in dsa_user_standalone_event_work()
91 u16 vid = standalone_work->vid; in dsa_user_standalone_event_work()
94 switch (standalone_work->event) { in dsa_user_standalone_event_work()
96 err = dsa_port_standalone_host_fdb_add(dp, addr, vid); in dsa_user_standalone_event_work()
98 dev_err(ds->dev, in dsa_user_standalone_event_work()
100 dp->index, addr, vid, err); in dsa_user_standalone_event_work()
106 err = dsa_port_standalone_host_fdb_del(dp, addr, vid); in dsa_user_standalone_event_work()
108 dev_err(ds->dev, in dsa_user_standalone_event_work()
110 dp->index, addr, vid, err); in dsa_user_standalone_event_work()
118 err = dsa_port_standalone_host_mdb_add(dp, &mdb); in dsa_user_standalone_event_work()
120 dev_err(ds->dev, in dsa_user_standalone_event_work()
122 dp->index, addr, vid, err); in dsa_user_standalone_event_work()
130 err = dsa_port_standalone_host_mdb_del(dp, &mdb); in dsa_user_standalone_event_work()
132 dev_err(ds->dev, in dsa_user_standalone_event_work()
134 dp->index, addr, vid, err); in dsa_user_standalone_event_work()
152 return -ENOMEM; in dsa_user_schedule_standalone_work()
154 INIT_WORK(&standalone_work->work, dsa_user_standalone_event_work); in dsa_user_schedule_standalone_work()
155 standalone_work->event = event; in dsa_user_schedule_standalone_work()
156 standalone_work->dev = dev; in dsa_user_schedule_standalone_work()
158 ether_addr_copy(standalone_work->addr, addr); in dsa_user_schedule_standalone_work()
159 standalone_work->vid = vid; in dsa_user_schedule_standalone_work()
161 dsa_schedule_work(&standalone_work->work); in dsa_user_schedule_standalone_work()
170 return dsa_user_schedule_standalone_work(ctx->dev, ctx->event, in dsa_user_host_vlan_rx_filtering()
171 ctx->addr, vid); in dsa_user_host_vlan_rx_filtering()
177 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_vlan_for_each() local
181 lockdep_assert_held(&dev->addr_list_lock); in dsa_user_vlan_for_each()
187 list_for_each_entry(v, &dp->user_vlans, list) { in dsa_user_vlan_for_each()
188 err = cb(arg, v->vid); in dsa_user_vlan_for_each()
200 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_sync_uc() local
209 if (!dsa_switch_supports_uc_filtering(dp->ds)) in dsa_user_sync_uc()
220 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_unsync_uc() local
229 if (!dsa_switch_supports_uc_filtering(dp->ds)) in dsa_user_unsync_uc()
240 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_sync_mc() local
249 if (!dsa_switch_supports_mc_filtering(dp->ds)) in dsa_user_sync_mc()
260 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_unsync_mc() local
269 if (!dsa_switch_supports_mc_filtering(dp->ds)) in dsa_user_unsync_mc()
278 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_sync_ha() local
279 struct dsa_switch *ds = dp->ds; in dsa_user_sync_ha()
285 dsa_user_sync_mc(dev, ha->addr); in dsa_user_sync_ha()
288 dsa_user_sync_uc(dev, ha->addr); in dsa_user_sync_ha()
299 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_unsync_ha() local
300 struct dsa_switch *ds = dp->ds; in dsa_user_unsync_ha()
306 dsa_user_unsync_uc(dev, ha->addr); in dsa_user_unsync_ha()
309 dsa_user_unsync_mc(dev, ha->addr); in dsa_user_unsync_ha()
321 struct dsa_switch *ds = bus->priv; in dsa_user_phy_read()
323 if (ds->phys_mii_mask & (1 << addr)) in dsa_user_phy_read()
324 return ds->ops->phy_read(ds, addr, reg); in dsa_user_phy_read()
331 struct dsa_switch *ds = bus->priv; in dsa_user_phy_write()
333 if (ds->phys_mii_mask & (1 << addr)) in dsa_user_phy_write()
334 return ds->ops->phy_write(ds, addr, reg, val); in dsa_user_phy_write()
341 ds->user_mii_bus->priv = (void *)ds; in dsa_user_mii_bus_init()
342 ds->user_mii_bus->name = "dsa user smi"; in dsa_user_mii_bus_init()
343 ds->user_mii_bus->read = dsa_user_phy_read; in dsa_user_mii_bus_init()
344 ds->user_mii_bus->write = dsa_user_phy_write; in dsa_user_mii_bus_init()
345 snprintf(ds->user_mii_bus->id, MII_BUS_ID_SIZE, "dsa-%d.%d", in dsa_user_mii_bus_init()
346 ds->dst->index, ds->index); in dsa_user_mii_bus_init()
347 ds->user_mii_bus->parent = ds->dev; in dsa_user_mii_bus_init()
348 ds->user_mii_bus->phy_mask = ~ds->phys_mii_mask; in dsa_user_mii_bus_init()
355 return READ_ONCE(dsa_user_to_conduit(dev)->ifindex); in dsa_user_get_iflink()
361 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_host_uc_install() local
362 struct dsa_switch *ds = dp->ds; in dsa_user_host_uc_install()
366 err = dsa_port_standalone_host_fdb_add(dp, addr, 0); in dsa_user_host_uc_install()
371 if (!ether_addr_equal(addr, conduit->dev_addr)) { in dsa_user_host_uc_install()
381 dsa_port_standalone_host_fdb_del(dp, addr, 0); in dsa_user_host_uc_install()
389 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_host_uc_uninstall() local
390 struct dsa_switch *ds = dp->ds; in dsa_user_host_uc_uninstall()
392 if (!ether_addr_equal(dev->dev_addr, conduit->dev_addr)) in dsa_user_host_uc_uninstall()
393 dev_uc_del(conduit, dev->dev_addr); in dsa_user_host_uc_uninstall()
396 dsa_port_standalone_host_fdb_del(dp, dev->dev_addr, 0); in dsa_user_host_uc_uninstall()
402 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_open() local
407 netdev_err(dev, "failed to open conduit %s\n", conduit->name); in dsa_user_open()
411 err = dsa_user_host_uc_install(dev, dev->dev_addr); in dsa_user_open()
415 err = dsa_port_enable_rt(dp, dev->phydev); in dsa_user_open()
429 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_close() local
431 dsa_port_disable_rt(dp); in dsa_user_close()
440 bool mc = dev->flags & (IFF_PROMISC | IFF_ALLMULTI); in dsa_user_manage_host_flood()
441 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_manage_host_flood() local
442 bool uc = dev->flags & IFF_PROMISC; in dsa_user_manage_host_flood()
444 dsa_port_set_host_flood(dp, uc, mc); in dsa_user_manage_host_flood()
450 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_change_rx_flags() local
451 struct dsa_switch *ds = dp->ds; in dsa_user_change_rx_flags()
455 dev->flags & IFF_ALLMULTI ? 1 : -1); in dsa_user_change_rx_flags()
458 dev->flags & IFF_PROMISC ? 1 : -1); in dsa_user_change_rx_flags()
473 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_set_mac_address() local
474 struct dsa_switch *ds = dp->ds; in dsa_user_set_mac_address()
478 if (!is_valid_ether_addr(addr->sa_data)) in dsa_user_set_mac_address()
479 return -EADDRNOTAVAIL; in dsa_user_set_mac_address()
481 if (ds->ops->port_set_mac_address) { in dsa_user_set_mac_address()
482 err = ds->ops->port_set_mac_address(ds, dp->index, in dsa_user_set_mac_address()
483 addr->sa_data); in dsa_user_set_mac_address()
491 if (!(dev->flags & IFF_UP)) in dsa_user_set_mac_address()
494 err = dsa_user_host_uc_install(dev, addr->sa_data); in dsa_user_set_mac_address()
501 eth_hw_addr_set(dev, addr->sa_data); in dsa_user_set_mac_address()
518 u32 portid = NETLINK_CB(dump->cb->skb).portid; in dsa_user_port_fdb_do_dump()
519 u32 seq = dump->cb->nlh->nlmsg_seq; in dsa_user_port_fdb_do_dump()
523 if (dump->idx < dump->cb->args[2]) in dsa_user_port_fdb_do_dump()
526 nlh = nlmsg_put(dump->skb, portid, seq, RTM_NEWNEIGH, in dsa_user_port_fdb_do_dump()
529 return -EMSGSIZE; in dsa_user_port_fdb_do_dump()
532 ndm->ndm_family = AF_BRIDGE; in dsa_user_port_fdb_do_dump()
533 ndm->ndm_pad1 = 0; in dsa_user_port_fdb_do_dump()
534 ndm->ndm_pad2 = 0; in dsa_user_port_fdb_do_dump()
535 ndm->ndm_flags = NTF_SELF; in dsa_user_port_fdb_do_dump()
536 ndm->ndm_type = 0; in dsa_user_port_fdb_do_dump()
537 ndm->ndm_ifindex = dump->dev->ifindex; in dsa_user_port_fdb_do_dump()
538 ndm->ndm_state = is_static ? NUD_NOARP : NUD_REACHABLE; in dsa_user_port_fdb_do_dump()
540 if (nla_put(dump->skb, NDA_LLADDR, ETH_ALEN, addr)) in dsa_user_port_fdb_do_dump()
543 if (vid && nla_put_u16(dump->skb, NDA_VLAN, vid)) in dsa_user_port_fdb_do_dump()
546 nlmsg_end(dump->skb, nlh); in dsa_user_port_fdb_do_dump()
549 dump->idx++; in dsa_user_port_fdb_do_dump()
553 nlmsg_cancel(dump->skb, nlh); in dsa_user_port_fdb_do_dump()
554 return -EMSGSIZE; in dsa_user_port_fdb_do_dump()
562 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_fdb_dump() local
571 err = dsa_port_fdb_dump(dp, dsa_user_port_fdb_do_dump, &dump); in dsa_user_fdb_dump()
580 struct dsa_switch *ds = p->dp->ds; in dsa_user_ioctl()
581 int port = p->dp->index; in dsa_user_ioctl()
586 if (ds->ops->port_hwtstamp_get) in dsa_user_ioctl()
587 return ds->ops->port_hwtstamp_get(ds, port, ifr); in dsa_user_ioctl()
590 if (ds->ops->port_hwtstamp_set) in dsa_user_ioctl()
591 return ds->ops->port_hwtstamp_set(ds, port, ifr); in dsa_user_ioctl()
595 return phylink_mii_ioctl(p->dp->pl, ifr, cmd); in dsa_user_ioctl()
602 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_port_attr_set() local
605 if (ctx && ctx != dp) in dsa_user_port_attr_set()
608 switch (attr->id) { in dsa_user_port_attr_set()
610 if (!dsa_port_offloads_bridge_port(dp, attr->orig_dev)) in dsa_user_port_attr_set()
611 return -EOPNOTSUPP; in dsa_user_port_attr_set()
613 ret = dsa_port_set_state(dp, attr->u.stp_state, true); in dsa_user_port_attr_set()
616 if (!dsa_port_offloads_bridge_port(dp, attr->orig_dev)) in dsa_user_port_attr_set()
617 return -EOPNOTSUPP; in dsa_user_port_attr_set()
619 ret = dsa_port_set_mst_state(dp, &attr->u.mst_state, extack); in dsa_user_port_attr_set()
622 if (!dsa_port_offloads_bridge_dev(dp, attr->orig_dev)) in dsa_user_port_attr_set()
623 return -EOPNOTSUPP; in dsa_user_port_attr_set()
625 ret = dsa_port_vlan_filtering(dp, attr->u.vlan_filtering, in dsa_user_port_attr_set()
629 if (!dsa_port_offloads_bridge_dev(dp, attr->orig_dev)) in dsa_user_port_attr_set()
630 return -EOPNOTSUPP; in dsa_user_port_attr_set()
632 ret = dsa_port_ageing_time(dp, attr->u.ageing_time); in dsa_user_port_attr_set()
635 if (!dsa_port_offloads_bridge_dev(dp, attr->orig_dev)) in dsa_user_port_attr_set()
636 return -EOPNOTSUPP; in dsa_user_port_attr_set()
638 ret = dsa_port_mst_enable(dp, attr->u.mst, extack); in dsa_user_port_attr_set()
641 if (!dsa_port_offloads_bridge_port(dp, attr->orig_dev)) in dsa_user_port_attr_set()
642 return -EOPNOTSUPP; in dsa_user_port_attr_set()
644 ret = dsa_port_pre_bridge_flags(dp, attr->u.brport_flags, in dsa_user_port_attr_set()
648 if (!dsa_port_offloads_bridge_port(dp, attr->orig_dev)) in dsa_user_port_attr_set()
649 return -EOPNOTSUPP; in dsa_user_port_attr_set()
651 ret = dsa_port_bridge_flags(dp, attr->u.brport_flags, extack); in dsa_user_port_attr_set()
654 if (!dsa_port_offloads_bridge_dev(dp, attr->orig_dev)) in dsa_user_port_attr_set()
655 return -EOPNOTSUPP; in dsa_user_port_attr_set()
657 ret = dsa_port_vlan_msti(dp, &attr->u.vlan_msti); in dsa_user_port_attr_set()
660 ret = -EOPNOTSUPP; in dsa_user_port_attr_set()
682 if (vid == vlan->vid) in dsa_user_vlan_check_for_8021q_uppers()
683 return -EBUSY; in dsa_user_vlan_check_for_8021q_uppers()
693 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_vlan_add() local
697 if (dsa_port_skip_vlan_configuration(dp)) { in dsa_user_vlan_add()
704 /* Deny adding a bridge VLAN when there is already an 802.1Q upper with in dsa_user_vlan_add()
707 if (br_vlan_enabled(dsa_port_bridge_dev_get(dp))) { in dsa_user_vlan_add()
718 return dsa_port_vlan_add(dp, vlan, extack); in dsa_user_vlan_add()
721 /* Offload a VLAN installed on the bridge or on a foreign interface by
728 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_host_vlan_add() local
731 /* Do nothing if this is a software bridge */ in dsa_user_host_vlan_add()
732 if (!dp->bridge) in dsa_user_host_vlan_add()
733 return -EOPNOTSUPP; in dsa_user_host_vlan_add()
735 if (dsa_port_skip_vlan_configuration(dp)) { in dsa_user_host_vlan_add()
747 return dsa_port_host_vlan_add(dp, &vlan, extack); in dsa_user_host_vlan_add()
754 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_port_obj_add() local
757 if (ctx && ctx != dp) in dsa_user_port_obj_add()
760 switch (obj->id) { in dsa_user_port_obj_add()
762 if (!dsa_port_offloads_bridge_port(dp, obj->orig_dev)) in dsa_user_port_obj_add()
763 return -EOPNOTSUPP; in dsa_user_port_obj_add()
765 err = dsa_port_mdb_add(dp, SWITCHDEV_OBJ_PORT_MDB(obj)); in dsa_user_port_obj_add()
768 if (!dsa_port_offloads_bridge_dev(dp, obj->orig_dev)) in dsa_user_port_obj_add()
769 return -EOPNOTSUPP; in dsa_user_port_obj_add()
771 err = dsa_port_bridge_host_mdb_add(dp, SWITCHDEV_OBJ_PORT_MDB(obj)); in dsa_user_port_obj_add()
774 if (dsa_port_offloads_bridge_port(dp, obj->orig_dev)) in dsa_user_port_obj_add()
780 if (!dsa_port_offloads_bridge_dev(dp, obj->orig_dev)) in dsa_user_port_obj_add()
781 return -EOPNOTSUPP; in dsa_user_port_obj_add()
783 err = dsa_port_mrp_add(dp, SWITCHDEV_OBJ_MRP(obj)); in dsa_user_port_obj_add()
786 if (!dsa_port_offloads_bridge_dev(dp, obj->orig_dev)) in dsa_user_port_obj_add()
787 return -EOPNOTSUPP; in dsa_user_port_obj_add()
789 err = dsa_port_mrp_add_ring_role(dp, in dsa_user_port_obj_add()
793 err = -EOPNOTSUPP; in dsa_user_port_obj_add()
803 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_vlan_del() local
806 if (dsa_port_skip_vlan_configuration(dp)) in dsa_user_vlan_del()
811 return dsa_port_vlan_del(dp, vlan); in dsa_user_vlan_del()
817 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_host_vlan_del() local
820 /* Do nothing if this is a software bridge */ in dsa_user_host_vlan_del()
821 if (!dp->bridge) in dsa_user_host_vlan_del()
822 return -EOPNOTSUPP; in dsa_user_host_vlan_del()
824 if (dsa_port_skip_vlan_configuration(dp)) in dsa_user_host_vlan_del()
829 return dsa_port_host_vlan_del(dp, vlan); in dsa_user_host_vlan_del()
835 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_port_obj_del() local
838 if (ctx && ctx != dp) in dsa_user_port_obj_del()
841 switch (obj->id) { in dsa_user_port_obj_del()
843 if (!dsa_port_offloads_bridge_port(dp, obj->orig_dev)) in dsa_user_port_obj_del()
844 return -EOPNOTSUPP; in dsa_user_port_obj_del()
846 err = dsa_port_mdb_del(dp, SWITCHDEV_OBJ_PORT_MDB(obj)); in dsa_user_port_obj_del()
849 if (!dsa_port_offloads_bridge_dev(dp, obj->orig_dev)) in dsa_user_port_obj_del()
850 return -EOPNOTSUPP; in dsa_user_port_obj_del()
852 err = dsa_port_bridge_host_mdb_del(dp, SWITCHDEV_OBJ_PORT_MDB(obj)); in dsa_user_port_obj_del()
855 if (dsa_port_offloads_bridge_port(dp, obj->orig_dev)) in dsa_user_port_obj_del()
861 if (!dsa_port_offloads_bridge_dev(dp, obj->orig_dev)) in dsa_user_port_obj_del()
862 return -EOPNOTSUPP; in dsa_user_port_obj_del()
864 err = dsa_port_mrp_del(dp, SWITCHDEV_OBJ_MRP(obj)); in dsa_user_port_obj_del()
867 if (!dsa_port_offloads_bridge_dev(dp, obj->orig_dev)) in dsa_user_port_obj_del()
868 return -EOPNOTSUPP; in dsa_user_port_obj_del()
870 err = dsa_port_mrp_del_ring_role(dp, in dsa_user_port_obj_del()
874 err = -EOPNOTSUPP; in dsa_user_port_obj_del()
887 return netpoll_send_skb(p->netpoll, skb); in dsa_user_netpoll_send_skb()
897 struct dsa_switch *ds = p->dp->ds; in dsa_skb_tx_timestamp()
899 if (!(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) in dsa_skb_tx_timestamp()
902 if (!ds->ops->port_txtstamp) in dsa_skb_tx_timestamp()
905 ds->ops->port_txtstamp(ds, p->dp->index, skb); in dsa_skb_tx_timestamp()
910 /* SKB for netpoll still need to be mangled with the protocol-specific in dsa_enqueue_skb()
919 skb->dev = dsa_user_to_conduit(dev); in dsa_enqueue_skb()
931 dev_sw_netstats_tx_add(dev, 1, skb->len); in dsa_user_xmit()
933 memset(skb->cb, 0, sizeof(skb->cb)); in dsa_user_xmit()
947 if (dev->needed_tailroom) in dsa_user_xmit()
953 nskb = p->xmit(skb, dev); in dsa_user_xmit()
967 strscpy(drvinfo->driver, "dsa", sizeof(drvinfo->driver)); in dsa_user_get_drvinfo()
968 strscpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); in dsa_user_get_drvinfo()
969 strscpy(drvinfo->bus_info, "platform", sizeof(drvinfo->bus_info)); in dsa_user_get_drvinfo()
974 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_get_regs_len() local
975 struct dsa_switch *ds = dp->ds; in dsa_user_get_regs_len()
977 if (ds->ops->get_regs_len) in dsa_user_get_regs_len()
978 return ds->ops->get_regs_len(ds, dp->index); in dsa_user_get_regs_len()
980 return -EOPNOTSUPP; in dsa_user_get_regs_len()
986 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_get_regs() local
987 struct dsa_switch *ds = dp->ds; in dsa_user_get_regs()
989 if (ds->ops->get_regs) in dsa_user_get_regs()
990 ds->ops->get_regs(ds, dp->index, regs, _p); in dsa_user_get_regs()
995 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_nway_reset() local
997 return phylink_ethtool_nway_reset(dp->pl); in dsa_user_nway_reset()
1002 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_get_eeprom_len() local
1003 struct dsa_switch *ds = dp->ds; in dsa_user_get_eeprom_len()
1005 if (ds->cd && ds->cd->eeprom_len) in dsa_user_get_eeprom_len()
1006 return ds->cd->eeprom_len; in dsa_user_get_eeprom_len()
1008 if (ds->ops->get_eeprom_len) in dsa_user_get_eeprom_len()
1009 return ds->ops->get_eeprom_len(ds); in dsa_user_get_eeprom_len()
1017 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_get_eeprom() local
1018 struct dsa_switch *ds = dp->ds; in dsa_user_get_eeprom()
1020 if (ds->ops->get_eeprom) in dsa_user_get_eeprom()
1021 return ds->ops->get_eeprom(ds, eeprom, data); in dsa_user_get_eeprom()
1023 return -EOPNOTSUPP; in dsa_user_get_eeprom()
1029 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_set_eeprom() local
1030 struct dsa_switch *ds = dp->ds; in dsa_user_set_eeprom()
1032 if (ds->ops->set_eeprom) in dsa_user_set_eeprom()
1033 return ds->ops->set_eeprom(ds, eeprom, data); in dsa_user_set_eeprom()
1035 return -EOPNOTSUPP; in dsa_user_set_eeprom()
1041 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_get_strings() local
1042 struct dsa_switch *ds = dp->ds; in dsa_user_get_strings()
1051 if (ds->ops->get_strings) in dsa_user_get_strings()
1052 ds->ops->get_strings(ds, dp->index, stringset, in dsa_user_get_strings()
1064 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_get_ethtool_stats() local
1065 struct dsa_switch *ds = dp->ds; in dsa_user_get_ethtool_stats()
1073 s = per_cpu_ptr(dev->tstats, i); in dsa_user_get_ethtool_stats()
1075 start = u64_stats_fetch_begin(&s->syncp); in dsa_user_get_ethtool_stats()
1076 tx_packets = u64_stats_read(&s->tx_packets); in dsa_user_get_ethtool_stats()
1077 tx_bytes = u64_stats_read(&s->tx_bytes); in dsa_user_get_ethtool_stats()
1078 rx_packets = u64_stats_read(&s->rx_packets); in dsa_user_get_ethtool_stats()
1079 rx_bytes = u64_stats_read(&s->rx_bytes); in dsa_user_get_ethtool_stats()
1080 } while (u64_stats_fetch_retry(&s->syncp, start)); in dsa_user_get_ethtool_stats()
1086 if (ds->ops->get_ethtool_stats) in dsa_user_get_ethtool_stats()
1087 ds->ops->get_ethtool_stats(ds, dp->index, data + 4); in dsa_user_get_ethtool_stats()
1092 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_get_sset_count() local
1093 struct dsa_switch *ds = dp->ds; in dsa_user_get_sset_count()
1098 if (ds->ops->get_sset_count) { in dsa_user_get_sset_count()
1099 count = ds->ops->get_sset_count(ds, dp->index, sset); in dsa_user_get_sset_count()
1109 return -EOPNOTSUPP; in dsa_user_get_sset_count()
1115 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_get_eth_phy_stats() local
1116 struct dsa_switch *ds = dp->ds; in dsa_user_get_eth_phy_stats()
1118 if (ds->ops->get_eth_phy_stats) in dsa_user_get_eth_phy_stats()
1119 ds->ops->get_eth_phy_stats(ds, dp->index, phy_stats); in dsa_user_get_eth_phy_stats()
1125 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_get_eth_mac_stats() local
1126 struct dsa_switch *ds = dp->ds; in dsa_user_get_eth_mac_stats()
1128 if (ds->ops->get_eth_mac_stats) in dsa_user_get_eth_mac_stats()
1129 ds->ops->get_eth_mac_stats(ds, dp->index, mac_stats); in dsa_user_get_eth_mac_stats()
1136 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_get_eth_ctrl_stats() local
1137 struct dsa_switch *ds = dp->ds; in dsa_user_get_eth_ctrl_stats()
1139 if (ds->ops->get_eth_ctrl_stats) in dsa_user_get_eth_ctrl_stats()
1140 ds->ops->get_eth_ctrl_stats(ds, dp->index, ctrl_stats); in dsa_user_get_eth_ctrl_stats()
1148 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_get_rmon_stats() local
1149 struct dsa_switch *ds = dp->ds; in dsa_user_get_rmon_stats()
1151 if (ds->ops->get_rmon_stats) in dsa_user_get_rmon_stats()
1152 ds->ops->get_rmon_stats(ds, dp->index, rmon_stats, ranges); in dsa_user_get_rmon_stats()
1158 struct dsa_port *dp = dsa_user_to_port(ndev); in dsa_user_net_selftest() local
1159 struct dsa_switch *ds = dp->ds; in dsa_user_net_selftest()
1161 if (ds->ops->self_test) { in dsa_user_net_selftest()
1162 ds->ops->self_test(ds, dp->index, etest, buf); in dsa_user_net_selftest()
1172 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_get_mm() local
1173 struct dsa_switch *ds = dp->ds; in dsa_user_get_mm()
1175 if (!ds->ops->get_mm) in dsa_user_get_mm()
1176 return -EOPNOTSUPP; in dsa_user_get_mm()
1178 return ds->ops->get_mm(ds, dp->index, state); in dsa_user_get_mm()
1184 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_set_mm() local
1185 struct dsa_switch *ds = dp->ds; in dsa_user_set_mm()
1187 if (!ds->ops->set_mm) in dsa_user_set_mm()
1188 return -EOPNOTSUPP; in dsa_user_set_mm()
1190 return ds->ops->set_mm(ds, dp->index, cfg, extack); in dsa_user_set_mm()
1196 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_get_mm_stats() local
1197 struct dsa_switch *ds = dp->ds; in dsa_user_get_mm_stats()
1199 if (ds->ops->get_mm_stats) in dsa_user_get_mm_stats()
1200 ds->ops->get_mm_stats(ds, dp->index, stats); in dsa_user_get_mm_stats()
1205 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_get_wol() local
1206 struct dsa_switch *ds = dp->ds; in dsa_user_get_wol()
1208 phylink_ethtool_get_wol(dp->pl, w); in dsa_user_get_wol()
1210 if (ds->ops->get_wol) in dsa_user_get_wol()
1211 ds->ops->get_wol(ds, dp->index, w); in dsa_user_get_wol()
1216 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_set_wol() local
1217 struct dsa_switch *ds = dp->ds; in dsa_user_set_wol()
1218 int ret = -EOPNOTSUPP; in dsa_user_set_wol()
1220 phylink_ethtool_set_wol(dp->pl, w); in dsa_user_set_wol()
1222 if (ds->ops->set_wol) in dsa_user_set_wol()
1223 ret = ds->ops->set_wol(ds, dp->index, w); in dsa_user_set_wol()
1230 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_set_eee() local
1231 struct dsa_switch *ds = dp->ds; in dsa_user_set_eee()
1235 if (!dev->phydev || !dp->pl) in dsa_user_set_eee()
1236 return -ENODEV; in dsa_user_set_eee()
1238 if (!ds->ops->set_mac_eee) in dsa_user_set_eee()
1239 return -EOPNOTSUPP; in dsa_user_set_eee()
1241 ret = ds->ops->set_mac_eee(ds, dp->index, e); in dsa_user_set_eee()
1245 return phylink_ethtool_set_eee(dp->pl, e); in dsa_user_set_eee()
1250 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_get_eee() local
1251 struct dsa_switch *ds = dp->ds; in dsa_user_get_eee()
1255 if (!dev->phydev || !dp->pl) in dsa_user_get_eee()
1256 return -ENODEV; in dsa_user_get_eee()
1258 if (!ds->ops->get_mac_eee) in dsa_user_get_eee()
1259 return -EOPNOTSUPP; in dsa_user_get_eee()
1261 ret = ds->ops->get_mac_eee(ds, dp->index, e); in dsa_user_get_eee()
1265 return phylink_ethtool_get_eee(dp->pl, e); in dsa_user_get_eee()
1271 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_get_link_ksettings() local
1273 return phylink_ethtool_ksettings_get(dp->pl, cmd); in dsa_user_get_link_ksettings()
1279 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_set_link_ksettings() local
1281 return phylink_ethtool_ksettings_set(dp->pl, cmd); in dsa_user_set_link_ksettings()
1287 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_get_pause_stats() local
1288 struct dsa_switch *ds = dp->ds; in dsa_user_get_pause_stats()
1290 if (ds->ops->get_pause_stats) in dsa_user_get_pause_stats()
1291 ds->ops->get_pause_stats(ds, dp->index, pause_stats); in dsa_user_get_pause_stats()
1297 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_get_pauseparam() local
1299 phylink_ethtool_get_pauseparam(dp->pl, pause); in dsa_user_get_pauseparam()
1305 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_set_pauseparam() local
1307 return phylink_ethtool_set_pauseparam(dp->pl, pause); in dsa_user_set_pauseparam()
1321 return -ENOMEM; in dsa_user_netpoll_setup()
1329 p->netpoll = netpoll; in dsa_user_netpoll_setup()
1337 struct netpoll *netpoll = p->netpoll; in dsa_user_netpoll_cleanup()
1342 p->netpoll = NULL; in dsa_user_netpoll_cleanup()
1358 list_for_each_entry(mall_tc_entry, &p->mall_tc_list, list) in dsa_user_mall_tc_entry_find()
1359 if (mall_tc_entry->cookie == cookie) in dsa_user_mall_tc_entry_find()
1370 struct netlink_ext_ack *extack = cls->common.extack; in dsa_user_add_cls_matchall_mirred()
1371 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_add_cls_matchall_mirred() local
1375 struct dsa_switch *ds = dp->ds; in dsa_user_add_cls_matchall_mirred()
1380 if (!ds->ops->port_mirror_add) in dsa_user_add_cls_matchall_mirred()
1381 return -EOPNOTSUPP; in dsa_user_add_cls_matchall_mirred()
1383 if (!flow_action_basic_hw_stats_check(&cls->rule->action, in dsa_user_add_cls_matchall_mirred()
1384 cls->common.extack)) in dsa_user_add_cls_matchall_mirred()
1385 return -EOPNOTSUPP; in dsa_user_add_cls_matchall_mirred()
1387 act = &cls->rule->action.entries[0]; in dsa_user_add_cls_matchall_mirred()
1389 if (!act->dev) in dsa_user_add_cls_matchall_mirred()
1390 return -EINVAL; in dsa_user_add_cls_matchall_mirred()
1392 if (!dsa_user_dev_check(act->dev)) in dsa_user_add_cls_matchall_mirred()
1393 return -EOPNOTSUPP; in dsa_user_add_cls_matchall_mirred()
1395 to_dp = dsa_user_to_port(act->dev); in dsa_user_add_cls_matchall_mirred()
1397 if (dp->ds != to_dp->ds) { in dsa_user_add_cls_matchall_mirred()
1399 "Cross-chip mirroring not implemented"); in dsa_user_add_cls_matchall_mirred()
1400 return -EOPNOTSUPP; in dsa_user_add_cls_matchall_mirred()
1405 return -ENOMEM; in dsa_user_add_cls_matchall_mirred()
1407 mall_tc_entry->cookie = cls->cookie; in dsa_user_add_cls_matchall_mirred()
1408 mall_tc_entry->type = DSA_PORT_MALL_MIRROR; in dsa_user_add_cls_matchall_mirred()
1409 mirror = &mall_tc_entry->mirror; in dsa_user_add_cls_matchall_mirred()
1410 mirror->to_local_port = to_dp->index; in dsa_user_add_cls_matchall_mirred()
1411 mirror->ingress = ingress; in dsa_user_add_cls_matchall_mirred()
1413 err = ds->ops->port_mirror_add(ds, dp->index, mirror, ingress, extack); in dsa_user_add_cls_matchall_mirred()
1419 list_add_tail(&mall_tc_entry->list, &p->mall_tc_list); in dsa_user_add_cls_matchall_mirred()
1429 struct netlink_ext_ack *extack = cls->common.extack; in dsa_user_add_cls_matchall_police()
1430 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_add_cls_matchall_police() local
1434 struct dsa_switch *ds = dp->ds; in dsa_user_add_cls_matchall_police()
1438 if (!ds->ops->port_policer_add) { in dsa_user_add_cls_matchall_police()
1441 return -EOPNOTSUPP; in dsa_user_add_cls_matchall_police()
1447 return -EOPNOTSUPP; in dsa_user_add_cls_matchall_police()
1450 if (!flow_action_basic_hw_stats_check(&cls->rule->action, in dsa_user_add_cls_matchall_police()
1451 cls->common.extack)) in dsa_user_add_cls_matchall_police()
1452 return -EOPNOTSUPP; in dsa_user_add_cls_matchall_police()
1454 list_for_each_entry(mall_tc_entry, &p->mall_tc_list, list) { in dsa_user_add_cls_matchall_police()
1455 if (mall_tc_entry->type == DSA_PORT_MALL_POLICER) { in dsa_user_add_cls_matchall_police()
1458 return -EEXIST; in dsa_user_add_cls_matchall_police()
1462 act = &cls->rule->action.entries[0]; in dsa_user_add_cls_matchall_police()
1466 return -ENOMEM; in dsa_user_add_cls_matchall_police()
1468 mall_tc_entry->cookie = cls->cookie; in dsa_user_add_cls_matchall_police()
1469 mall_tc_entry->type = DSA_PORT_MALL_POLICER; in dsa_user_add_cls_matchall_police()
1470 policer = &mall_tc_entry->policer; in dsa_user_add_cls_matchall_police()
1471 policer->rate_bytes_per_sec = act->police.rate_bytes_ps; in dsa_user_add_cls_matchall_police()
1472 policer->burst = act->police.burst; in dsa_user_add_cls_matchall_police()
1474 err = ds->ops->port_policer_add(ds, dp->index, policer); in dsa_user_add_cls_matchall_police()
1480 list_add_tail(&mall_tc_entry->list, &p->mall_tc_list); in dsa_user_add_cls_matchall_police()
1489 int err = -EOPNOTSUPP; in dsa_user_add_cls_matchall()
1491 if (cls->common.protocol == htons(ETH_P_ALL) && in dsa_user_add_cls_matchall()
1492 flow_offload_has_one_action(&cls->rule->action) && in dsa_user_add_cls_matchall()
1493 cls->rule->action.entries[0].id == FLOW_ACTION_MIRRED) in dsa_user_add_cls_matchall()
1495 else if (flow_offload_has_one_action(&cls->rule->action) && in dsa_user_add_cls_matchall()
1496 cls->rule->action.entries[0].id == FLOW_ACTION_POLICE) in dsa_user_add_cls_matchall()
1505 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_del_cls_matchall() local
1507 struct dsa_switch *ds = dp->ds; in dsa_user_del_cls_matchall()
1509 mall_tc_entry = dsa_user_mall_tc_entry_find(dev, cls->cookie); in dsa_user_del_cls_matchall()
1513 list_del(&mall_tc_entry->list); in dsa_user_del_cls_matchall()
1515 switch (mall_tc_entry->type) { in dsa_user_del_cls_matchall()
1517 if (ds->ops->port_mirror_del) in dsa_user_del_cls_matchall()
1518 ds->ops->port_mirror_del(ds, dp->index, in dsa_user_del_cls_matchall()
1519 &mall_tc_entry->mirror); in dsa_user_del_cls_matchall()
1522 if (ds->ops->port_policer_del) in dsa_user_del_cls_matchall()
1523 ds->ops->port_policer_del(ds, dp->index); in dsa_user_del_cls_matchall()
1536 if (cls->common.chain_index) in dsa_user_setup_tc_cls_matchall()
1537 return -EOPNOTSUPP; in dsa_user_setup_tc_cls_matchall()
1539 switch (cls->command) { in dsa_user_setup_tc_cls_matchall()
1546 return -EOPNOTSUPP; in dsa_user_setup_tc_cls_matchall()
1554 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_add_cls_flower() local
1555 struct dsa_switch *ds = dp->ds; in dsa_user_add_cls_flower()
1556 int port = dp->index; in dsa_user_add_cls_flower()
1558 if (!ds->ops->cls_flower_add) in dsa_user_add_cls_flower()
1559 return -EOPNOTSUPP; in dsa_user_add_cls_flower()
1561 return ds->ops->cls_flower_add(ds, port, cls, ingress); in dsa_user_add_cls_flower()
1568 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_del_cls_flower() local
1569 struct dsa_switch *ds = dp->ds; in dsa_user_del_cls_flower()
1570 int port = dp->index; in dsa_user_del_cls_flower()
1572 if (!ds->ops->cls_flower_del) in dsa_user_del_cls_flower()
1573 return -EOPNOTSUPP; in dsa_user_del_cls_flower()
1575 return ds->ops->cls_flower_del(ds, port, cls, ingress); in dsa_user_del_cls_flower()
1582 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_stats_cls_flower() local
1583 struct dsa_switch *ds = dp->ds; in dsa_user_stats_cls_flower()
1584 int port = dp->index; in dsa_user_stats_cls_flower()
1586 if (!ds->ops->cls_flower_stats) in dsa_user_stats_cls_flower()
1587 return -EOPNOTSUPP; in dsa_user_stats_cls_flower()
1589 return ds->ops->cls_flower_stats(ds, port, cls, ingress); in dsa_user_stats_cls_flower()
1596 switch (cls->command) { in dsa_user_setup_tc_cls_flower()
1604 return -EOPNOTSUPP; in dsa_user_setup_tc_cls_flower()
1614 return -EOPNOTSUPP; in dsa_user_setup_tc_block_cb()
1622 return -EOPNOTSUPP; in dsa_user_setup_tc_block_cb()
1646 if (f->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS) in dsa_user_setup_tc_block()
1648 else if (f->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_EGRESS) in dsa_user_setup_tc_block()
1651 return -EOPNOTSUPP; in dsa_user_setup_tc_block()
1653 f->driver_block_list = &dsa_user_block_cb_list; in dsa_user_setup_tc_block()
1655 switch (f->command) { in dsa_user_setup_tc_block()
1658 return -EBUSY; in dsa_user_setup_tc_block()
1665 list_add_tail(&block_cb->driver_list, &dsa_user_block_cb_list); in dsa_user_setup_tc_block()
1668 block_cb = flow_block_cb_lookup(f->block, cb, dev); in dsa_user_setup_tc_block()
1670 return -ENOENT; in dsa_user_setup_tc_block()
1673 list_del(&block_cb->driver_list); in dsa_user_setup_tc_block()
1676 return -EOPNOTSUPP; in dsa_user_setup_tc_block()
1685 if (!conduit->netdev_ops->ndo_setup_tc) in dsa_user_setup_ft_block()
1686 return -EOPNOTSUPP; in dsa_user_setup_ft_block()
1688 return conduit->netdev_ops->ndo_setup_tc(conduit, TC_SETUP_FT, type_data); in dsa_user_setup_ft_block()
1694 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_setup_tc() local
1695 struct dsa_switch *ds = dp->ds; in dsa_user_setup_tc()
1701 return dsa_user_setup_ft_block(ds, dp->index, type_data); in dsa_user_setup_tc()
1706 if (!ds->ops->port_setup_tc) in dsa_user_setup_tc()
1707 return -EOPNOTSUPP; in dsa_user_setup_tc()
1709 return ds->ops->port_setup_tc(ds, dp->index, type, type_data); in dsa_user_setup_tc()
1715 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_get_rxnfc() local
1716 struct dsa_switch *ds = dp->ds; in dsa_user_get_rxnfc()
1718 if (!ds->ops->get_rxnfc) in dsa_user_get_rxnfc()
1719 return -EOPNOTSUPP; in dsa_user_get_rxnfc()
1721 return ds->ops->get_rxnfc(ds, dp->index, nfc, rule_locs); in dsa_user_get_rxnfc()
1727 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_set_rxnfc() local
1728 struct dsa_switch *ds = dp->ds; in dsa_user_set_rxnfc()
1730 if (!ds->ops->set_rxnfc) in dsa_user_set_rxnfc()
1731 return -EOPNOTSUPP; in dsa_user_set_rxnfc()
1733 return ds->ops->set_rxnfc(ds, dp->index, nfc); in dsa_user_set_rxnfc()
1740 struct dsa_switch *ds = p->dp->ds; in dsa_user_get_ts_info()
1742 if (!ds->ops->get_ts_info) in dsa_user_get_ts_info()
1743 return -EOPNOTSUPP; in dsa_user_get_ts_info()
1745 return ds->ops->get_ts_info(ds, p->dp->index, ts); in dsa_user_get_ts_info()
1751 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_vlan_rx_add_vid() local
1755 /* This API only allows programming tagged, non-PVID VIDs */ in dsa_user_vlan_rx_add_vid()
1759 struct dsa_switch *ds = dp->ds; in dsa_user_vlan_rx_add_vid()
1765 ret = dsa_port_vlan_add(dp, &vlan, &extack); in dsa_user_vlan_rx_add_vid()
1773 ret = dsa_port_host_vlan_add(dp, &vlan, &extack); in dsa_user_vlan_rx_add_vid()
1776 netdev_err(dev, "CPU port %d: %s\n", dp->cpu_dp->index, in dsa_user_vlan_rx_add_vid()
1787 ret = -ENOMEM; in dsa_user_vlan_rx_add_vid()
1793 v->vid = vid; in dsa_user_vlan_rx_add_vid()
1794 list_add_tail(&v->list, &dp->user_vlans); in dsa_user_vlan_rx_add_vid()
1799 ha->addr, vid); in dsa_user_vlan_rx_add_vid()
1806 ha->addr, vid); in dsa_user_vlan_rx_add_vid()
1817 dsa_port_host_vlan_del(dp, &vlan); in dsa_user_vlan_rx_add_vid()
1818 dsa_port_vlan_del(dp, &vlan); in dsa_user_vlan_rx_add_vid()
1826 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_vlan_rx_kill_vid() local
1829 /* This API only allows programming tagged, non-PVID VIDs */ in dsa_user_vlan_rx_kill_vid()
1832 struct dsa_switch *ds = dp->ds; in dsa_user_vlan_rx_kill_vid()
1837 err = dsa_port_vlan_del(dp, &vlan); in dsa_user_vlan_rx_kill_vid()
1841 err = dsa_port_host_vlan_del(dp, &vlan); in dsa_user_vlan_rx_kill_vid()
1851 v = dsa_vlan_find(&dp->user_vlans, &vlan); in dsa_user_vlan_rx_kill_vid()
1854 return -ENOENT; in dsa_user_vlan_rx_kill_vid()
1857 list_del(&v->list); in dsa_user_vlan_rx_kill_vid()
1863 ha->addr, vid); in dsa_user_vlan_rx_kill_vid()
1870 ha->addr, vid); in dsa_user_vlan_rx_kill_vid()
1897 * VLAN-aware bridge are VLAN-aware, and standalone ports are VLAN-unaware,
1900 * If ds->vlan_filtering_is_global = true, then standalone ports which share
1901 * the same switch with other ports that offload a VLAN-aware bridge are also
1902 * inevitably VLAN-aware.
1906 * - If standalone (this includes software bridge, software LAG):
1907 * - if ds->needs_standalone_vlan_filtering = true, OR if
1908 * (ds->vlan_filtering_is_global = true AND there are bridges spanning
1910 * - the 8021q upper VLANs
1911 * - else (standalone VLAN filtering is not needed, VLAN filtering is not
1912 * global, or it is, but no port is under a VLAN-aware bridge):
1913 * - no VLAN (any 8021q upper is a software VLAN)
1915 * - If under a vlan_filtering=0 bridge which it offload:
1916 * - if ds->configure_vlan_while_not_filtering = true (default):
1917 * - the bridge VLANs. These VLANs are committed to hardware but inactive.
1918 * - else (deprecated):
1919 * - no VLAN. The bridge VLANs are not restored when VLAN awareness is
1922 * - If under a vlan_filtering=1 bridge which it offload:
1923 * - the bridge VLANs
1924 * - the 8021q upper VLANs
1932 user->features |= NETIF_F_HW_VLAN_CTAG_FILTER; in dsa_user_manage_vlan_filtering()
1937 user->features &= ~NETIF_F_HW_VLAN_CTAG_FILTER; in dsa_user_manage_vlan_filtering()
1945 user->features &= ~NETIF_F_HW_VLAN_CTAG_FILTER; in dsa_user_manage_vlan_filtering()
1963 if (p->dev->mtu == mtu) in dsa_hw_port_list_set_mtu()
1966 err = dev_set_mtu(p->dev, mtu); in dsa_hw_port_list_set_mtu()
1975 if (p->dev->mtu == p->old_mtu) in dsa_hw_port_list_set_mtu()
1978 if (dev_set_mtu(p->dev, p->old_mtu)) in dsa_hw_port_list_set_mtu()
1979 netdev_err(p->dev, "Failed to restore MTU\n"); in dsa_hw_port_list_set_mtu()
1994 static void dsa_bridge_mtu_normalization(struct dsa_port *dp) in dsa_bridge_mtu_normalization() argument
2002 if (!dp->ds->mtu_enforcement_ingress) in dsa_bridge_mtu_normalization()
2005 if (!dp->bridge) in dsa_bridge_mtu_normalization()
2010 /* Populate the list of ports that are part of the same bridge in dsa_bridge_mtu_normalization()
2014 list_for_each_entry(other_dp, &dst->ports, list) { in dsa_bridge_mtu_normalization()
2018 if (other_dp->type != DSA_PORT_TYPE_USER) in dsa_bridge_mtu_normalization()
2021 if (!dsa_port_bridge_same(dp, other_dp)) in dsa_bridge_mtu_normalization()
2024 if (!other_dp->ds->mtu_enforcement_ingress) in dsa_bridge_mtu_normalization()
2027 user = other_dp->user; in dsa_bridge_mtu_normalization()
2029 if (min_mtu > user->mtu) in dsa_bridge_mtu_normalization()
2030 min_mtu = user->mtu; in dsa_bridge_mtu_normalization()
2036 hw_port->dev = user; in dsa_bridge_mtu_normalization()
2037 hw_port->old_mtu = user->mtu; in dsa_bridge_mtu_normalization()
2039 list_add(&hw_port->list, &hw_port_list); in dsa_bridge_mtu_normalization()
2043 /* Attempt to configure the entire hardware bridge to the newly added in dsa_bridge_mtu_normalization()
2047 err = dsa_hw_port_list_set_mtu(&hw_port_list, dp->user->mtu); in dsa_bridge_mtu_normalization()
2052 * all hardware bridge ports now. If this fails too, then all ports will in dsa_bridge_mtu_normalization()
2064 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_change_mtu() local
2065 struct dsa_port *cpu_dp = dp->cpu_dp; in dsa_user_change_mtu()
2066 struct dsa_switch *ds = dp->ds; in dsa_user_change_mtu()
2076 if (!ds->ops->port_change_mtu) in dsa_user_change_mtu()
2077 return -EOPNOTSUPP; in dsa_user_change_mtu()
2079 dsa_tree_for_each_user_port(other_dp, ds->dst) { in dsa_user_change_mtu()
2086 if (!other_dp->user) in dsa_user_change_mtu()
2092 if (dp == other_dp) in dsa_user_change_mtu()
2095 user_mtu = other_dp->user->mtu; in dsa_user_change_mtu()
2101 overhead = dsa_tag_protocol_overhead(cpu_dp->tag_ops); in dsa_user_change_mtu()
2102 mtu_limit = min_t(int, conduit->max_mtu, dev->max_mtu + overhead); in dsa_user_change_mtu()
2103 old_conduit_mtu = conduit->mtu; in dsa_user_change_mtu()
2106 return -ERANGE; in dsa_user_change_mtu()
2127 err = ds->ops->port_change_mtu(ds, dp->index, new_mtu); in dsa_user_change_mtu()
2131 WRITE_ONCE(dev->mtu, new_mtu); in dsa_user_change_mtu()
2133 dsa_bridge_mtu_normalization(dp); in dsa_user_change_mtu()
2139 dsa_port_mtu_change(cpu_dp, old_conduit_mtu - overhead); in dsa_user_change_mtu()
2150 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_dcbnl_set_apptrust() local
2151 struct dsa_switch *ds = dp->ds; in dsa_user_dcbnl_set_apptrust()
2152 int port = dp->index; in dsa_user_dcbnl_set_apptrust()
2154 if (!ds->ops->port_set_apptrust) in dsa_user_dcbnl_set_apptrust()
2155 return -EOPNOTSUPP; in dsa_user_dcbnl_set_apptrust()
2157 return ds->ops->port_set_apptrust(ds, port, sel, nsel); in dsa_user_dcbnl_set_apptrust()
2163 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_dcbnl_get_apptrust() local
2164 struct dsa_switch *ds = dp->ds; in dsa_user_dcbnl_get_apptrust()
2165 int port = dp->index; in dsa_user_dcbnl_get_apptrust()
2167 if (!ds->ops->port_get_apptrust) in dsa_user_dcbnl_get_apptrust()
2168 return -EOPNOTSUPP; in dsa_user_dcbnl_get_apptrust()
2170 return ds->ops->port_get_apptrust(ds, port, sel, nsel); in dsa_user_dcbnl_get_apptrust()
2176 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_dcbnl_set_default_prio() local
2177 struct dsa_switch *ds = dp->ds; in dsa_user_dcbnl_set_default_prio()
2179 int err, port = dp->index; in dsa_user_dcbnl_set_default_prio()
2181 if (!ds->ops->port_set_default_prio) in dsa_user_dcbnl_set_default_prio()
2182 return -EOPNOTSUPP; in dsa_user_dcbnl_set_default_prio()
2191 err = ds->ops->port_set_default_prio(ds, port, new_prio); in dsa_user_dcbnl_set_default_prio()
2207 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_dcbnl_ieee_global_dscp_setdel() local
2208 struct dsa_switch *ds = dp->ds; in dsa_user_dcbnl_ieee_global_dscp_setdel()
2218 struct net_device *user = other_dp->user; in dsa_user_dcbnl_ieee_global_dscp_setdel()
2239 struct net_device *user = other_dp->user; in dsa_user_dcbnl_ieee_global_dscp_setdel()
2255 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_dcbnl_add_dscp_prio() local
2256 struct dsa_switch *ds = dp->ds; in dsa_user_dcbnl_add_dscp_prio()
2258 int err, port = dp->index; in dsa_user_dcbnl_add_dscp_prio()
2259 u8 dscp = app->protocol; in dsa_user_dcbnl_add_dscp_prio()
2261 if (!ds->ops->port_add_dscp_prio) in dsa_user_dcbnl_add_dscp_prio()
2262 return -EOPNOTSUPP; in dsa_user_dcbnl_add_dscp_prio()
2267 return -EINVAL; in dsa_user_dcbnl_add_dscp_prio()
2277 err = ds->ops->port_add_dscp_prio(ds, port, dscp, new_prio); in dsa_user_dcbnl_add_dscp_prio()
2283 if (!ds->dscp_prio_mapping_is_global) in dsa_user_dcbnl_add_dscp_prio()
2288 if (ds->ops->port_del_dscp_prio) in dsa_user_dcbnl_add_dscp_prio()
2289 ds->ops->port_del_dscp_prio(ds, port, dscp, new_prio); in dsa_user_dcbnl_add_dscp_prio()
2300 switch (app->selector) { in dsa_user_dcbnl_ieee_setapp()
2302 switch (app->protocol) { in dsa_user_dcbnl_ieee_setapp()
2306 return -EOPNOTSUPP; in dsa_user_dcbnl_ieee_setapp()
2312 return -EOPNOTSUPP; in dsa_user_dcbnl_ieee_setapp()
2319 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_dcbnl_del_default_prio() local
2320 struct dsa_switch *ds = dp->ds; in dsa_user_dcbnl_del_default_prio()
2322 int err, port = dp->index; in dsa_user_dcbnl_del_default_prio()
2324 if (!ds->ops->port_set_default_prio) in dsa_user_dcbnl_del_default_prio()
2325 return -EOPNOTSUPP; in dsa_user_dcbnl_del_default_prio()
2334 err = ds->ops->port_set_default_prio(ds, port, new_prio); in dsa_user_dcbnl_del_default_prio()
2346 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_dcbnl_del_dscp_prio() local
2347 struct dsa_switch *ds = dp->ds; in dsa_user_dcbnl_del_dscp_prio()
2348 int err, port = dp->index; in dsa_user_dcbnl_del_dscp_prio()
2349 u8 dscp = app->protocol; in dsa_user_dcbnl_del_dscp_prio()
2351 if (!ds->ops->port_del_dscp_prio) in dsa_user_dcbnl_del_dscp_prio()
2352 return -EOPNOTSUPP; in dsa_user_dcbnl_del_dscp_prio()
2358 err = ds->ops->port_del_dscp_prio(ds, port, dscp, app->priority); in dsa_user_dcbnl_del_dscp_prio()
2364 if (!ds->dscp_prio_mapping_is_global) in dsa_user_dcbnl_del_dscp_prio()
2369 if (ds->ops->port_add_dscp_prio) in dsa_user_dcbnl_del_dscp_prio()
2370 ds->ops->port_add_dscp_prio(ds, port, dscp, in dsa_user_dcbnl_del_dscp_prio()
2371 app->priority); in dsa_user_dcbnl_del_dscp_prio()
2382 switch (app->selector) { in dsa_user_dcbnl_ieee_delapp()
2384 switch (app->protocol) { in dsa_user_dcbnl_ieee_delapp()
2388 return -EOPNOTSUPP; in dsa_user_dcbnl_ieee_delapp()
2394 return -EOPNOTSUPP; in dsa_user_dcbnl_ieee_delapp()
2398 /* Pre-populate the DCB application priority table with the priorities
2403 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_dcbnl_init() local
2404 struct dsa_switch *ds = dp->ds; in dsa_user_dcbnl_init()
2405 int port = dp->index; in dsa_user_dcbnl_init()
2408 if (ds->ops->port_get_default_prio) { in dsa_user_dcbnl_init()
2409 int prio = ds->ops->port_get_default_prio(ds, port); in dsa_user_dcbnl_init()
2424 if (ds->ops->port_get_dscp_prio) { in dsa_user_dcbnl_init()
2434 prio = ds->ops->port_get_dscp_prio(ds, port, protocol); in dsa_user_dcbnl_init()
2435 if (prio == -EOPNOTSUPP) in dsa_user_dcbnl_init()
2495 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_get_stats64() local
2496 struct dsa_switch *ds = dp->ds; in dsa_user_get_stats64()
2498 if (ds->ops->get_stats64) in dsa_user_get_stats64()
2499 ds->ops->get_stats64(ds, dp->index, s); in dsa_user_get_stats64()
2507 struct dsa_port *dp = dsa_user_to_port(ctx->dev); in dsa_user_fill_forward_path() local
2508 struct net_device *conduit = dsa_port_to_conduit(dp); in dsa_user_fill_forward_path()
2509 struct dsa_port *cpu_dp = dp->cpu_dp; in dsa_user_fill_forward_path()
2511 path->dev = ctx->dev; in dsa_user_fill_forward_path()
2512 path->type = DEV_PATH_DSA; in dsa_user_fill_forward_path()
2513 path->dsa.proto = cpu_dp->tag_ops->proto; in dsa_user_fill_forward_path()
2514 path->dsa.port = dp->index; in dsa_user_fill_forward_path()
2515 ctx->dev = conduit; in dsa_user_fill_forward_path()
2549 const struct dsa_port *dp = dsa_to_port(ds, port); in dsa_port_phylink_mac_change() local
2551 if (dp->pl) in dsa_port_phylink_mac_change()
2552 phylink_mac_change(dp->pl, up); in dsa_port_phylink_mac_change()
2559 struct dsa_port *dp = dsa_phylink_to_port(config); in dsa_user_phylink_fixed_state() local
2560 struct dsa_switch *ds = dp->ds; in dsa_user_phylink_fixed_state()
2565 ds->ops->phylink_fixed_state(ds, dp->index, state); in dsa_user_phylink_fixed_state()
2572 struct dsa_port *dp = dsa_user_to_port(user_dev); in dsa_user_phy_connect() local
2573 struct dsa_switch *ds = dp->ds; in dsa_user_phy_connect()
2575 user_dev->phydev = mdiobus_get_phy(ds->user_mii_bus, addr); in dsa_user_phy_connect()
2576 if (!user_dev->phydev) { in dsa_user_phy_connect()
2578 return -ENODEV; in dsa_user_phy_connect()
2581 user_dev->phydev->dev_flags |= flags; in dsa_user_phy_connect()
2583 return phylink_connect_phy(dp->pl, user_dev->phydev); in dsa_user_phy_connect()
2588 struct dsa_port *dp = dsa_user_to_port(user_dev); in dsa_user_phy_setup() local
2589 struct device_node *port_dn = dp->dn; in dsa_user_phy_setup()
2590 struct dsa_switch *ds = dp->ds; in dsa_user_phy_setup()
2594 dp->pl_config.dev = &user_dev->dev; in dsa_user_phy_setup()
2595 dp->pl_config.type = PHYLINK_NETDEV; in dsa_user_phy_setup()
2601 if (ds->ops->phylink_fixed_state) { in dsa_user_phy_setup()
2602 dp->pl_config.get_fixed_state = dsa_user_phylink_fixed_state; in dsa_user_phy_setup()
2603 dp->pl_config.poll_fixed_state = true; in dsa_user_phy_setup()
2606 ret = dsa_port_phylink_create(dp); in dsa_user_phy_setup()
2610 if (ds->ops->get_phy_flags) in dsa_user_phy_setup()
2611 phy_flags = ds->ops->get_phy_flags(ds, dp->index); in dsa_user_phy_setup()
2613 ret = phylink_of_phy_connect(dp->pl, port_dn, phy_flags); in dsa_user_phy_setup()
2614 if (ret == -ENODEV && ds->user_mii_bus) { in dsa_user_phy_setup()
2618 ret = dsa_user_phy_connect(user_dev, dp->index, phy_flags); in dsa_user_phy_setup()
2623 dsa_port_phylink_destroy(dp); in dsa_user_phy_setup()
2631 struct dsa_port *dp = dsa_user_to_port(user); in dsa_user_setup_tagger() local
2632 struct net_device *conduit = dsa_port_to_conduit(dp); in dsa_user_setup_tagger()
2634 const struct dsa_port *cpu_dp = dp->cpu_dp; in dsa_user_setup_tagger()
2635 const struct dsa_switch *ds = dp->ds; in dsa_user_setup_tagger()
2637 user->needed_headroom = cpu_dp->tag_ops->needed_headroom; in dsa_user_setup_tagger()
2638 user->needed_tailroom = cpu_dp->tag_ops->needed_tailroom; in dsa_user_setup_tagger()
2643 user->needed_headroom += conduit->needed_headroom; in dsa_user_setup_tagger()
2644 user->needed_tailroom += conduit->needed_tailroom; in dsa_user_setup_tagger()
2646 p->xmit = cpu_dp->tag_ops->xmit; in dsa_user_setup_tagger()
2648 user->features = conduit->vlan_features | NETIF_F_HW_TC; in dsa_user_setup_tagger()
2649 user->hw_features |= NETIF_F_HW_TC; in dsa_user_setup_tagger()
2650 if (user->needed_tailroom) in dsa_user_setup_tagger()
2651 user->features &= ~(NETIF_F_SG | NETIF_F_FRAGLIST); in dsa_user_setup_tagger()
2652 if (ds->needs_standalone_vlan_filtering) in dsa_user_setup_tagger()
2653 user->features |= NETIF_F_HW_VLAN_CTAG_FILTER; in dsa_user_setup_tagger()
2655 user->lltx = true; in dsa_user_setup_tagger()
2660 struct dsa_port *dp = dsa_user_to_port(user_dev); in dsa_user_suspend() local
2668 phylink_stop(dp->pl); in dsa_user_suspend()
2676 struct dsa_port *dp = dsa_user_to_port(user_dev); in dsa_user_resume() local
2684 phylink_start(dp->pl); in dsa_user_resume()
2693 struct dsa_switch *ds = port->ds; in dsa_user_create()
2700 if (!ds->num_tx_queues) in dsa_user_create()
2701 ds->num_tx_queues = 1; in dsa_user_create()
2703 if (port->name) { in dsa_user_create()
2704 name = port->name; in dsa_user_create()
2713 ds->num_tx_queues, 1); in dsa_user_create()
2715 return -ENOMEM; in dsa_user_create()
2717 user_dev->rtnl_link_ops = &dsa_link_ops; in dsa_user_create()
2718 user_dev->ethtool_ops = &dsa_user_ethtool_ops; in dsa_user_create()
2720 user_dev->dcbnl_ops = &dsa_user_dcbnl_ops; in dsa_user_create()
2722 if (!is_zero_ether_addr(port->mac)) in dsa_user_create()
2723 eth_hw_addr_set(user_dev, port->mac); in dsa_user_create()
2726 user_dev->priv_flags |= IFF_NO_QUEUE; in dsa_user_create()
2728 user_dev->priv_flags |= IFF_UNICAST_FLT; in dsa_user_create()
2729 user_dev->netdev_ops = &dsa_user_netdev_ops; in dsa_user_create()
2730 if (ds->ops->port_max_mtu) in dsa_user_create()
2731 user_dev->max_mtu = ds->ops->port_max_mtu(ds, port->index); in dsa_user_create()
2734 SET_NETDEV_DEV(user_dev, port->ds->dev); in dsa_user_create()
2735 SET_NETDEV_DEVLINK_PORT(user_dev, &port->devlink_port); in dsa_user_create()
2736 user_dev->dev.of_node = port->dn; in dsa_user_create()
2737 user_dev->vlan_features = conduit->vlan_features; in dsa_user_create()
2740 user_dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS; in dsa_user_create()
2742 ret = gro_cells_init(&p->gcells, user_dev); in dsa_user_create()
2746 p->dp = port; in dsa_user_create()
2747 INIT_LIST_HEAD(&p->mall_tc_list); in dsa_user_create()
2748 port->user = user_dev; in dsa_user_create()
2757 ret, ds->dst->index, ds->index, port->index); in dsa_user_create()
2764 if (ret && ret != -EOPNOTSUPP) in dsa_user_create()
2765 dev_warn(ds->dev, "nonfatal error %d setting MTU to %d on port %d\n", in dsa_user_create()
2766 ret, ETH_DATA_LEN, port->index); in dsa_user_create()
2771 ret, user_dev->name); in dsa_user_create()
2800 phylink_disconnect_phy(p->dp->pl); in dsa_user_create()
2802 dsa_port_phylink_destroy(p->dp); in dsa_user_create()
2804 gro_cells_destroy(&p->gcells); in dsa_user_create()
2807 port->user = NULL; in dsa_user_create()
2814 struct dsa_port *dp = dsa_user_to_port(user_dev); in dsa_user_destroy() local
2821 phylink_disconnect_phy(dp->pl); in dsa_user_destroy()
2824 dsa_port_phylink_destroy(dp); in dsa_user_destroy()
2825 gro_cells_destroy(&p->gcells); in dsa_user_destroy()
2833 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_change_conduit() local
2834 struct dsa_switch *ds = dp->ds; in dsa_user_change_conduit()
2842 if (!ds->ops->port_change_conduit) { in dsa_user_change_conduit()
2845 return -EOPNOTSUPP; in dsa_user_change_conduit()
2851 return -EOPNOTSUPP; in dsa_user_change_conduit()
2860 return -EOPNOTSUPP; in dsa_user_change_conduit()
2863 /* Since we allow live-changing the DSA conduit, plus we auto-open the in dsa_user_change_conduit()
2867 if (dev->flags & IFF_UP) { in dsa_user_change_conduit()
2879 err = dsa_port_change_conduit(dp, conduit, extack); in dsa_user_change_conduit()
2883 /* Update the MTU of the new CPU port through cross-chip notifiers */ in dsa_user_change_conduit()
2884 err = dsa_user_change_mtu(dev, dev->mtu); in dsa_user_change_conduit()
2885 if (err && err != -EOPNOTSUPP) { in dsa_user_change_conduit()
2902 return dev->netdev_ops == &dsa_user_netdev_ops; in dsa_user_dev_check()
2911 struct dsa_port *dp; in dsa_user_changeupper() local
2916 dp = dsa_user_to_port(dev); in dsa_user_changeupper()
2917 extack = netdev_notifier_info_to_extack(&info->info); in dsa_user_changeupper()
2919 if (netif_is_bridge_master(info->upper_dev)) { in dsa_user_changeupper()
2920 if (info->linking) { in dsa_user_changeupper()
2921 err = dsa_port_bridge_join(dp, info->upper_dev, extack); in dsa_user_changeupper()
2923 dsa_bridge_mtu_normalization(dp); in dsa_user_changeupper()
2924 if (err == -EOPNOTSUPP) { in dsa_user_changeupper()
2931 dsa_port_bridge_leave(dp, info->upper_dev); in dsa_user_changeupper()
2934 } else if (netif_is_lag_master(info->upper_dev)) { in dsa_user_changeupper()
2935 if (info->linking) { in dsa_user_changeupper()
2936 err = dsa_port_lag_join(dp, info->upper_dev, in dsa_user_changeupper()
2937 info->upper_info, extack); in dsa_user_changeupper()
2938 if (err == -EOPNOTSUPP) { in dsa_user_changeupper()
2945 dsa_port_lag_leave(dp, info->upper_dev); in dsa_user_changeupper()
2948 } else if (is_hsr_master(info->upper_dev)) { in dsa_user_changeupper()
2949 if (info->linking) { in dsa_user_changeupper()
2950 err = dsa_port_hsr_join(dp, info->upper_dev, extack); in dsa_user_changeupper()
2951 if (err == -EOPNOTSUPP) { in dsa_user_changeupper()
2958 dsa_port_hsr_leave(dp, info->upper_dev); in dsa_user_changeupper()
2969 struct dsa_port *dp; in dsa_user_prechangeupper() local
2974 dp = dsa_user_to_port(dev); in dsa_user_prechangeupper()
2976 if (netif_is_bridge_master(info->upper_dev) && !info->linking) in dsa_user_prechangeupper()
2977 dsa_port_pre_bridge_leave(dp, info->upper_dev); in dsa_user_prechangeupper()
2978 else if (netif_is_lag_master(info->upper_dev) && !info->linking) in dsa_user_prechangeupper()
2979 dsa_port_pre_lag_leave(dp, info->upper_dev); in dsa_user_prechangeupper()
2981 * meaningfully placed under a bridge yet in dsa_user_prechangeupper()
2994 struct dsa_port *dp; in dsa_user_lag_changeupper() local
3003 dp = dsa_user_to_port(lower); in dsa_user_lag_changeupper()
3004 if (!dp->lag) in dsa_user_lag_changeupper()
3026 struct dsa_port *dp; in dsa_user_lag_prechangeupper() local
3035 dp = dsa_user_to_port(lower); in dsa_user_lag_prechangeupper()
3036 if (!dp->lag) in dsa_user_lag_prechangeupper()
3054 struct dsa_port *dp; in dsa_prevent_bridging_8021q_upper() local
3056 ext_ack = netdev_notifier_info_to_extack(&info->info); in dsa_prevent_bridging_8021q_upper()
3065 dp = dsa_user_to_port(user); in dsa_prevent_bridging_8021q_upper()
3066 br = dsa_port_bridge_dev_get(dp); in dsa_prevent_bridging_8021q_upper()
3070 /* Deny enslaving a VLAN device into a VLAN-aware bridge */ in dsa_prevent_bridging_8021q_upper()
3072 netif_is_bridge_master(info->upper_dev) && info->linking) { in dsa_prevent_bridging_8021q_upper()
3074 "Cannot make VLAN device join VLAN-aware bridge"); in dsa_prevent_bridging_8021q_upper()
3075 return notifier_from_errno(-EINVAL); in dsa_prevent_bridging_8021q_upper()
3085 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_check_8021q_upper() local
3086 struct net_device *br = dsa_port_bridge_dev_get(dp); in dsa_user_check_8021q_upper()
3095 extack = netdev_notifier_info_to_extack(&info->info); in dsa_user_check_8021q_upper()
3096 vid = vlan_dev_vlan_id(info->upper_dev); in dsa_user_check_8021q_upper()
3098 /* br_vlan_get_info() returns -EINVAL or -ENOENT if the in dsa_user_check_8021q_upper()
3105 "This VLAN is already configured by the bridge"); in dsa_user_check_8021q_upper()
3106 return notifier_from_errno(-EBUSY); in dsa_user_check_8021q_upper()
3117 struct dsa_port *dp; in dsa_user_prechangeupper_sanity_check() local
3123 dp = dsa_user_to_port(dev); in dsa_user_prechangeupper_sanity_check()
3124 ds = dp->ds; in dsa_user_prechangeupper_sanity_check()
3126 if (ds->ops->port_prechangeupper) { in dsa_user_prechangeupper_sanity_check()
3127 err = ds->ops->port_prechangeupper(ds, dp->index, info); in dsa_user_prechangeupper_sanity_check()
3132 if (is_vlan_dev(info->upper_dev)) in dsa_user_prechangeupper_sanity_check()
3154 return notifier_from_errno(-EINVAL); in dsa_lag_conduit_validate()
3160 if (!dsa_port_tree_same(lower1->dsa_ptr, in dsa_lag_conduit_validate()
3161 lower2->dsa_ptr)) { in dsa_lag_conduit_validate()
3164 return notifier_from_errno(-EINVAL); in dsa_lag_conduit_validate()
3176 struct netlink_ext_ack *extack = netdev_notifier_info_to_extack(&info->info); in dsa_conduit_prechangeupper_sanity_check()
3181 if (!info->linking) in dsa_conduit_prechangeupper_sanity_check()
3185 if (dsa_user_dev_check(info->upper_dev)) in dsa_conduit_prechangeupper_sanity_check()
3188 /* Allow bridge uppers of DSA conduits, subject to further in dsa_conduit_prechangeupper_sanity_check()
3191 if (netif_is_bridge_master(info->upper_dev)) in dsa_conduit_prechangeupper_sanity_check()
3197 if (netif_is_lag_master(info->upper_dev)) in dsa_conduit_prechangeupper_sanity_check()
3198 return dsa_lag_conduit_validate(info->upper_dev, extack); in dsa_conduit_prechangeupper_sanity_check()
3202 return notifier_from_errno(-EBUSY); in dsa_conduit_prechangeupper_sanity_check()
3209 struct netlink_ext_ack *extack = netdev_notifier_info_to_extack(&info->info); in dsa_lag_conduit_prechangelower_sanity_check()
3210 struct net_device *lag_dev = info->upper_dev; in dsa_lag_conduit_prechangelower_sanity_check()
3217 if (!info->linking) in dsa_lag_conduit_prechangelower_sanity_check()
3223 return notifier_from_errno(-EINVAL); in dsa_lag_conduit_prechangelower_sanity_check()
3227 if (!dsa_port_tree_same(dev->dsa_ptr, lower->dsa_ptr)) { in dsa_lag_conduit_prechangelower_sanity_check()
3230 return notifier_from_errno(-EINVAL); in dsa_lag_conduit_prechangelower_sanity_check()
3239 /* Don't allow bridging of DSA conduits, since the bridge layer rx_handler
3241 * chance to strip off and parse the DSA switch tag protocol header (the bridge
3252 struct net_device *br = info->upper_dev; in dsa_bridge_prechangelower_sanity_check()
3260 if (!info->linking) in dsa_bridge_prechangelower_sanity_check()
3263 extack = netdev_notifier_info_to_extack(&info->info); in dsa_bridge_prechangelower_sanity_check()
3272 return notifier_from_errno(-EINVAL); in dsa_bridge_prechangelower_sanity_check()
3283 struct dsa_port *dp; in dsa_tree_migrate_ports_from_lag_conduit() local
3286 dsa_tree_for_each_user_port(dp, dst) { in dsa_tree_migrate_ports_from_lag_conduit()
3287 if (dsa_port_to_conduit(dp) != lag_dev) in dsa_tree_migrate_ports_from_lag_conduit()
3290 err = dsa_user_change_conduit(dp->user, new_conduit, NULL); in dsa_tree_migrate_ports_from_lag_conduit()
3292 netdev_err(dp->user, in dsa_tree_migrate_ports_from_lag_conduit()
3294 new_conduit->name, ERR_PTR(err)); in dsa_tree_migrate_ports_from_lag_conduit()
3304 struct dsa_port *cpu_dp = conduit->dsa_ptr; in dsa_conduit_lag_join()
3305 struct dsa_switch_tree *dst = cpu_dp->dst; in dsa_conduit_lag_join()
3306 struct dsa_port *dp; in dsa_conduit_lag_join() local
3313 dsa_tree_for_each_user_port(dp, dst) { in dsa_conduit_lag_join()
3314 if (dsa_port_to_conduit(dp) != conduit) in dsa_conduit_lag_join()
3317 err = dsa_user_change_conduit(dp->user, lag_dev, extack); in dsa_conduit_lag_join()
3325 dsa_tree_for_each_user_port_continue_reverse(dp, dst) { in dsa_conduit_lag_join()
3326 if (dsa_port_to_conduit(dp) != lag_dev) in dsa_conduit_lag_join()
3329 err = dsa_user_change_conduit(dp->user, conduit, NULL); in dsa_conduit_lag_join()
3331 netdev_err(dp->user, in dsa_conduit_lag_join()
3333 conduit->name, ERR_PTR(err)); in dsa_conduit_lag_join()
3337 dsa_conduit_lag_teardown(lag_dev, conduit->dsa_ptr); in dsa_conduit_lag_join()
3345 struct dsa_port *dp, *cpu_dp = lag_dev->dsa_ptr; in dsa_conduit_lag_leave() local
3346 struct dsa_switch_tree *dst = cpu_dp->dst; in dsa_conduit_lag_leave()
3353 new_cpu_dp = lower->dsa_ptr; in dsa_conduit_lag_leave()
3362 dsa_tree_for_each_user_port(dp, dst) in dsa_conduit_lag_leave()
3363 if (dsa_port_to_conduit(dp) == lag_dev) in dsa_conduit_lag_leave()
3364 dp->cpu_dp = new_cpu_dp; in dsa_conduit_lag_leave()
3369 lag_dev->dsa_ptr = new_cpu_dp; in dsa_conduit_lag_leave()
3381 dsa_conduit_lag_teardown(lag_dev, conduit->dsa_ptr); in dsa_conduit_lag_leave()
3393 extack = netdev_notifier_info_to_extack(&info->info); in dsa_conduit_changeupper()
3395 if (netif_is_lag_master(info->upper_dev)) { in dsa_conduit_changeupper()
3396 if (info->linking) { in dsa_conduit_changeupper()
3397 err = dsa_conduit_lag_join(dev, info->upper_dev, in dsa_conduit_changeupper()
3398 info->upper_info, extack); in dsa_conduit_changeupper()
3401 dsa_conduit_lag_leave(dev, info->upper_dev); in dsa_conduit_changeupper()
3464 struct dsa_port *dp; in dsa_user_netdevice_event() local
3468 dp = dsa_user_to_port(dev); in dsa_user_netdevice_event()
3470 err = dsa_port_lag_change(dp, info->lower_state_info); in dsa_user_netdevice_event()
3477 dp = dev->dsa_ptr; in dsa_user_netdevice_event()
3479 err = dsa_port_lag_change(dp, info->lower_state_info); in dsa_user_netdevice_event()
3491 struct dsa_port *cpu_dp = dev->dsa_ptr; in dsa_user_netdevice_event()
3492 struct dsa_switch_tree *dst = cpu_dp->ds->dst; in dsa_user_netdevice_event()
3515 struct dsa_port *dp, *cpu_dp; in dsa_user_netdevice_event() local
3522 cpu_dp = dev->dsa_ptr; in dsa_user_netdevice_event()
3523 dst = cpu_dp->ds->dst; in dsa_user_netdevice_event()
3527 list_for_each_entry(dp, &dst->ports, list) { in dsa_user_netdevice_event()
3528 if (!dsa_port_is_user(dp)) in dsa_user_netdevice_event()
3531 if (dp->cpu_dp != cpu_dp) in dsa_user_netdevice_event()
3534 list_add(&dp->user->close_list, &close_list); in dsa_user_netdevice_event()
3553 info.addr = switchdev_work->addr; in dsa_fdb_offload_notify()
3554 info.vid = switchdev_work->vid; in dsa_fdb_offload_notify()
3557 switchdev_work->orig_dev, &info.info, NULL); in dsa_fdb_offload_notify()
3564 const unsigned char *addr = switchdev_work->addr; in dsa_user_switchdev_event_work()
3565 struct net_device *dev = switchdev_work->dev; in dsa_user_switchdev_event_work()
3566 u16 vid = switchdev_work->vid; in dsa_user_switchdev_event_work()
3568 struct dsa_port *dp; in dsa_user_switchdev_event_work() local
3571 dp = dsa_user_to_port(dev); in dsa_user_switchdev_event_work()
3572 ds = dp->ds; in dsa_user_switchdev_event_work()
3574 switch (switchdev_work->event) { in dsa_user_switchdev_event_work()
3576 if (switchdev_work->host_addr) in dsa_user_switchdev_event_work()
3577 err = dsa_port_bridge_host_fdb_add(dp, addr, vid); in dsa_user_switchdev_event_work()
3578 else if (dp->lag) in dsa_user_switchdev_event_work()
3579 err = dsa_port_lag_fdb_add(dp, addr, vid); in dsa_user_switchdev_event_work()
3581 err = dsa_port_fdb_add(dp, addr, vid); in dsa_user_switchdev_event_work()
3583 dev_err(ds->dev, in dsa_user_switchdev_event_work()
3585 dp->index, addr, vid, err); in dsa_user_switchdev_event_work()
3592 if (switchdev_work->host_addr) in dsa_user_switchdev_event_work()
3593 err = dsa_port_bridge_host_fdb_del(dp, addr, vid); in dsa_user_switchdev_event_work()
3594 else if (dp->lag) in dsa_user_switchdev_event_work()
3595 err = dsa_port_lag_fdb_del(dp, addr, vid); in dsa_user_switchdev_event_work()
3597 err = dsa_port_fdb_del(dp, addr, vid); in dsa_user_switchdev_event_work()
3599 dev_err(ds->dev, in dsa_user_switchdev_event_work()
3601 dp->index, addr, vid, err); in dsa_user_switchdev_event_work()
3613 const struct dsa_port *dp = dsa_user_to_port(dev); in dsa_foreign_dev_check() local
3614 struct dsa_switch_tree *dst = dp->ds->dst; in dsa_foreign_dev_check()
3632 struct dsa_port *dp = dsa_user_to_port(dev); in dsa_user_fdb_event() local
3633 bool host_addr = fdb_info->is_local; in dsa_user_fdb_event()
3634 struct dsa_switch *ds = dp->ds; in dsa_user_fdb_event()
3636 if (ctx && ctx != dp) in dsa_user_fdb_event()
3639 if (!dp->bridge) in dsa_user_fdb_event()
3643 if (dsa_port_offloads_bridge_port(dp, orig_dev)) in dsa_user_fdb_event()
3646 /* FDB entries learned by the software bridge or by foreign in dsa_user_fdb_event()
3647 * bridge ports should be installed as host addresses only if in dsa_user_fdb_event()
3650 if (!ds->assisted_learning_on_cpu_port) in dsa_user_fdb_event()
3664 if (dp->lag && !host_addr) { in dsa_user_fdb_event()
3665 if (!ds->ops->lag_fdb_add || !ds->ops->lag_fdb_del) in dsa_user_fdb_event()
3666 return -EOPNOTSUPP; in dsa_user_fdb_event()
3668 if (!ds->ops->port_fdb_add || !ds->ops->port_fdb_del) in dsa_user_fdb_event()
3669 return -EOPNOTSUPP; in dsa_user_fdb_event()
3674 return -ENOMEM; in dsa_user_fdb_event()
3678 orig_dev->name, fdb_info->addr, fdb_info->vid, in dsa_user_fdb_event()
3681 INIT_WORK(&switchdev_work->work, dsa_user_switchdev_event_work); in dsa_user_fdb_event()
3682 switchdev_work->event = event; in dsa_user_fdb_event()
3683 switchdev_work->dev = dev; in dsa_user_fdb_event()
3684 switchdev_work->orig_dev = orig_dev; in dsa_user_fdb_event()
3686 ether_addr_copy(switchdev_work->addr, fdb_info->addr); in dsa_user_fdb_event()
3687 switchdev_work->vid = fdb_info->vid; in dsa_user_fdb_event()
3688 switchdev_work->host_addr = host_addr; in dsa_user_fdb_event()
3690 dsa_schedule_work(&switchdev_work->work); in dsa_user_fdb_event()